/** * @see org.apache.commons.math3.stat.inference.GTest#gDataSetsComparison(long[], long[]) * @since 3.1 */ public static double gDataSetsComparison(final long[] observed1, final long[] observed2) throws DimensionMismatchException, NotPositiveException, ZeroException { return G_TEST.gDataSetsComparison(observed1, observed2); }
/** * @see org.apache.commons.math3.stat.inference.GTest#gTestDataSetsComparison(long[], long[]) * @since 3.1 */ public static double gTestDataSetsComparison(final long[] observed1, final long[] observed2) throws DimensionMismatchException, NotPositiveException, ZeroException, MaxCountExceededException { return G_TEST.gTestDataSetsComparison(observed1, observed2); }
/** * @see org.apache.commons.math3.stat.inference.GTest#g(double[], long[]) * @since 3.1 */ public static double g(final double[] expected, final long[] observed) throws NotPositiveException, NotStrictlyPositiveException, DimensionMismatchException { return G_TEST.g(expected, observed); }
@Override public Object doWork(Object value1, Object value2) throws IOException { List<Number> listA = (List<Number>) value1; List<Number> listB = (List<Number>) value2; long[] sampleA = new long[listA.size()]; long[] sampleB = new long[listB.size()]; for(int i=0; i<sampleA.length; i++) { sampleA[i] = listA.get(i).longValue(); } for(int i=0; i<sampleB.length; i++) { sampleB[i] = listB.get(i).longValue(); } GTest gTest = new GTest(); double g = gTest.gDataSetsComparison(sampleA, sampleB); double p = gTest.gTestDataSetsComparison(sampleA, sampleB); Map<String,Number> m = new HashMap<>(); m.put("G-statistic", g); m.put("p-value", p); return new Tuple(m); } }
/** * @see org.apache.commons.math3.stat.inference.GTest#gTest( double[], long[] ) * @since 3.1 */ public static double gTest(final double[] expected, final long[] observed) throws NotPositiveException, NotStrictlyPositiveException, DimensionMismatchException, MaxCountExceededException { return G_TEST.gTest(expected, observed); }
/** * @see org.apache.commons.math3.stat.inference.GTest#gTestIntrinsic(double[], long[] ) * @since 3.1 */ public static double gTestIntrinsic(final double[] expected, final long[] observed) throws NotPositiveException, NotStrictlyPositiveException, DimensionMismatchException, MaxCountExceededException { return G_TEST.gTestIntrinsic(expected, observed); }
/** * @see org.apache.commons.math3.stat.inference.GTest#rootLogLikelihoodRatio(long, long, long, long) * @since 3.1 */ public static double rootLogLikelihoodRatio(final long k11, final long k12, final long k21, final long k22) throws DimensionMismatchException, NotPositiveException, ZeroException { return G_TEST.rootLogLikelihoodRatio(k11, k12, k21, k22); }
/** * @see org.apache.commons.math3.stat.inference.GTest#gTest( double[],long[],double) * @since 3.1 */ public static boolean gTest(final double[] expected, final long[] observed, final double alpha) throws NotPositiveException, NotStrictlyPositiveException, DimensionMismatchException, OutOfRangeException, MaxCountExceededException { return G_TEST.gTest(expected, observed, alpha); }
/** * @see org.apache.commons.math3.stat.inference.GTest#gTestIntrinsic(double[], long[] ) * @since 3.1 */ public static double gTestIntrinsic(final double[] expected, final long[] observed) throws NotPositiveException, NotStrictlyPositiveException, DimensionMismatchException, MaxCountExceededException { return G_TEST.gTestIntrinsic(expected, observed); }
/** * @see org.apache.commons.math3.stat.inference.GTest#rootLogLikelihoodRatio(long, long, long, long) * @since 3.1 */ public static double rootLogLikelihoodRatio(final long k11, final long k12, final long k21, final long k22) throws DimensionMismatchException, NotPositiveException, ZeroException { return G_TEST.rootLogLikelihoodRatio(k11, k12, k21, k22); }
final double llr = gDataSetsComparison( new long[]{k11, k12}, new long[]{k21, k22}); double sqrt = FastMath.sqrt(llr);
/** * @see org.apache.commons.math3.stat.inference.GTest#gTestDataSetsComparison(long[],long[],double) * @since 3.1 */ public static boolean gTestDataSetsComparison(final long[] observed1, final long[] observed2, final double alpha) throws DimensionMismatchException, NotPositiveException, ZeroException, OutOfRangeException, MaxCountExceededException { return G_TEST.gTestDataSetsComparison(observed1, observed2, alpha); }
/** * Returns the intrinsic (Hardy-Weinberg proportions) p-Value, as described * in p64-69 of McDonald, J.H. 2009. Handbook of Biological Statistics * (2nd ed.). Sparky House Publishing, Baltimore, Maryland. * * <p> The probability returned is the tail probability beyond * {@link #g(double[], long[]) g(expected, observed)} * in the ChiSquare distribution with degrees of freedom two less than the * common length of {@code expected} and {@code observed}.</p> * * @param observed array of observed frequency counts * @param expected array of expected frequency counts * @return p-value * @throws NotPositiveException if {@code observed} has negative entries * @throws NotStrictlyPositiveException {@code expected} has entries that are * not strictly positive * @throws DimensionMismatchException if the array lengths do not match or * are less than 2. * @throws MaxCountExceededException if an error occurs computing the * p-value. */ public double gTestIntrinsic(final double[] expected, final long[] observed) throws NotPositiveException, NotStrictlyPositiveException, DimensionMismatchException, MaxCountExceededException { // pass a null rng to avoid unneeded overhead as we will not sample from this distribution final ChiSquaredDistribution distribution = new ChiSquaredDistribution(null, expected.length - 2.0); return 1.0 - distribution.cumulativeProbability(g(expected, observed)); }
alpha, 0, 0.5); return gTest(expected, observed) < alpha;
new ChiSquaredDistribution(null, (double) observed1.length - 1); return 1 - distribution.cumulativeProbability( gDataSetsComparison(observed1, observed2));
LocalizedFormats.OUT_OF_BOUND_SIGNIFICANCE_LEVEL, alpha, 0, 0.5); return gTestDataSetsComparison(observed1, observed2) < alpha;
return 1.0 - distribution.cumulativeProbability(g(expected, observed));