2021-02-08 12:58:27 +00:00
---
2022-04-03 23:05:35 +00:00
toc_priority: 300
toc_title: studentTTest
2021-02-08 12:58:27 +00:00
---
# studentTTest {#studentttest}
2021-07-29 15:20:55 +00:00
Applies Student's t-test to samples from two populations.
2021-02-08 12:58:27 +00:00
**Syntax**
``` sql
2022-01-01 06:37:18 +00:00
studentTTest([confidence_level])(sample_data, sample_index)
2021-02-08 12:58:27 +00:00
```
Values of both samples are in the `sample_data` column. If `sample_index` equals to 0 then the value in that row belongs to the sample from the first population. Otherwise it belongs to the sample from the second population.
The null hypothesis is that means of populations are equal. Normal distribution with equal variances is assumed.
2021-02-15 21:33:53 +00:00
**Arguments**
2021-02-08 12:58:27 +00:00
2021-03-13 18:18:45 +00:00
- `sample_data` — Sample data. [Integer ](../../../sql-reference/data-types/int-uint.md ), [Float ](../../../sql-reference/data-types/float.md ) or [Decimal ](../../../sql-reference/data-types/decimal.md ).
- `sample_index` — Sample index. [Integer ](../../../sql-reference/data-types/int-uint.md ).
2021-02-08 12:58:27 +00:00
2022-01-01 06:37:18 +00:00
**Parameters**
- `confidence_level` — Confidence level in order to calculate confidence intervals. [Float ](../../../sql-reference/data-types/float.md ).
2021-02-08 12:58:27 +00:00
**Returned values**
2022-02-03 10:53:00 +00:00
[Tuple ](../../../sql-reference/data-types/tuple.md ) with two or four elements (if the optional `confidence_level` is specified):
2021-02-11 20:16:01 +00:00
2021-02-08 12:58:27 +00:00
- calculated t-statistic. [Float64 ](../../../sql-reference/data-types/float.md ).
- calculated p-value. [Float64 ](../../../sql-reference/data-types/float.md ).
2022-01-01 06:37:18 +00:00
- [calculated confidence-interval-low.] [Float64 ](../../../sql-reference/data-types/float.md ).
- [calculated confidence-interval-high.] [Float64 ](../../../sql-reference/data-types/float.md ).
2021-02-08 12:58:27 +00:00
**Example**
Input table:
``` text
┌─sample_data─┬─sample_index─┐
│ 20.3 │ 0 │
│ 21.1 │ 0 │
│ 21.9 │ 1 │
│ 21.7 │ 0 │
│ 19.9 │ 1 │
│ 21.8 │ 1 │
└─────────────┴──────────────┘
```
Query:
``` sql
SELECT studentTTest(sample_data, sample_index) FROM student_ttest;
```
Result:
``` text
┌─studentTTest(sample_data, sample_index)───┐
│ (-0.21739130434783777,0.8385421208415731) │
└───────────────────────────────────────────┘
```
**See Also**
- [Student's t-test ](https://en.wikipedia.org/wiki/Student%27s_t-test )
- [welchTTest function ](welchttest.md#welchttest )
2021-09-19 20:05:54 +00:00
[Original article ](https://clickhouse.com/docs/en/sql-reference/aggregate-functions/reference/studentttest/ ) <!--hide-->