📄 ttest.java
字号:
* </li></ul></p> * * @param sample1 array of sample data values * @param sample2 array of sample data values * @return p-value for t-test * @throws IllegalArgumentException if the precondition is not met * @throws MathException if an error occurs computing the p-value */ public abstract double homoscedasticTTest( double[] sample1, double[] sample2) throws IllegalArgumentException, MathException; /** * Performs a * <a href="http://www.itl.nist.gov/div898/handbook/eda/section3/eda353.htm"> * two-sided t-test</a> evaluating the null hypothesis that <code>sample1</code> * and <code>sample2</code> are drawn from populations with the same mean, * with significance level <code>alpha</code>. This test does not assume * that the subpopulation variances are equal. To perform the test assuming * equal variances, use * {@link #homoscedasticTTest(double[], double[], double)}. * <p> * Returns <code>true</code> iff the null hypothesis that the means are * equal can be rejected with confidence <code>1 - alpha</code>. To * perform a 1-sided test, use <code>alpha * 2</code></p> * <p> * See {@link #t(double[], double[])} for the formula used to compute the * t-statistic. Degrees of freedom are approximated using the * <a href="http://www.itl.nist.gov/div898/handbook/prc/section3/prc31.htm"> * Welch-Satterthwaite approximation.</a></p> * <p> * <strong>Examples:</strong><br><ol> * <li>To test the (2-sided) hypothesis <code>mean 1 = mean 2 </code> at * the 95% level, use * <br><code>tTest(sample1, sample2, 0.05). </code> * </li> * <li>To test the (one-sided) hypothesis <code> mean 1 < mean 2 </code>, * at the 99% level, first verify that the measured mean of <code>sample 1</code> * is less than the mean of <code>sample 2</code> and then use * <br><code>tTest(sample1, sample2, 0.02) </code> * </li></ol></p> * <p> * <strong>Usage Note:</strong><br> * The validity of the test depends on the assumptions of the parametric * t-test procedure, as discussed * <a href="http://www.basic.nwu.edu/statguidefiles/ttest_unpaired_ass_viol.html"> * here</a></p> * <p> * <strong>Preconditions</strong>: <ul> * <li>The observed array lengths must both be at least 2. * </li> * <li> <code> 0 < alpha < 0.5 </code> * </li></ul></p> * * @param sample1 array of sample data values * @param sample2 array of sample data values * @param alpha significance level of the test * @return true if the null hypothesis can be rejected with * confidence 1 - alpha * @throws IllegalArgumentException if the preconditions are not met * @throws MathException if an error occurs performing the test */ public abstract boolean tTest( double[] sample1, double[] sample2, double alpha) throws IllegalArgumentException, MathException; /** * Performs a * <a href="http://www.itl.nist.gov/div898/handbook/eda/section3/eda353.htm"> * two-sided t-test</a> evaluating the null hypothesis that <code>sample1</code> * and <code>sample2</code> are drawn from populations with the same mean, * with significance level <code>alpha</code>, assuming that the * subpopulation variances are equal. Use * {@link #tTest(double[], double[], double)} to perform the test without * the assumption of equal variances. * <p> * Returns <code>true</code> iff the null hypothesis that the means are * equal can be rejected with confidence <code>1 - alpha</code>. To * perform a 1-sided test, use <code>alpha * 2.</code> To perform the test * without the assumption of equal subpopulation variances, use * {@link #tTest(double[], double[], double)}.</p> * <p> * A pooled variance estimate is used to compute the t-statistic. See * {@link #t(double[], double[])} for the formula. The sum of the sample * sizes minus 2 is used as the degrees of freedom.</p> * <p> * <strong>Examples:</strong><br><ol> * <li>To test the (2-sided) hypothesis <code>mean 1 = mean 2 </code> at * the 95% level, use <br><code>tTest(sample1, sample2, 0.05). </code> * </li> * <li>To test the (one-sided) hypothesis <code> mean 1 < mean 2, </code> * at the 99% level, first verify that the measured mean of * <code>sample 1</code> is less than the mean of <code>sample 2</code> * and then use * <br><code>tTest(sample1, sample2, 0.02) </code> * </li></ol></p> * <p> * <strong>Usage Note:</strong><br> * The validity of the test depends on the assumptions of the parametric * t-test procedure, as discussed * <a href="http://www.basic.nwu.edu/statguidefiles/ttest_unpaired_ass_viol.html"> * here</a></p> * <p> * <strong>Preconditions</strong>: <ul> * <li>The observed array lengths must both be at least 2. * </li> * <li> <code> 0 < alpha < 0.5 </code> * </li></ul></p> * * @param sample1 array of sample data values * @param sample2 array of sample data values * @param alpha significance level of the test * @return true if the null hypothesis can be rejected with * confidence 1 - alpha * @throws IllegalArgumentException if the preconditions are not met * @throws MathException if an error occurs performing the test */ public abstract boolean homoscedasticTTest( double[] sample1, double[] sample2, double alpha) throws IllegalArgumentException, MathException; /** * Returns the <i>observed significance level</i>, or * <i>p-value</i>, associated with a two-sample, two-tailed t-test * comparing the means of the datasets described by two StatisticalSummary * instances. * <p> * The number returned is the smallest significance level * at which one can reject the null hypothesis that the two means are * equal in favor of the two-sided alternative that they are different. * For a one-sided test, divide the returned value by 2.</p> * <p> * The test does not assume that the underlying popuation variances are * equal and it uses approximated degrees of freedom computed from the * sample data to compute the p-value. To perform the test assuming * equal variances, use * {@link #homoscedasticTTest(StatisticalSummary, StatisticalSummary)}.</p> * <p> * <strong>Usage Note:</strong><br> * The validity of the p-value depends on the assumptions of the parametric * t-test procedure, as discussed * <a href="http://www.basic.nwu.edu/statguidefiles/ttest_unpaired_ass_viol.html"> * here</a></p> * <p> * <strong>Preconditions</strong>: <ul> * <li>The datasets described by the two Univariates must each contain * at least 2 observations. * </li></ul></p> * * @param sampleStats1 StatisticalSummary describing data from the first sample * @param sampleStats2 StatisticalSummary describing data from the second sample * @return p-value for t-test * @throws IllegalArgumentException if the precondition is not met * @throws MathException if an error occurs computing the p-value */ public abstract double tTest( StatisticalSummary sampleStats1, StatisticalSummary sampleStats2) throws IllegalArgumentException, MathException; /** * Returns the <i>observed significance level</i>, or * <i>p-value</i>, associated with a two-sample, two-tailed t-test * comparing the means of the datasets described by two StatisticalSummary * instances, under the hypothesis of equal subpopulation variances. To * perform a test without the equal variances assumption, use * {@link #tTest(StatisticalSummary, StatisticalSummary)}. * <p> * The number returned is the smallest significance level * at which one can reject the null hypothesis that the two means are * equal in favor of the two-sided alternative that they are different. * For a one-sided test, divide the returned value by 2.</p> * <p> * See {@link #homoscedasticT(double[], double[])} for the formula used to * compute the t-statistic. The sum of the sample sizes minus 2 is used as * the degrees of freedom.</p> * <p> * <strong>Usage Note:</strong><br> * The validity of the p-value depends on the assumptions of the parametric * t-test procedure, as discussed * <a href="http://www.basic.nwu.edu/statguidefiles/ttest_unpaired_ass_viol.html">here</a> * </p><p> * <strong>Preconditions</strong>: <ul> * <li>The datasets described by the two Univariates must each contain * at least 2 observations. * </li></ul></p> * * @param sampleStats1 StatisticalSummary describing data from the first sample * @param sampleStats2 StatisticalSummary describing data from the second sample * @return p-value for t-test * @throws IllegalArgumentException if the precondition is not met * @throws MathException if an error occurs computing the p-value */ public abstract double homoscedasticTTest( StatisticalSummary sampleStats1, StatisticalSummary sampleStats2) throws IllegalArgumentException, MathException; /** * Performs a * <a href="http://www.itl.nist.gov/div898/handbook/eda/section3/eda353.htm"> * two-sided t-test</a> evaluating the null hypothesis that * <code>sampleStats1</code> and <code>sampleStats2</code> describe * datasets drawn from populations with the same mean, with significance * level <code>alpha</code>. This test does not assume that the * subpopulation variances are equal. To perform the test under the equal * variances assumption, use * {@link #homoscedasticTTest(StatisticalSummary, StatisticalSummary)}. * <p> * Returns <code>true</code> iff the null hypothesis that the means are * equal can be rejected with confidence <code>1 - alpha</code>. To * perform a 1-sided test, use <code>alpha * 2</code></p> * <p> * See {@link #t(double[], double[])} for the formula used to compute the * t-statistic. Degrees of freedom are approximated using the * <a href="http://www.itl.nist.gov/div898/handbook/prc/section3/prc31.htm"> * Welch-Satterthwaite approximation.</a></p> * <p> * <strong>Examples:</strong><br><ol> * <li>To test the (2-sided) hypothesis <code>mean 1 = mean 2 </code> at * the 95%, use * <br><code>tTest(sampleStats1, sampleStats2, 0.05) </code> * </li> * <li>To test the (one-sided) hypothesis <code> mean 1 < mean 2 </code> * at the 99% level, first verify that the measured mean of * <code>sample 1</code> is less than the mean of <code>sample 2</code> * and then use * <br><code>tTest(sampleStats1, sampleStats2, 0.02) </code> * </li></ol></p> * <p> * <strong>Usage Note:</strong><br> * The validity of the test depends on the assumptions of the parametric * t-test procedure, as discussed * <a href="http://www.basic.nwu.edu/statguidefiles/ttest_unpaired_ass_viol.html"> * here</a></p> * <p> * <strong>Preconditions</strong>: <ul> * <li>The datasets described by the two Univariates must each contain * at least 2 observations. * </li> * <li> <code> 0 < alpha < 0.5 </code> * </li></ul></p> * * @param sampleStats1 StatisticalSummary describing sample data values * @param sampleStats2 StatisticalSummary describing sample data values * @param alpha significance level of the test * @return true if the null hypothesis can be rejected with * confidence 1 - alpha * @throws IllegalArgumentException if the preconditions are not met * @throws MathException if an error occurs performing the test */ public abstract boolean tTest( StatisticalSummary sampleStats1, StatisticalSummary sampleStats2, double alpha) throws IllegalArgumentException, MathException;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -