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

> 値のカラムの シャノンエントロピー を計算します。

# entropy

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

導入バージョン: v20.1.0

値のカラムの [シャノンエントロピー](https://en.wikipedia.org/wiki/Entropy_\(information_theory\)) を計算します。

**構文**

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

**引数**

* `val` — 任意の型の値を持つカラム。[`Any`](/ja/reference/data-types)

**戻り値**

シャノンエントロピーを返します。[`Float64`](/ja/reference/data-types/float)

**例**

**基本的なエントロピーの計算**

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