chiSq += chiSq(ids.count(id), expected);
}
System.out.println("X^2 = " + chiSq);
ChiSquare dist = new ChiSquare(df, new MersenneTwister());
// p-value is ~= prob of seeing this distribution from fair router
double pValue = 1.0 - dist.cdf(chiSq);
System.out.println("p-value = " + pValue);
assertTrue("Non-uniform load distribution detected.", pValue >= 0.05);
}
private double chiSq(double observed, double expected) {