Skip to content

chiSquaredTest

chiSquaredTest(observed, expected, options?): ChiSquaredTestResult

Defined in: chi-squared-test.ts:46

Pearson’s chi-squared test, comparing observed counts against expected ones.

The p-value is the chi-squared upper tail computed directly, so a result significant at 1e-30 reports that rather than zero.

readonly number[]

Counts actually seen. Not modified.

readonly number[]

Counts the null hypothesis predicts, in the same order. Every one must be positive — a zero expected count makes the statistic undefined, not infinite.

ChiSquaredTestOptions

How many parameters were fitted from the data.

ChiSquaredTestResult

The statistic, its degrees of freedom and the p-value.

When the inputs differ in length, hold fewer than two categories, contain a non-positive expected count, disagree on the total count, or leave no degrees of freedom.