/** * @param counts array representation of 2-way table * @param alpha significance level of the test * @return true iff null hypothesis can be rejected with confidence * 1 - alpha * @throws IllegalArgumentException if preconditions are not met * @throws MathException if an error occurs performing the test */ public boolean chiSquareTest(long[][] counts, double alpha) throws IllegalArgumentException, MathException { if ((alpha <= 0) || (alpha > 0.5)) { throw new IllegalArgumentException("bad significance level: " + alpha); } return (chiSquareTest(counts) < alpha); }
/** * {@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 * @param alpha significance level of the test * @return true iff null hypothesis can be rejected with confidence * 1 - alpha * @throws IllegalArgumentException if preconditions are not met * @throws MathException if an error occurs performing the test */ public boolean chiSquareTest(double[] expected, long[] observed, double alpha) throws IllegalArgumentException, MathException { if ((alpha <= 0) || (alpha > 0.5)) { throw new IllegalArgumentException( "bad significance level: " + alpha); } return (chiSquareTest(expected, observed) < alpha); }
/** * @param counts array representation of 2-way table * @param alpha significance level of the test * @return true iff null hypothesis can be rejected with confidence * 1 - alpha * @throws IllegalArgumentException if preconditions are not met * @throws MathException if an error occurs performing the test */ public boolean chiSquareTest(long[][] counts, double alpha) throws IllegalArgumentException, MathException { if ((alpha <= 0) || (alpha > 0.5)) { throw MathRuntimeException.createIllegalArgumentException( LocalizedFormats.OUT_OF_BOUND_SIGNIFICANCE_LEVEL, alpha, 0.0, 0.5); } return chiSquareTest(counts) < alpha; }
/** * @param counts array representation of 2-way table * @param alpha significance level of the test * @return true iff null hypothesis can be rejected with confidence * 1 - alpha * @throws IllegalArgumentException if preconditions are not met * @throws MathException if an error occurs performing the test */ public boolean chiSquareTest(long[][] counts, double alpha) throws IllegalArgumentException, MathException { if ((alpha <= 0) || (alpha > 0.5)) { throw MathRuntimeException.createIllegalArgumentException( "out of bounds significance level {0}, must be between {1} and {2}", alpha, 0.0, 0.5); } return chiSquareTest(counts) < alpha; }
/** * {@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 * @param alpha significance level of the test * @return true iff null hypothesis can be rejected with confidence * 1 - alpha * @throws IllegalArgumentException if preconditions are not met * @throws MathException if an error occurs performing the test */ public boolean chiSquareTest(double[] expected, long[] observed, double alpha) throws IllegalArgumentException, MathException { if ((alpha <= 0) || (alpha > 0.5)) { throw MathRuntimeException.createIllegalArgumentException( LocalizedFormats.OUT_OF_BOUND_SIGNIFICANCE_LEVEL, alpha, 0, 0.5); } return chiSquareTest(expected, observed) < alpha; }
/** * {@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 * @param alpha significance level of the test * @return true iff null hypothesis can be rejected with confidence * 1 - alpha * @throws IllegalArgumentException if preconditions are not met * @throws MathException if an error occurs performing the test */ public boolean chiSquareTest(double[] expected, long[] observed, double alpha) throws IllegalArgumentException, MathException { if ((alpha <= 0) || (alpha > 0.5)) { throw MathRuntimeException.createIllegalArgumentException( "out of bounds significance level {0}, must be between {1} and {2}", alpha, 0, 0.5); } return chiSquareTest(expected, observed) < alpha; }
public IValue chiSquareTest(IList dataValues){ makeChi(dataValues); try { return values.real(new ChiSquareTestImpl().chiSquareTest(expected, observed)); } catch (IllegalArgumentException e) { throw RuntimeExceptionFactory.illegalArgument(dataValues, null, null, e.getMessage()); } catch (MathException e) { throw RuntimeExceptionFactory.illegalArgument(dataValues, null, null, e.getMessage()); } }
final double chi2PValue = new ChiSquareTestImpl().chiSquareTest(counts); final double penalty = -10.0 * Math.log10(Math.max(chi2PValue, SMALLEST_CHI2_PVALUE));
public IValue chiSquareTest(IList dataValues, IReal alpha){ makeChi(dataValues); try { return values.bool(new ChiSquareTestImpl().chiSquareTest(expected, observed, alpha.doubleValue())); } catch (IllegalArgumentException e) { throw RuntimeExceptionFactory.illegalArgument(dataValues, null, null, e.getMessage()); } catch (MathException e) { throw RuntimeExceptionFactory.illegalArgument(dataValues, null, null, e.getMessage()); } }
ChiSquareTestImpl cs = new ChiSquareTestImpl(); try { pValue = cs.chiSquareTest(expected, observed); chiSq = cs.chiSquare(expected, observed); } catch (Exception e) {
pValues.addValue(cs.chiSquareTest(expected, observed)); xs.addValue(cs.chiSquare(expected, observed)); } catch (Exception e) {