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

> 对样本与已知总体均值执行单样本 Student t 检验。

# studentTTestOneSample

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

Introduced in：v25.10.0

对样本应用单样本 Student t 检验，以判断样本均值是否与已知总体均值存在差异。

假定数据服从正态分布。原假设为样本均值等于总体均值。

可选参数 `confidence_level` 用于计算置信区间。

**注意：**

* 至少需要 2 个观测值；否则结果为 `(nan, nan)` (如果请求区间，则区间值为 `nan`) 。
* 对于常量或近似常量输入，由于标准误为零 (或实际上接近零) ，也会返回 `nan`。

**See Also**

* [Student t 检验](https://en.wikipedia.org/wiki/Student%27s_t-test)
* [studentTTest function](/zh/reference/functions/aggregate-functions/studentTTest)

**Syntax**

```sql theme={null}
studentTTestOneSample([confidence_level])(sample_data, population_mean)
```

**参数**

* `confidence_level` — 可选。置信区间的置信水平，取值为 (0, 1) 之间的浮点数。[`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)
* `population_mean` — 用于检验比较的已知总体均值 (通常为常量) 。[`(U)Int*`](/zh/reference/data-types/int-uint) 或 [`Float*`](/zh/reference/data-types/float) 或 [`Decimal`](/zh/reference/data-types/decimal)

**返回值**

返回一个包含两个或四个元素的 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 studentTTestOneSample()(value, 20.0) FROM t;
```

```response title=Response theme={null}
```

**含 95% 置信区间**

```sql title=Query theme={null}
SELECT studentTTestOneSample(0.95)(value, 20.0) FROM t;
```

```response title=Response theme={null}
```

**另请参见**

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