Skip to content

chiSquaredGoodnessOfFitTest(observed, probabilities, options?): ChiSquaredGoodnessOfFitTestResult

Defined in: packages/hypothesis-test/src/chi-squared-goodness-of-fit-test.ts:38

Compare category counts against probabilities scaled by the observed total. The probability sum must lie within 1e-12 of one. The calculation preserves the supplied probabilities. It drops categories with two zero counts and returns a zero p-value when any positive observation has zero expectation.

Pooling works inward from both tails and merges any remaining low interior categories toward larger indices. The p-value is the upper tail of the asymptotic chi-squared distribution. Time and working storage are linear in the category count.

ArrayLike<number>

ArrayLike<Probability>

ChiSquaredGoodnessOfFitTestOptions

ChiSquaredGoodnessOfFitTestResult

With INVALID_COUNT for an invalid count or unsafe total, LENGTH_MISMATCH, TOO_FEW_CATEGORIES, INVALID_PROBABILITIES, ZERO_TOTAL_COUNT, INVALID_OPTION for an invalid pooling threshold, or INVALID_DEGREES_OF_FREEDOM.

With INVALID_PARAMETER when the degrees of freedom exceed the supported maximum.