> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-fix-nav-issues.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Calculates Shannon entropy of for a column of values.

# entropy

<h2 id="entropy">
  entropy
</h2>

Introduced in: v20.1.0

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

**Syntax**

```sql theme={null}
entropy(val)
```

**Arguments**

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

**Returned value**

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

**Examples**

**Basic entropy calculation**

```sql title=Query theme={null}
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 title=Response theme={null}
┌─entropy(vals)─┬─entropy(strings)─┐
│             1 │             1.75 │
└───────────────┴──────────────────┘
```
