# oneSampleTTest

> **oneSampleTTest**(`sample`, `expectedMean`, `options?`): [`OneSampleTTestResult`](/reference/knotkit/hypothesis-test/interfaces/onesamplettestresult/)

Defined in: [packages/hypothesis-test/src/one-sample-t-test.ts:21](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/hypothesis-test/src/one-sample-t-test.ts#L21)

Student’s t-test of whether a sample’s mean equals `expectedMean`, matching `scipy.stats.ttest_1samp`. The statistic is `(mean - expectedMean) / sqrt(variance / n)` with `n - 1` degrees of freedom. `greater` tests a mean above `expectedMean`. Uses O(n) time and constant working storage.

A constant sample has zero variance. SciPy returns NaN or an infinite statistic there; this function throws.

## Parameters

### sample

`ArrayLike`<`number`>

### expectedMean

`number`

### options?

[`OneSampleTTestOptions`](/reference/knotkit/hypothesis-test/interfaces/onesamplettestoptions/)

## Returns

[`OneSampleTTestResult`](/reference/knotkit/hypothesis-test/interfaces/onesamplettestresult/)

## Throws

With `EMPTY_SAMPLE`, `TOO_SMALL_SAMPLE` below two values, `NON_FINITE_SAMPLE` (also for a non-finite `expectedMean`), `ZERO_VARIANCE`, or `INVALID_OPTION`.

## Throws

With `INVALID_PARAMETER` above 1e5 degrees of freedom.
