mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-15 19:02:04 +00:00
901 B
901 B
slug | sidebar_position |
---|---|
/en/sql-reference/aggregate-functions/reference/entropy | 131 |
entropy
Calculates Shannon entropy of a column of values.
Syntax
entropy(val)
Arguments
val
— Column of values of any type.
Returned value
- Shannon entropy.
Type: Float64.
Example
Query:
CREATE TABLE entropy (`vals` UInt32,`strings` String) ENGINE = Memory;
INSERT INTO entropy VALUES (1, 'A'), (1, 'A'), (1,'A'), (1,'A'), (2,'B'), (2,'B'), (2,'C'), (2,'D');
SELECT entropy(vals), entropy(strings) FROM entropy;
Result:
┌─entropy(vals)─┬─entropy(strings)─┐
│ 1 │ 1.75 │
└───────────────┴──────────────────┘