mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 00:52:02 +00:00
WIP update-aggregate-funcions-in-zh
This commit is contained in:
parent
502a5d62da
commit
31d6a4369b
@ -0,0 +1,23 @@
|
||||
---
|
||||
toc_priority: 141
|
||||
---
|
||||
|
||||
# deltaSum {#agg_functions-deltasum}
|
||||
|
||||
**语法**
|
||||
|
||||
``` sql
|
||||
deltaSum(value)
|
||||
```
|
||||
|
||||
计算连续行之间的差值和。如果差值为负,则忽略。
|
||||
`value`必须是整型或浮点类型。
|
||||
|
||||
示例:
|
||||
|
||||
```sql
|
||||
select deltaSum(arrayJoin([1, 2, 3])); -- => 2
|
||||
select deltaSum(arrayJoin([1, 2, 3, 0, 3, 4, 2, 3])); -- => 7
|
||||
select deltaSum(arrayJoin([2.25, 3, 4.5])); -- => 2.25
|
||||
```
|
||||
|
@ -0,0 +1,72 @@
|
||||
---
|
||||
toc_priority: 310
|
||||
toc_title: mannWhitneyUTest
|
||||
---
|
||||
|
||||
# mannWhitneyUTest {#mannwhitneyutest}
|
||||
|
||||
对两个总体的样本应用 Mann-Whitney 秩检验。
|
||||
|
||||
**语法**
|
||||
|
||||
``` sql
|
||||
mannWhitneyUTest[(alternative[, continuity_correction])](sample_data, sample_index)
|
||||
```
|
||||
|
||||
两个样本的值都在 `sample_data` 列中。如果 `sample_index` 等于 0,则该行的值属于第一个总体的样本。 反之属于第二个总体的样本。
|
||||
零假设是两个总体随机相等。也可以检验单边假设。该检验不假设数据具有正态分布。
|
||||
|
||||
**参数**
|
||||
|
||||
- `sample_data` — 样本数据。[Integer](../../../sql-reference/data-types/int-uint.md), [Float](../../../sql-reference/data-types/float.md) 或 [Decimal](../../../sql-reference/data-types/decimal.md)。
|
||||
- `sample_index` — 样本索引。[Integer](../../../sql-reference/data-types/int-uint.md).
|
||||
|
||||
**参数**
|
||||
|
||||
- `alternative` — 供选假设。(可选,默认值是: `'two-sided'` 。) [String](../../../sql-reference/data-types/string.md)。
|
||||
- `'two-sided'`;
|
||||
- `'greater'`;
|
||||
- `'less'`。
|
||||
- `continuity_correction` — 如果不为0,那么将对p值进行正态近似的连续性修正。(可选,默认:1。) [UInt64](../../../sql-reference/data-types/int-uint.md)。
|
||||
|
||||
**返回值**
|
||||
|
||||
[元组](../../../sql-reference/data-types/tuple.md),有两个元素:
|
||||
|
||||
- 计算出U统计量。[Float64](../../../sql-reference/data-types/float.md)。
|
||||
- 计算出的p值。[Float64](../../../sql-reference/data-types/float.md)。
|
||||
|
||||
|
||||
**示例**
|
||||
|
||||
输入表:
|
||||
|
||||
``` text
|
||||
┌─sample_data─┬─sample_index─┐
|
||||
│ 10 │ 0 │
|
||||
│ 11 │ 0 │
|
||||
│ 12 │ 0 │
|
||||
│ 1 │ 1 │
|
||||
│ 2 │ 1 │
|
||||
│ 3 │ 1 │
|
||||
└─────────────┴──────────────┘
|
||||
```
|
||||
|
||||
查询:
|
||||
|
||||
``` sql
|
||||
SELECT mannWhitneyUTest('greater')(sample_data, sample_index) FROM mww_ttest;
|
||||
```
|
||||
|
||||
结果:
|
||||
|
||||
``` text
|
||||
┌─mannWhitneyUTest('greater')(sample_data, sample_index)─┐
|
||||
│ (9,0.04042779918503192) │
|
||||
└────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
**参见**
|
||||
|
||||
- [Mann–Whitney U test](https://en.wikipedia.org/wiki/Mann%E2%80%93Whitney_U_test)
|
||||
- [Stochastic ordering](https://en.wikipedia.org/wiki/Stochastic_ordering)
|
@ -0,0 +1,64 @@
|
||||
---
|
||||
toc_priority: 300
|
||||
toc_title: studentTTest
|
||||
---
|
||||
|
||||
# studentTTest {#studentttest}
|
||||
|
||||
对两个总体的样本应用t检验。
|
||||
|
||||
**语法**
|
||||
|
||||
``` sql
|
||||
studentTTest(sample_data, sample_index)
|
||||
```
|
||||
|
||||
两个样本的值都在 `sample_data` 列中。如果 `sample_index` 等于 0,则该行的值属于第一个总体的样本。 反之属于第二个总体的样本。
|
||||
零假设是总体的均值相等。假设为方差相等的正态分布。
|
||||
|
||||
**参数**
|
||||
|
||||
- `sample_data` — 样本数据。[Integer](../../../sql-reference/data-types/int-uint.md), [Float](../../../sql-reference/data-types/float.md) 或 [Decimal](../../../sql-reference/data-types/decimal.md)。
|
||||
- `sample_index` — 样本索引。[Integer](../../../sql-reference/data-types/int-uint.md)。
|
||||
|
||||
**返回值**
|
||||
|
||||
[元组](../../../sql-reference/data-types/tuple.md),有两个元素:
|
||||
|
||||
- 计算出的t统计量。 [Float64](../../../sql-reference/data-types/float.md)。
|
||||
- 计算出的p值。[Float64](../../../sql-reference/data-types/float.md)。
|
||||
|
||||
|
||||
**示例**
|
||||
|
||||
输入表:
|
||||
|
||||
``` text
|
||||
┌─sample_data─┬─sample_index─┐
|
||||
│ 20.3 │ 0 │
|
||||
│ 21.1 │ 0 │
|
||||
│ 21.9 │ 1 │
|
||||
│ 21.7 │ 0 │
|
||||
│ 19.9 │ 1 │
|
||||
│ 21.8 │ 1 │
|
||||
└─────────────┴──────────────┘
|
||||
```
|
||||
|
||||
查询:
|
||||
|
||||
``` sql
|
||||
SELECT studentTTest(sample_data, sample_index) FROM student_ttest;
|
||||
```
|
||||
|
||||
结果:
|
||||
|
||||
``` text
|
||||
┌─studentTTest(sample_data, sample_index)───┐
|
||||
│ (-0.21739130434783777,0.8385421208415731) │
|
||||
└───────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
**参见**
|
||||
|
||||
- [Student's t-test](https://en.wikipedia.org/wiki/Student%27s_t-test)
|
||||
- [welchTTest function](../../../sql-reference/aggregate-functions/reference/welchttest.md#welchttest)
|
@ -0,0 +1,62 @@
|
||||
---
|
||||
toc_priority: 301
|
||||
toc_title: welchTTest
|
||||
---
|
||||
|
||||
# welchTTest {#welchttest}
|
||||
|
||||
对两个总体的样本应用 Welch t检验。
|
||||
|
||||
**语法**
|
||||
|
||||
``` sql
|
||||
welchTTest(sample_data, sample_index)
|
||||
```
|
||||
两个样本的值都在 `sample_data` 列中。如果 `sample_index` 等于 0,则该行的值属于第一个总体的样本。 反之属于第二个总体的样本。
|
||||
零假设是群体的均值相等。假设为正态分布。总体可能具有不相等的方差。
|
||||
|
||||
**参数**
|
||||
|
||||
- `sample_data` — 样本数据。[Integer](../../../sql-reference/data-types/int-uint.md), [Float](../../../sql-reference/data-types/float.md) 或 [Decimal](../../../sql-reference/data-types/decimal.md).
|
||||
- `sample_index` — 样本索引。[Integer](../../../sql-reference/data-types/int-uint.md).
|
||||
|
||||
**返回值**
|
||||
|
||||
[元组](../../../sql-reference/data-types/tuple.md),有两个元素:
|
||||
|
||||
- 计算出的t统计量。 [Float64](../../../sql-reference/data-types/float.md)。
|
||||
- 计算出的p值。[Float64](../../../sql-reference/data-types/float.md)。
|
||||
|
||||
**示例**
|
||||
|
||||
输入表:
|
||||
|
||||
``` text
|
||||
┌─sample_data─┬─sample_index─┐
|
||||
│ 20.3 │ 0 │
|
||||
│ 22.1 │ 0 │
|
||||
│ 21.9 │ 0 │
|
||||
│ 18.9 │ 1 │
|
||||
│ 20.3 │ 1 │
|
||||
│ 19 │ 1 │
|
||||
└─────────────┴──────────────┘
|
||||
```
|
||||
|
||||
查询:
|
||||
|
||||
``` sql
|
||||
SELECT welchTTest(sample_data, sample_index) FROM welch_ttest;
|
||||
```
|
||||
|
||||
结果:
|
||||
|
||||
``` text
|
||||
┌─welchTTest(sample_data, sample_index)─────┐
|
||||
│ (2.7988719532211235,0.051807360348581945) │
|
||||
└───────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
**参见**
|
||||
|
||||
- [Welch's t-test](https://en.wikipedia.org/wiki/Welch%27s_t-test)
|
||||
- [studentTTest function](../../../sql-reference/aggregate-functions/reference/studentttest.md#studentttest)
|
Loading…
Reference in New Issue
Block a user