/** * Test if two clusters are significantly different in the metrics we look at for balancing. * * @param orig the utilization matrix from the original cluster * @param optimized the utilization matrix from the optimized cluster * @return The P value that the various derived resources come from the same probability distribution. The probability * that the null hypothesis is correct. */ public static double[] testDifference(double[][] orig, double[][] optimized) { int nResources = RawAndDerivedResource.values().length; if (orig.length != nResources) { throw new IllegalArgumentException("orig must have number of rows equal to RawAndDerivedResource."); } if (optimized.length != nResources) { throw new IllegalArgumentException("optimized must have number of rows equal to RawAndDerivedResource."); } if (orig[0].length != optimized[0].length) { throw new IllegalArgumentException("The number of brokers must be the same."); } double[] pValues = new double[orig.length]; //TODO: For small N we want to do statistical bootstrapping (not the same as bootstrapping data). for (int resourceIndex = 0; resourceIndex < nResources; resourceIndex++) { RandomGenerator rng = new MersenneTwister(0x5d11121018463324L); KolmogorovSmirnovTest kolmogorovSmirnovTest = new KolmogorovSmirnovTest(rng); pValues[resourceIndex] = kolmogorovSmirnovTest.kolmogorovSmirnovTest(orig[resourceIndex], optimized[resourceIndex]); } return pValues; }
public double getKStest() { final KolmogorovSmirnovTest test = new KolmogorovSmirnovTest(); final double pValue = test.kolmogorovSmirnovTest(p1Counts, p2Counts); return pValue; }
KolmogorovSmirnovTest test = new KolmogorovSmirnovTest(); double pValue;
KolmogorovSmirnovTest ks = new KolmogorovSmirnovTest(); double[] data = ((List<?>)second).stream().mapToDouble(item -> ((Number)item).doubleValue()).toArray();
/** * Returns the Kolmogorov-Smirnov (K-S) test of the polynomial fit as a * measurement of goodness of fit. * * @return the test statistic (p-value) used to evaluate the null hypothesis * that sampled data and polynomial fitted represent samples from * the same underlying distribution * * @throws NullPointerException * if curve fitting has not been performed * @throws InsufficientDataException * if sampled data contains fewer than two data points */ public double getKStestOfFit() { validateFit(); final KolmogorovSmirnovTest test = new KolmogorovSmirnovTest(); final double pValue = test.kolmogorovSmirnovTest(inputCounts, fCounts); return pValue; }
/** * Returns the result of a Kolmogorov Smirnov test * @param otherAlgorithm - * @return the p-value result of a Kolmogorov Smirnov test. */ public double getSmirnoffPValue(HypothesisTestableMetric otherAlgorithm){ return new KolmogorovSmirnovTest().kolmogorovSmirnovTest(getDetailedResults().toDoubleArray(), otherAlgorithm.getDetailedResults().toDoubleArray()); } }