slug: /zh/sql-reference/aggregate-functions/reference/welchttest sidebar_position: 301

sidebar_label: welchTTest

welchTTest {#welchttest}

对两个总体的样本应用 Welch t检验。

语法

  1. welchTTest(sample_data, sample_index)

两个样本的值都在 sample_data 列中。如果 sample_index 等于 0,则该行的值属于第一个总体的样本。 反之属于第二个总体的样本。 零假设是群体的均值相等。假设为正态分布。总体可能具有不相等的方差。

参数

返回值

元组,有两个元素:

示例

输入表:

  1. ┌─sample_data─┬─sample_index─┐
  2. 20.3 0
  3. 22.1 0
  4. 21.9 0
  5. 18.9 1
  6. 20.3 1
  7. 19 1
  8. └─────────────┴──────────────┘

查询:

  1. SELECT welchTTest(sample_data, sample_index) FROM welch_ttest;

结果:

  1. ┌─welchTTest(sample_data, sample_index)─────┐
  2. (2.7988719532211235,0.051807360348581945)
  3. └───────────────────────────────────────────┘

参见