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.
Parameters
Section titled “Parameters”observed
Section titled “observed”ArrayLike<number>
probabilities
Section titled “probabilities”ArrayLike<Probability>
options?
Section titled “options?”ChiSquaredGoodnessOfFitTestOptions
Returns
Section titled “Returns”ChiSquaredGoodnessOfFitTestResult
Throws
Section titled “Throws”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.
Throws
Section titled “Throws”With INVALID_PARAMETER when the degrees of freedom exceed the supported maximum.