NumberIsTooSmallException, OutOfRangeException, MaxCountExceededException { checkSignificanceLevel(alpha); return pairedTTest(sample1, sample2) < alpha;
OutOfRangeException, MaxCountExceededException { checkSignificanceLevel(alpha); return tTest(mu, sampleStats) < alpha;
/** * @see org.apache.commons.math3.stat.inference.TTest#pairedT(double[], double[]) */ public static double pairedT(final double[] sample1, final double[] sample2) throws NullArgumentException, NoDataException, DimensionMismatchException, NumberIsTooSmallException { return T_TEST.pairedT(sample1, sample2); }
OutOfRangeException, MaxCountExceededException { checkSignificanceLevel(alpha); return homoscedasticTTest(sample1, sample2) < alpha;
tTestImpl = new TTest(); testStat = tTestImpl.homoscedasticT(val0, val1); p = tTestImpl.homoscedasticTTest(val0, val1); p = adjustedPValue(p, testStat); } else { testStat = tTestImpl.t(val0, val1); p = tTestImpl.tTest(val0, val1); p = adjustedPValue(p, testStat); tTestImpl = new TTest(); testStat = tTestImpl.homoscedasticT(sumStats0, sumStats1); p = tTestImpl.homoscedasticTTest(sumStats0, sumStats1); p = adjustedPValue(p, testStat); } else { testStat = tTestImpl.t(sumStats0, sumStats1); p = tTestImpl.tTest(sumStats0, sumStats1); p = adjustedPValue(p, testStat);
@Override public Object doWork(Object value1, Object value2) throws IOException { TTest tTest = new TTest(); Map map = new HashMap(); Tuple tuple = new Tuple(map); double tstat = tTest.t(mean, samples); double pval = tTest.tTest(mean, samples); double tstat = tTest.t(samples1, samples2); double pval = tTest.tTest(samples1, samples2); tuple.put("t-statistic", tstat); tuple.put("p-value", pval);
DimensionMismatchException, NumberIsTooSmallException { checkSampleData(sample1); checkSampleData(sample2); double meanDifference = StatUtils.meanDifference(sample1, sample2); return t(meanDifference, 0, StatUtils.varianceDifference(sample1, sample2, meanDifference), sample1.length);
@Override public Object doWork(Object value1, Object value2) throws IOException { TTest tTest = new TTest(); Map map = new HashMap(); Tuple tuple = new Tuple(map); double tstat = tTest.pairedT(samples1, samples2); double pval = tTest.pairedTTest(samples1, samples2); tuple.put("t-statistic", tstat); tuple.put("p-value", pval);
/** * @see org.apache.commons.math3.stat.inference.TTest#tTest(double, org.apache.commons.math3.stat.descriptive.StatisticalSummary) */ public static double tTest(final double mu, final StatisticalSummary sampleStats) throws NullArgumentException, NumberIsTooSmallException, MaxCountExceededException { return T_TEST.tTest(mu, sampleStats); }
MaxCountExceededException { checkSampleData(sample); return tTest(StatUtils.mean(sample), mu, StatUtils.variance(sample), sample.length);
@Override public double[] compute(final Map<String, Object> combinedAggregators) { final ArrayOfDoublesSketch sketch1 = (ArrayOfDoublesSketch) getFields().get(0).compute(combinedAggregators); final ArrayOfDoublesSketch sketch2 = (ArrayOfDoublesSketch) getFields().get(1).compute(combinedAggregators); if (sketch1.getNumValues() != sketch2.getNumValues()) { throw new IAE( "Sketches have different number of values: %d and %d", sketch1.getNumValues(), sketch2.getNumValues() ); } final SummaryStatistics[] stats1 = getStats(sketch1); final SummaryStatistics[] stats2 = getStats(sketch2); final int numberOfValues = sketch1.getNumValues(); final double[] pValues = new double[numberOfValues]; final TTest test = new TTest(); for (int i = 0; i < pValues.length; i++) { pValues[i] = test.tTest(stats1[i], stats2[i]); } return pValues; }
/** * Returns the result of a two-tailed paired t-test. * Since n should always be greater 30, normality can be assumed. * @param otherAlgorithm - * @return the p-value result of a paired t-test */ public double getTTestPValue(HypothesisTestableMetric otherAlgorithm){ return new TTest().pairedTTest(getDetailedResults().toDoubleArray(), otherAlgorithm.getDetailedResults().toDoubleArray()); }
throws NullArgumentException, NumberIsTooSmallException { checkSampleData(sample1); checkSampleData(sample2); return homoscedasticT(StatUtils.mean(sample1), StatUtils.mean(sample2), StatUtils.variance(sample1), StatUtils.variance(sample2), sample1.length, sample2.length);
MaxCountExceededException { checkSampleData(sample1); checkSampleData(sample2); return homoscedasticTTest(StatUtils.mean(sample1), StatUtils.mean(sample2), StatUtils.variance(sample1),
/** * @see org.apache.commons.math3.stat.inference.TTest#t(double, org.apache.commons.math3.stat.descriptive.StatisticalSummary) */ public static double t(final double mu, final StatisticalSummary sampleStats) throws NullArgumentException, NumberIsTooSmallException { return T_TEST.t(mu, sampleStats); }
/** * Computes p-value for 2-sided, 2-sample t-test. * <p> * Does not assume subpopulation variances are equal. Degrees of freedom * are estimated from the data.</p> * * @param m1 first sample mean * @param m2 second sample mean * @param v1 first sample variance * @param v2 second sample variance * @param n1 first sample n * @param n2 second sample n * @return p-value * @throws MaxCountExceededException if an error occurs computing the p-value * @throws NotStrictlyPositiveException if the estimated degrees of freedom is not * strictly positive */ protected double tTest(final double m1, final double m2, final double v1, final double v2, final double n1, final double n2) throws MaxCountExceededException, NotStrictlyPositiveException { final double t = FastMath.abs(t(m1, m2, v1, v2, n1, n2)); final double degreesOfFreedom = df(v1, v2, n1, n2); // pass a null rng to avoid unneeded overhead as we will not sample from this distribution final TDistribution distribution = new TDistribution(null, degreesOfFreedom); return 2.0 * distribution.cumulativeProbability(-t); }
/** * @see org.apache.commons.math3.stat.inference.TTest#pairedTTest(double[], double[]) */ public static double pairedTTest(final double[] sample1, final double[] sample2) throws NullArgumentException, NoDataException, DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException { return T_TEST.pairedTTest(sample1, sample2); }
/** * Creates a new filter. * @param minSampleSize The minimum sample size before tests are used * to filter the entities. * @param alpha The alpha value for the test. 0.5 for 95% is recommended. */ public HeuristicConfidenceFilter(ConfidenceFilterSerializer serializer, int minSampleSize, double alpha) { this.serializer = serializer; this.minSampleSize = minSampleSize; this.alpha = alpha; ttest = new TTest(); }
/** * @see org.apache.commons.math3.stat.inference.TTest#homoscedasticT(org.apache.commons.math3.stat.descriptive.StatisticalSummary, org.apache.commons.math3.stat.descriptive.StatisticalSummary) */ public static double homoscedasticT(final StatisticalSummary sampleStats1, final StatisticalSummary sampleStats2) throws NullArgumentException, NumberIsTooSmallException { return T_TEST.homoscedasticT(sampleStats1, sampleStats2); }
/** * @see org.apache.commons.math3.stat.inference.TTest#homoscedasticTTest(double[], double[]) */ public static double homoscedasticTTest(final double[] sample1, final double[] sample2) throws NullArgumentException, NumberIsTooSmallException, MaxCountExceededException { return T_TEST.homoscedasticTTest(sample1, sample2); }