/** * @see org.apache.commons.math3.stat.inference.KolmogorovSmirnovTest#kolmogorovSmirnovTest(RealDistribution, double[]) * @since 3.3 */ public static double kolmogorovSmirnovTest(RealDistribution dist, double[] data) throws InsufficientDataException, NullArgumentException { return KS_TEST.kolmogorovSmirnovTest(dist, data); }
/** * @see org.apache.commons.math3.stat.inference.KolmogorovSmirnovTest#kolmogorovSmirnovTest(double[], double[], boolean) * @since 3.3 */ public static double kolmogorovSmirnovTest(double[] x, double[] y, boolean strict) throws InsufficientDataException, NullArgumentException { return KS_TEST.kolmogorovSmirnovTest(x, y, strict); }
/** * @see org.apache.commons.math3.stat.inference.KolmogorovSmirnovTest#kolmogorovSmirnovTest(RealDistribution, double[], boolean) * @since 3.3 */ public static double kolmogorovSmirnovTest(RealDistribution dist, double[] data, boolean strict) throws InsufficientDataException, NullArgumentException { return KS_TEST.kolmogorovSmirnovTest(dist, data, strict); }
/** * @see org.apache.commons.math3.stat.inference.KolmogorovSmirnovTest#kolmogorovSmirnovTest(RealDistribution, double[], double) * @since 3.3 */ public static boolean kolmogorovSmirnovTest(RealDistribution dist, double[] data, double alpha) throws InsufficientDataException, NullArgumentException { return KS_TEST.kolmogorovSmirnovTest(dist, data, alpha); }
/** * @see org.apache.commons.math3.stat.inference.KolmogorovSmirnovTest#kolmogorovSmirnovTest(double[], double[]) * @since 3.3 */ public static double kolmogorovSmirnovTest(double[] x, double[] y) throws InsufficientDataException, NullArgumentException { return KS_TEST.kolmogorovSmirnovTest(x, y); }
/** * Computes the <i>p-value</i>, or <i>observed significance level</i>, of a one-sample <a * href="http://en.wikipedia.org/wiki/Kolmogorov-Smirnov_test"> Kolmogorov-Smirnov test</a> * evaluating the null hypothesis that {@code data} conforms to {@code distribution}. * * @param distribution reference distribution * @param data sample being being evaluated * @return the p-value associated with the null hypothesis that {@code data} is a sample from * {@code distribution} * @throws InsufficientDataException if {@code data} does not have length at least 2 * @throws NullArgumentException if {@code data} is null */ public double kolmogorovSmirnovTest(RealDistribution distribution, double[] data) { return kolmogorovSmirnovTest(distribution, data, false); }
/** * Computes the <i>p-value</i>, or <i>observed significance level</i>, of a two-sample <a * href="http://en.wikipedia.org/wiki/Kolmogorov-Smirnov_test"> Kolmogorov-Smirnov test</a> * evaluating the null hypothesis that {@code x} and {@code y} are samples drawn from the same * probability distribution. Assumes the strict form of the inequality used to compute the * p-value. See {@link #kolmogorovSmirnovTest(RealDistribution, double[], boolean)}. * * @param x first sample dataset * @param y second sample dataset * @return p-value associated with the null hypothesis that {@code x} and {@code y} represent * samples from the same distribution * @throws InsufficientDataException if either {@code x} or {@code y} does not have length at * least 2 * @throws NullArgumentException if either {@code x} or {@code y} is null */ public double kolmogorovSmirnovTest(double[] x, double[] y) { return kolmogorovSmirnovTest(x, y, true); }
/** * Performs a <a href="http://en.wikipedia.org/wiki/Kolmogorov-Smirnov_test"> Kolmogorov-Smirnov * test</a> evaluating the null hypothesis that {@code data} conforms to {@code distribution}. * * @param distribution reference distribution * @param data sample being being evaluated * @param alpha significance level of the test * @return true iff the null hypothesis that {@code data} is a sample from {@code distribution} * can be rejected with confidence 1 - {@code alpha} * @throws InsufficientDataException if {@code data} does not have length at least 2 * @throws NullArgumentException if {@code data} is null */ public boolean kolmogorovSmirnovTest(RealDistribution distribution, double[] data, double alpha) { if ((alpha <= 0) || (alpha > 0.5)) { throw new OutOfRangeException(LocalizedFormats.OUT_OF_BOUND_SIGNIFICANCE_LEVEL, alpha, 0, 0.5); } return kolmogorovSmirnovTest(distribution, data) < alpha; }
/** * 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; }
/** * @see org.apache.commons.math3.stat.inference.KolmogorovSmirnovTest#kolmogorovSmirnovTest(RealDistribution, double[], double) * @since 3.3 */ public static boolean kolmogorovSmirnovTest(RealDistribution dist, double[] data, double alpha) throws InsufficientDataException, NullArgumentException { return KS_TEST.kolmogorovSmirnovTest(dist, data, alpha); }
/** * @see org.apache.commons.math3.stat.inference.KolmogorovSmirnovTest#kolmogorovSmirnovTest(double[], double[], boolean) * @since 3.3 */ public static double kolmogorovSmirnovTest(double[] x, double[] y, boolean strict) throws InsufficientDataException, NullArgumentException { return KS_TEST.kolmogorovSmirnovTest(x, y, strict); }
/** * @see org.apache.commons.math3.stat.inference.KolmogorovSmirnovTest#kolmogorovSmirnovTest(RealDistribution, double[], boolean) * @since 3.3 */ public static double kolmogorovSmirnovTest(RealDistribution dist, double[] data, boolean strict) throws InsufficientDataException, NullArgumentException { return KS_TEST.kolmogorovSmirnovTest(dist, data, strict); }
/** * @see org.apache.commons.math3.stat.inference.KolmogorovSmirnovTest#kolmogorovSmirnovTest(RealDistribution, double[]) * @since 3.3 */ public static double kolmogorovSmirnovTest(RealDistribution dist, double[] data) throws InsufficientDataException, NullArgumentException { return KS_TEST.kolmogorovSmirnovTest(dist, data); }
/** * @see org.apache.commons.math3.stat.inference.KolmogorovSmirnovTest#kolmogorovSmirnovTest(double[], double[]) * @since 3.3 */ public static double kolmogorovSmirnovTest(double[] x, double[] y) throws InsufficientDataException, NullArgumentException { return KS_TEST.kolmogorovSmirnovTest(x, y); }
/** * Computes the <i>p-value</i>, or <i>observed significance level</i>, of a one-sample <a * href="http://en.wikipedia.org/wiki/Kolmogorov-Smirnov_test"> Kolmogorov-Smirnov test</a> * evaluating the null hypothesis that {@code data} conforms to {@code distribution}. * * @param distribution reference distribution * @param data sample being being evaluated * @return the p-value associated with the null hypothesis that {@code data} is a sample from * {@code distribution} * @throws InsufficientDataException if {@code data} does not have length at least 2 * @throws NullArgumentException if {@code data} is null */ public double kolmogorovSmirnovTest(RealDistribution distribution, double[] data) { return kolmogorovSmirnovTest(distribution, data, false); }
/** * Computes the <i>p-value</i>, or <i>observed significance level</i>, of a two-sample <a * href="http://en.wikipedia.org/wiki/Kolmogorov-Smirnov_test"> Kolmogorov-Smirnov test</a> * evaluating the null hypothesis that {@code x} and {@code y} are samples drawn from the same * probability distribution. Assumes the strict form of the inequality used to compute the * p-value. See {@link #kolmogorovSmirnovTest(RealDistribution, double[], boolean)}. * * @param x first sample dataset * @param y second sample dataset * @return p-value associated with the null hypothesis that {@code x} and {@code y} represent * samples from the same distribution * @throws InsufficientDataException if either {@code x} or {@code y} does not have length at * least 2 * @throws NullArgumentException if either {@code x} or {@code y} is null */ public double kolmogorovSmirnovTest(double[] x, double[] y) { return kolmogorovSmirnovTest(x, y, true); }
public double getKStest() { final KolmogorovSmirnovTest test = new KolmogorovSmirnovTest(); final double pValue = test.kolmogorovSmirnovTest(p1Counts, p2Counts); return pValue; }
/** * Performs a <a href="http://en.wikipedia.org/wiki/Kolmogorov-Smirnov_test"> Kolmogorov-Smirnov * test</a> evaluating the null hypothesis that {@code data} conforms to {@code distribution}. * * @param distribution reference distribution * @param data sample being being evaluated * @param alpha significance level of the test * @return true iff the null hypothesis that {@code data} is a sample from {@code distribution} * can be rejected with confidence 1 - {@code alpha} * @throws InsufficientDataException if {@code data} does not have length at least 2 * @throws NullArgumentException if {@code data} is null */ public boolean kolmogorovSmirnovTest(RealDistribution distribution, double[] data, double alpha) { if ((alpha <= 0) || (alpha > 0.5)) { throw new OutOfRangeException(LocalizedFormats.OUT_OF_BOUND_SIGNIFICANCE_LEVEL, alpha, 0, 0.5); } return kolmogorovSmirnovTest(distribution, data) < alpha; }
/** * 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()); } }