/** * @param observed1 array of observed frequency counts of the first data set * @param observed2 array of observed frequency counts of the second data set * @return p-value * @throws IllegalArgumentException if preconditions are not met * @throws MathException if an error occurs computing the p-value * @since 1.2 */ public double chiSquareTestDataSetsComparison(long[] observed1, long[] observed2) throws IllegalArgumentException, MathException { distribution.setDegreesOfFreedom((double) observed1.length - 1); return 1 - distribution.cumulativeProbability( chiSquareDataSetsComparison(observed1, observed2)); }
ChiSquaredDistribution dist = new ChiSquaredDistribution(df); double chidst = 1 - dist.cumulativeProbability(chi);
/** * @param observed1 array of observed frequency counts of the first data set * @param observed2 array of observed frequency counts of the second data set * @return p-value * @throws IllegalArgumentException if preconditions are not met * @throws MathException if an error occurs computing the p-value * @since 1.2 */ public double chiSquareTestDataSetsComparison(long[] observed1, long[] observed2) throws IllegalArgumentException, MathException { distribution.setDegreesOfFreedom((double) observed1.length - 1); return 1 - distribution.cumulativeProbability( chiSquareDataSetsComparison(observed1, observed2)); }
/** * @param observed1 array of observed frequency counts of the first data set * @param observed2 array of observed frequency counts of the second data set * @return p-value * @throws IllegalArgumentException if preconditions are not met * @throws MathException if an error occurs computing the p-value * @since 1.2 */ public double chiSquareTestDataSetsComparison(long[] observed1, long[] observed2) throws IllegalArgumentException, MathException { distribution.setDegreesOfFreedom((double) observed1.length - 1); return 1 - distribution.cumulativeProbability( chiSquareDataSetsComparison(observed1, observed2)); }
/** * {@inheritDoc} * <p><strong>Note: </strong>This implementation rescales the * <code>expected</code> array if necessary to ensure that the sum of the * expected and observed counts are equal.</p> * * @param observed array of observed frequency counts * @param expected array of expected frequency counts * @return p-value * @throws IllegalArgumentException if preconditions are not met * @throws MathException if an error occurs computing the p-value */ public double chiSquareTest(double[] expected, long[] observed) throws IllegalArgumentException, MathException { distribution.setDegreesOfFreedom(expected.length - 1.0); return 1.0 - distribution.cumulativeProbability( chiSquare(expected, observed)); }
/** * {@inheritDoc} * <p><strong>Note: </strong>This implementation rescales the * <code>expected</code> array if necessary to ensure that the sum of the * expected and observed counts are equal.</p> * * @param observed array of observed frequency counts * @param expected array of expected frequency counts * @return p-value * @throws IllegalArgumentException if preconditions are not met * @throws MathException if an error occurs computing the p-value */ public double chiSquareTest(double[] expected, long[] observed) throws IllegalArgumentException, MathException { distribution.setDegreesOfFreedom(expected.length - 1.0); return 1.0 - distribution.cumulativeProbability( chiSquare(expected, observed)); }
/** * {@inheritDoc} * <p><strong>Note: </strong>This implementation rescales the * <code>expected</code> array if necessary to ensure that the sum of the * expected and observed counts are equal.</p> * * @param observed array of observed frequency counts * @param expected array of expected frequency counts * @return p-value * @throws IllegalArgumentException if preconditions are not met * @throws MathException if an error occurs computing the p-value */ public double chiSquareTest(double[] expected, long[] observed) throws IllegalArgumentException, MathException { distribution.setDegreesOfFreedom(expected.length - 1.0); return 1.0 - distribution.cumulativeProbability( chiSquare(expected, observed)); }
/** * @param counts array representation of 2-way table * @return p-value * @throws IllegalArgumentException if preconditions are not met * @throws MathException if an error occurs computing the p-value */ public double chiSquareTest(long[][] counts) throws IllegalArgumentException, MathException { checkArray(counts); double df = ((double) counts.length -1) * ((double) counts[0].length - 1); distribution.setDegreesOfFreedom(df); return 1 - distribution.cumulativeProbability(chiSquare(counts)); }
/** * @param counts array representation of 2-way table * @return p-value * @throws IllegalArgumentException if preconditions are not met * @throws MathException if an error occurs computing the p-value */ public double chiSquareTest(long[][] counts) throws IllegalArgumentException, MathException { checkArray(counts); double df = ((double) counts.length -1) * ((double) counts[0].length - 1); distribution.setDegreesOfFreedom(df); return 1 - distribution.cumulativeProbability(chiSquare(counts)); }
/** * @param counts array representation of 2-way table * @return p-value * @throws IllegalArgumentException if preconditions are not met * @throws MathException if an error occurs computing the p-value */ public double chiSquareTest(long[][] counts) throws IllegalArgumentException, MathException { checkArray(counts); double df = ((double) counts.length -1) * ((double) counts[0].length - 1); distribution.setDegreesOfFreedom(df); return 1 - distribution.cumulativeProbability(chiSquare(counts)); }