DimensionMismatchException, MaxCountExceededException {
// pass a null rng to avoid unneeded overhead as we will not sample from this distribution
final ChiSquaredDistribution distribution =
new ChiSquaredDistribution(null, expected.length - 1.0);
return 1.0 - distribution.cumulativeProbability(chiSquare(expected, observed));
}
/**
* Performs a <a href="http://www.itl.nist.gov/div898/handbook/eda/section3/eda35f.htm">
* Chi-square goodness of fit test</a> evaluating the null hypothesis that the