tl.nist.gov/div898/handbook/eda/section3/eda35f.htm"> Chi-Square statistic comparing
observed
and
expected
frequency counts.
This statistic can be used to perform a Chi-Square test evaluating the null hypothesis that the observed counts follow the expected distribution.
Preconditions:
- Expected counts must all be positive.
- Observed counts must all be ≥ 0.
- The observed and expected arrays must have the same length and their common length must be at least 2.
If any of the preconditions are not met, an IllegalArgumentException
is thrown.
Note: This implementation rescales the expected
array if necessary to ensure that the sum of the expected and observed counts are equal.
@param observed array of observed frequency counts
@param expected array of expected frequency counts
@return chiSquare test statistic
@throws NotPositiveException if
observed
has negative entries
@throws NotStrictlyPositiveException if
expected
has entries that arenot strictly positive
@throws DimensionMismatchException if the arrays length is less than 2