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.
Parameters
Section titled “Parameters”observed
Section titled “observed”readonly number[]
Counts actually seen. Not modified.
expected
Section titled “expected”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.
options?
Section titled “options?”How many parameters were fitted from the data.
Returns
Section titled “Returns”The statistic, its degrees of freedom and the p-value.
Throws
Section titled “Throws”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.