From af86aea90dafcbf457e2f7d10dba5b5481e858d0 Mon Sep 17 00:00:00 2001 From: gyuton <40863448+gyuton@users.noreply.github.com> Date: Mon, 25 Oct 2021 14:47:18 +0300 Subject: [PATCH] DOCSUP-10111: Documented the entropy aggregate function (#30237) * initial commit * Update draft * small fix --- .../aggregate-functions/reference/entropy.md | 43 +++++++++++++++++++ .../aggregate-functions/reference/entropy.md | 43 +++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 docs/en/sql-reference/aggregate-functions/reference/entropy.md create mode 100644 docs/ru/sql-reference/aggregate-functions/reference/entropy.md diff --git a/docs/en/sql-reference/aggregate-functions/reference/entropy.md b/docs/en/sql-reference/aggregate-functions/reference/entropy.md new file mode 100644 index 00000000000..5ebb678e6b5 --- /dev/null +++ b/docs/en/sql-reference/aggregate-functions/reference/entropy.md @@ -0,0 +1,43 @@ +--- +toc_priority: 302 +--- + +# entropy {#entropy} + +Calculates [Shannon entropy](https://en.wikipedia.org/wiki/Entropy_(information_theory)) of a column of values. + +**Syntax** + +``` sql +entropy(val) +``` + +**Arguments** + +- `val` — Column of values of any type. + +**Returned value** + +- Shannon entropy. + +Type: [Float64](../../../sql-reference/data-types/float.md). + +**Example** + +Query: + +``` sql +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; +``` + +Result: + +``` text +┌─entropy(vals)─┬─entropy(strings)─┐ +│ 1 │ 1.75 │ +└───────────────┴──────────────────┘ +``` diff --git a/docs/ru/sql-reference/aggregate-functions/reference/entropy.md b/docs/ru/sql-reference/aggregate-functions/reference/entropy.md new file mode 100644 index 00000000000..b5abe00fd96 --- /dev/null +++ b/docs/ru/sql-reference/aggregate-functions/reference/entropy.md @@ -0,0 +1,43 @@ +--- +toc_priority: 302 +--- + +# entropy {#entropy} + +Вычисляет [информационную энтропию](https://ru.wikipedia.org/wiki/%D0%98%D0%BD%D1%84%D0%BE%D1%80%D0%BC%D0%B0%D1%86%D0%B8%D0%BE%D0%BD%D0%BD%D0%B0%D1%8F_%D1%8D%D0%BD%D1%82%D1%80%D0%BE%D0%BF%D0%B8%D1%8F) столбца данных. + +**Синтаксис** + +``` sql +entropy(val) +``` + +**Аргументы** + +- `val` — столбец значений любого типа + +**Возвращаемое значение** + +- Информационная энтропия. + +Тип: [Float64](../../../sql-reference/data-types/float.md). + +**Пример** + +Запрос: + +``` sql +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 +┌─entropy(vals)─┬─entropy(strings)─┐ +│ 1 │ 1.75 │ +└───────────────┴──────────────────┘ +```