slug: /zh/sql-reference/aggregate-functions/reference/mannwhitneyutest sidebar_position: 310

sidebar_label: mannWhitneyUTest

mannWhitneyUTest {#mannwhitneyutest}

对两个总体的样本应用 Mann-Whitney 秩检验。

语法

  1. mannWhitneyUTest[(alternative[, continuity_correction])](sample_data, sample_index)

两个样本的值都在 sample_data 列中。如果 sample_index 等于 0,则该行的值属于第一个总体的样本。 反之属于第二个总体的样本。 零假设是两个总体随机相等。也可以检验单边假设。该检验不假设数据具有正态分布。

参数

参数

  • alternative — 供选假设。(可选,默认值是: 'two-sided' 。) String
    • 'two-sided';
    • 'greater';
    • 'less'
  • continuity_correction — 如果不为0,那么将对p值进行正态近似的连续性修正。(可选,默认:1。) UInt64

返回值

元组,有两个元素:

示例

输入表:

  1. ┌─sample_data─┬─sample_index─┐
  2. 10 0
  3. 11 0
  4. 12 0
  5. 1 1
  6. 2 1
  7. 3 1
  8. └─────────────┴──────────────┘

查询:

  1. SELECT mannWhitneyUTest('greater')(sample_data, sample_index) FROM mww_ttest;

结果:

  1. ┌─mannWhitneyUTest('greater')(sample_data, sample_index)─┐
  2. (9,0.04042779918503192)
  3. └────────────────────────────────────────────────────────┘

参见