Skip to main content
Module

x/simplestatistics/src/chi_squared_goodness_of_fit.js

simple statistics for node & browser javascript
Latest
import * as simplestatistics from "https://deno.land/x/simplestatistics@v7.8.3/src/chi_squared_goodness_of_fit.js";

Functions

The χ2 (Chi-Squared) Goodness-of-Fit Test uses a measure of goodness of fit which is the sum of differences between observed and expected outcome frequencies (that is, counts of observations), each squared and divided by the number of observations expected given the hypothesized distribution. The resulting χ2 statistic, chiSquared, can be compared to the chi-squared distribution to determine the goodness of fit. In order to determine the degrees of freedom of the chi-squared distribution, one takes the total number of observed frequencies and subtracts the number of estimated parameters. The test statistic follows, approximately, a chi-square distribution with (k − c) degrees of freedom where k is the number of non-empty cells and c is the number of estimated parameters for the distribution.