/** Check sample data. * @param stat statistical summary * @exception IllegalArgumentException if there is not enough sample data */ private void checkSampleData(final StatisticalSummary stat) throws IllegalArgumentException { if ((stat == null) || (stat.getN() < 2)) { throw MathRuntimeException.createIllegalArgumentException( INSUFFICIENT_DATA_MESSAGE, (stat == null) ? 0 : stat.getN()); } }
/** Check sample data. * @param stat statistical summary * @exception IllegalArgumentException if there is not enough sample data */ private void checkSampleData(final StatisticalSummary stat) throws IllegalArgumentException { if ((stat == null) || (stat.getN() < 2)) { throw MathRuntimeException.createIllegalArgumentException( LocalizedFormats.INSUFFICIENT_DATA_FOR_T_STATISTIC, (stat == null) ? 0 : stat.getN()); } }
/** * Computes a <a href="http://www.itl.nist.gov/div898/handbook/prc/section2/prc22.htm#formula"> * t statistic </a> to use in comparing the mean of the dataset described by * <code>sampleStats</code> to <code>mu</code>. * <p> * This statistic can be used to perform a one sample t-test for the mean. * </p><p> * <strong>Preconditions</strong>: <ul> * <li><code>observed.getN() > = 2</code>. * </li></ul></p> * * @param mu comparison constant * @param sampleStats DescriptiveStatistics holding sample summary statitstics * @return t statistic * @throws IllegalArgumentException if the precondition is not met */ public double t(double mu, StatisticalSummary sampleStats) throws IllegalArgumentException { if ((sampleStats == null) || (sampleStats.getN() < 2)) { throw new IllegalArgumentException("insufficient data for t statistic"); } return t(sampleStats.getMean(), mu, sampleStats.getVariance(), sampleStats.getN()); }
throws IllegalArgumentException, MathException { if ((sampleStats1 == null) || (sampleStats2 == null || Math.min(sampleStats1.getN(), sampleStats2.getN()) < 2)) { throw new IllegalArgumentException("insufficient data for t statistic"); sampleStats2.getVariance(), (double) sampleStats1.getN(), (double) sampleStats2.getN());
throws IllegalArgumentException, MathException { if ((sampleStats1 == null) || (sampleStats2 == null || Math.min(sampleStats1.getN(), sampleStats2.getN()) < 2)) { throw new IllegalArgumentException("insufficient data for t statistic"); sampleStats2.getVariance(), (double) sampleStats1.getN(), (double) sampleStats2.getN());
/** * Computes a <a href="http://www.itl.nist.gov/div898/handbook/prc/section2/prc22.htm#formula"> * t statistic </a> to use in comparing the mean of the dataset described by * <code>sampleStats</code> to <code>mu</code>. * <p> * This statistic can be used to perform a one sample t-test for the mean. * </p><p> * <strong>Preconditions</strong>: <ul> * <li><code>observed.getN() > = 2</code>. * </li></ul></p> * * @param mu comparison constant * @param sampleStats DescriptiveStatistics holding sample summary statitstics * @return t statistic * @throws IllegalArgumentException if the precondition is not met */ public double t(double mu, StatisticalSummary sampleStats) throws IllegalArgumentException { checkSampleData(sampleStats); return t(sampleStats.getMean(), mu, sampleStats.getVariance(), sampleStats.getN()); }
/** * Computes a <a href="http://www.itl.nist.gov/div898/handbook/prc/section2/prc22.htm#formula"> * t statistic </a> to use in comparing the mean of the dataset described by * <code>sampleStats</code> to <code>mu</code>. * <p> * This statistic can be used to perform a one sample t-test for the mean. * </p><p> * <strong>Preconditions</strong>: <ul> * <li><code>observed.getN() > = 2</code>. * </li></ul></p> * * @param mu comparison constant * @param sampleStats DescriptiveStatistics holding sample summary statitstics * @return t statistic * @throws IllegalArgumentException if the precondition is not met */ public double t(double mu, StatisticalSummary sampleStats) throws IllegalArgumentException { checkSampleData(sampleStats); return t(sampleStats.getMean(), mu, sampleStats.getVariance(), sampleStats.getN()); }
checkSampleData(sampleStats); return tTest(sampleStats.getMean(), mu, sampleStats.getVariance(), sampleStats.getN());
checkSampleData(sampleStats); return tTest(sampleStats.getMean(), mu, sampleStats.getVariance(), sampleStats.getN());