> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-8c05c8a2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> 对来自两个总体的样本执行 Student t 检验。

# studentTTest

<div id="studentTTest">
  ## studentTTest
</div>

引入版本：v21.1.0

对来自两个总体的样本应用 Student's t 检验。

两个样本的值都位于 `sample_data` 列中。如果 `sample_index` 等于 0，则该行中的值属于第一个总体的样本；否则，属于第二个总体的样本。
原假设为两个总体的均值相等。假设数据服从方差相等的正态分布。

**另请参阅**

* [Student's t 检验](https://en.wikipedia.org/wiki/Student%27s_t-test)
* [welchTTest 函数](/zh/reference/functions/aggregate-functions/welchTTest)

**语法**

```sql theme={null}
studentTTest([confidence_level])(sample_data, sample_index)
```

**参数**

* `confidence_level` — 可选。用于计算置信区间的置信水平。[`Float`](/zh/reference/data-types/float)

**参数列表**

* `sample_data` — 样本数据。[`Integer`](/zh/reference/data-types/int-uint) 或 [`Float`](/zh/reference/data-types/float) 或 [`Decimal`](/zh/reference/data-types/decimal)
* `sample_index` — 样本索引。[`Integer`](/zh/reference/data-types/int-uint)

**返回值**

返回一个包含两个或四个元素的 Tuple (如果指定了可选参数 `confidence_level`) ：计算得到的 t 统计量、p 值、\[计算得到的置信区间下限]、\[计算得到的置信区间上限]。[`Tuple(Float64, Float64)`](/zh/reference/data-types/tuple) 或 [`Tuple(Float64, Float64, Float64, Float64)`](/zh/reference/data-types/tuple)

**示例**

**基本用法**

```sql title=Query theme={null}
SELECT studentTTest(sample_data, sample_index) FROM student_ttest;
```

```response title=Response theme={null}
┌─studentTTest(sample_data, sample_index)───┐
│ (-0.21739130434783777,0.8385421208415731) │
└───────────────────────────────────────────┘
```

**另请参阅**

* [Student's t 检验](https://en.wikipedia.org/wiki/Student%27s_t-test)
* [welchTTest 函数](/zh/reference/functions/aggregate-functions/welchTTest)
