slug: /zh/sql-reference/aggregate-functions/reference/studentttest sidebar_position: 300

sidebar_label: studentTTest

studentTTest {#studentttest}

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

语法

  1. studentTTest(sample_data, sample_index)

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

参数

返回值

元组,有两个元素:

示例

输入表:

  1. ┌─sample_data─┬─sample_index─┐
  2. 20.3 0
  3. 21.1 0
  4. 21.9 1
  5. 21.7 0
  6. 19.9 1
  7. 21.8 1
  8. └─────────────┴──────────────┘

查询:

  1. SELECT studentTTest(sample_data, sample_index) FROM student_ttest;

结果:

  1. ┌─studentTTest(sample_data, sample_index)───┐
  2. (-0.21739130434783777,0.8385421208415731)
  3. └───────────────────────────────────────────┘

参见