* @return p-value
* @throws IllegalArgumentException if preconditions are not met
*/
public double chiSquareTest(double[] expected, double[] observed)
throws IllegalArgumentException, MathException {
ChiSquaredDistribution chiSquaredDistribution =
DistributionFactory.newInstance().createChiSquareDistribution(
(double) expected.length - 1);
return 1
- chiSquaredDistribution.cummulativeProbability(
chiSquare(expected, observed));
}