# entropy (/docs/reference/sql/aggregate-functions/entropy)



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](/docs/reference/clickhouse-compatibility#service-interfaces).

Calculates the [Shannon entropy](https://en.wikipedia.org/wiki/Entropy_\(information_theory\)) for a column of values.

**Syntax**

```sql
entropy(val)
```

**Arguments**

* `val` — Column of values of any type. [`Any`](/reference/data-types)

**Returned value**

Returns Shannon entropy. [`Float64`](/reference/data-types/float)

**Examples**

**Basic entropy calculation**

```sql title=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
```

```text title=Response
┌─entropy(vals)─┬─entropy(strings)─┐
│             1 │             1.75 │
└───────────────┴──────────────────┘
```

*Introduced in version 20.1.0.*
