public static void assertGTest(final RealDistribution expectedDistribution,final double[] values,double alpha){
  final int numBins=values.length / 30;
  final double[] breaks=new double[numBins];
  for (int b=0; b < breaks.length; b++) {
    breaks[b]=expectedDistribution.inverseCumulativeProbability((double)b / numBins);
  }
  final long[] observed=new long[numBins];
  for (  final double value : values) {
    int b=0;
    do {
      b++;
    }
 while (b < numBins && value >= breaks[b]);
    observed[b - 1]++;
  }
  final double[] expected=new double[numBins];
  Arrays.fill(expected,(double)values.length / numBins);
  assertGTest(expected,observed,alpha);
}

public static void assertGTest ( final RealDistribution expectedDistribution , final double [ ] values , double alpha ) { final int numBins = values . length / 30 ; final double [ ] breaks = new double [ numBins ] ; for ( int b = 0 ; b < breaks . length ; b ++ ) { breaks [ b ] = expectedDistribution . inverseCumulativeProbability ( ( double ) b / numBins ) ; } final long [ ] observed = new long [ numBins ] ; for ( final double value : values ) { int b = 0 ; do { b ++ ; } while ( b < numBins && value >= breaks [ b ] ) ; observed [ b - 1 ] ++ ; } final double [ ] expected = new double [ numBins ] ; Arrays . fill ( expected , ( double ) values . length / numBins ) ; assertGTest ( expected , observed , alpha ) ; }
asserts the null hypothesis that the sample follows the given distribution , using a g - test
