entropy
Calculates the [Shannon entropy](https://en.
This page describes the RawTree engine binary used to generate this reference. It does not define Query API support. Descriptions retain upstream ClickHouse terminology. See SQL interface scope.
Calculates the Shannon entropy for a column of values.
Syntax
entropy(val)Arguments
val— Column of values of any type.Any
Returned value
Returns Shannon entropy. Float64
Examples
Basic entropy calculation
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┌─entropy(vals)─┬─entropy(strings)─┐
│ 1 │ 1.75 │
└───────────────┴──────────────────┘Introduced in version 20.1.0.