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

> Applies the student t-test to samples from two populations.

# studentTTest

<h2 id="studentTTest">
  studentTTest
</h2>

Introduced in: v21.1.0

Applies Student's t-test to samples from two populations.

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.

**See Also**

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

**Syntax**

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

**Parameters**

* `confidence_level` — Optional. Confidence level in order to calculate confidence intervals. [`Float`](/reference/data-types/float)

**Arguments**

* `sample_data` — Sample data. [`Integer`](/reference/data-types/int-uint) or [`Float`](/reference/data-types/float) or [`Decimal`](/reference/data-types/decimal)
* `sample_index` — Sample index. [`Integer`](/reference/data-types/int-uint)

**Returned value**

Returns a tuple with two or four elements (if the optional `confidence_level` is specified): calculated t-statistic, calculated p-value, \[calculated confidence-interval-low], \[calculated confidence-interval-high]. [`Tuple(Float64, Float64)`](/reference/data-types/tuple) or [`Tuple(Float64, Float64, Float64, Float64)`](/reference/data-types/tuple)

**Examples**

**Basic usage**

```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) │
└───────────────────────────────────────────┘
```

**See Also**

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