ClickHouse/docs/ja/sql-reference/aggregate-functions/reference/entropy.md
2024-11-18 11:58:58 +09:00

947 B

slug sidebar_position
/ja/sql-reference/aggregate-functions/reference/entropy 131

entropy

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

構文

entropy(val)

引数

  • val — 任意の型の値のカラム。

返される値

  • シャノンエントロピー。

型: Float64

クエリ:

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;

結果:

┌─entropy(vals)─┬─entropy(strings)─┐
│             1 │             1.75 │
└───────────────┴──────────────────┘