Skip to main content

entropy

Introduced in: v20.1.0 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
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
Response
┌─entropy(vals)─┬─entropy(strings)─┐
│             1 │             1.75 │
└───────────────┴──────────────────┘
Last modified on June 8, 2026