Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs for skew and kurt #1127

Merged
merged 2 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions docs/sql-manual/sql-functions/aggregate-functions/kurt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---
{
"title": "KURT,KURT_POP,KURTOSIS",
"language": "en"
}
---

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

## Description

Returns the [kurtosis](https://en.wikipedia.org/wiki/Kurtosis) of the expr expression.
The forumula used for this function is `4-th centrol moment / ((variance)^2) - 3`, when variance is zero, `kurtosis` will return `NULL`.

## Syntax

`kurtosis(expr)`

## Arguments

TinyInt/SmallInt/Integer/BigInt/Float/Double, Decimal will be casted to a float number.

## Return value

`Double`

## Example
```sql
create table statistic_test(tag int, val1 double not null, val2 double null) distributed by hash(tag) properties("replication_num"="1")

insert into statistic_test values (1, -10, -10),(2, -20, NULL),(3, 100, NULL),(4, 100, NULL),(5, 1000,1000);

// NULL is ignored
select kurt(val1), kurt(val2) from statistic_test
--------------

+-------------------+--------------------+
| kurt(val1) | kurt(val2) |
+-------------------+--------------------+
| 0.162124583734851 | -1.3330994719286338 |
+-------------------+--------------------+
1 row in set (0.02 sec)

// Each group just has one row, result is NULL
select kurt(val1), kurt(val2) from statistic_test group by tag
--------------

+------------+------------+
| kurt(val1) | kurt(val2) |
+------------+------------+
| NULL | NULL |
| NULL | NULL |
| NULL | NULL |
| NULL | NULL |
| NULL | NULL |
+------------+------------+
5 rows in set (0.02 sec)
```

## Related Commands

[skew](./skew.md)
84 changes: 84 additions & 0 deletions docs/sql-manual/sql-functions/aggregate-functions/skew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
{
"title": "SKEW,SKEW_POP,SKEWNESS",
"language": "en"
}
---

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

## skewness,skew,skew_pop
### Description

Returns the [skewness](https://en.wikipedia.org/wiki/Skewness) of the expr expression.
The forumula used for this function is `3-th centrol moment / ((variance)^{1.5})`, when variance is zero, `skewness` will return `NULL`.

### Syntax

`skewness(expr)`

### Arguments

TinyInt/SmallInt/Integer/BigInt/Float/Double, Decimal will be casted to a float number.

### Return value

`Double`

### Example
```sql
create table statistic_test (tag int, val1 double not null, val2 double null)
distributed by hash(tag) properties("replication_num"="1")

insert into statistic_test values (1, -10, -10),
(2, -20, NULL),
(3, 100, NULL),
(4, 100, NULL),
(5, 1000,1000);

// NULL is ignored
select skew(val1), skew(val2) from statistic_test
--------------

+--------------------+--------------------+
| skew(val1) | skew(val2) |
+--------------------+--------------------+
| 1.4337199628825619 | 1.1543940205711711 |
+--------------------+--------------------+
1 row in set (0.01 sec)

// Each group just has one row, result is NULL
select skew(val1), skew(val2) from statistic_test group by tag
--------------

+------------+------------+
| skew(val1) | skew(val2) |
+------------+------------+
| NULL | NULL |
| NULL | NULL |
| NULL | NULL |
| NULL | NULL |
| NULL | NULL |
+------------+------------+
5 rows in set (0.04 sec)
```
### Related Commands

[kurt](./kurt.md)
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
{
"title": "KURT,KURT_POP,KURTOSIS",
"language": "zh-CN"
}
---

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

## 描述

kurtosis 返回 expr 表达式的[峰度值](https://en.wikipedia.org/wiki/Kurtosis)。此函数使用的公式为 第四阶中心矩 / (方差的平方) - 3,当方差为零时,kurtosis 将返回 NULL。

## 语法

`kurtosis(expr)`

## 参数说明

TinyInt/SmallInt/Integer/BigInt/Float/Double, Decimal 会被 cast 成浮点数参与运算。

## 返回值说明

`Double`

## 举例
```sql
create table statistic_test(tag int, val1 double not null, val2 double null) distributed by hash(tag) properties("replication_num"="1");

insert into statistic_test values (1, -10, -10),(2, -20, NULL),(3, 100, NULL),(4, 100, NULL),(5, 1000,1000);

// NULL 值会被忽略
select kurt(val1), kurt(val2) from statistic_test;
--------------

+-------------------+--------------------+
| kurt(val1) | kurt(val2) |
+-------------------+--------------------+
| 0.162124583734851 | -1.3330994719286338 |
+-------------------+--------------------+
1 row in set (0.02 sec)

// 每组只有一行数据,结果为 NULL
select kurt(val1), kurt(val2) from statistic_test group by tag;
--------------

+------------+------------+
| kurt(val1) | kurt(val2) |
+------------+------------+
| NULL | NULL |
| NULL | NULL |
| NULL | NULL |
| NULL | NULL |
| NULL | NULL |
+------------+------------+
5 rows in set (0.02 sec)
```

## 相关命令

[skew](./skew.md)
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
{
"title": "SKEW,SKEW_POP,SKEWNESS",
"language": "en"
}
---

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

## skewness,skew,skew_pop
### 描述

返回表达式的 [斜度](https://en.wikipedia.org/wiki/Skewness)。
用来计算斜度的公式是 `3阶中心矩 / ((方差)^{1.5})`, 当方差为零时, `skewness` 会返回 `NULL`.

### 语法

`skewness(expr)`

### 参数说明

TinyInt/SmallInt/Integer/BigInt/Float/Double, Decimal 会被 cast 成浮点数参与运算。

### 返回值说明

`Double`

### 举例
```sql
create table statistic_test (tag int, val1 double not null, val2 double null)
distributed by hash(tag) properties("replication_num"="1")

insert into statistic_test values (1, -10, -10),
(2, -20, NULL),
(3, 100, NULL),
(4, 100, NULL),
(5, 1000,1000);

// NULL is ignored
select skew(val1), skew(val2) from statistic_test
--------------

+--------------------+--------------------+
| skew(val1) | skew(val2) |
+--------------------+--------------------+
| 1.4337199628825619 | 1.1543940205711711 |
+--------------------+--------------------+
1 row in set (0.01 sec)

// Each group just has one row, result is NULL
select skew(val1), skew(val2) from statistic_test group by tag
--------------

+------------+------------+
| skew(val1) | skew(val2) |
+------------+------------+
| NULL | NULL |
| NULL | NULL |
| NULL | NULL |
| NULL | NULL |
| NULL | NULL |
+------------+------------+
5 rows in set (0.04 sec)
```
### 相关命令

[kurt](./kurt.md)
Loading
Loading