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

> Calcula a entropia de Shannon de uma coluna de valores.

# entropy

<div id="entropy">
  ## entropy
</div>

Introduzido em: v20.1.0

Calcula a [entropia de Shannon](https://en.wikipedia.org/wiki/Entropy_\(information_theory\)) de uma coluna de valores.

**Sintaxe**

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

**Argumentos**

* `val` — Coluna com valores de qualquer tipo. [`Any`](/pt-BR/reference/data-types)

**Valor retornado**

Retorna a entropia de Shannon. [`Float64`](/pt-BR/reference/data-types/float)

**Exemplos**

**Cálculo básico de entropia**

```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 │
└───────────────┴──────────────────┘
```
