# twoSampleTTest

> **twoSampleTTest**(`first`, `second`, `options?`): [`TwoSampleTTestResult`](/reference/knotkit/hypothesis-test/interfaces/twosamplettestresult/)

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

Student’s pooled-variance t-test of whether two independent samples share a mean, matching `scipy.stats.ttest_ind(first, second, equal_var=True)`. The statistic is `(mean₁ - mean₂) / se`, where `se` uses the pooled variance, with `m + n - 2` degrees of freedom. `greater` tests a first mean above the second. Use `welchTTest` when the variances may differ. Uses O(m + n) time and constant working storage.

Constant samples have zero pooled variance. SciPy returns NaN or an infinite statistic there; this function throws.

## Parameters

### first

`ArrayLike`<`number`>

### second

`ArrayLike`<`number`>

### options?

[`TwoSampleTTestOptions`](/reference/knotkit/hypothesis-test/interfaces/twosamplettestoptions/)

## Returns

[`TwoSampleTTestResult`](/reference/knotkit/hypothesis-test/interfaces/twosamplettestresult/)

## Throws

With `EMPTY_SAMPLE`, `TOO_SMALL_SAMPLE` below three pooled values, `NON_FINITE_SAMPLE`, `ZERO_VARIANCE`, or `INVALID_OPTION`.

## Throws

With `INVALID_PARAMETER` above 1e5 degrees of freedom.
