⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ttest.java

📁 Apache的common math数学软件包
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
     * <strong><code> m1</code></strong> is the mean of the first sample;       * <strong><code> m2</code></strong> is the mean of the second sample     * <strong><code> var1</code></strong> is the variance of the first sample;       * <strong><code> var2</code></strong> is the variance of the second sample     * </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 t statistic     * @throws IllegalArgumentException if the precondition is not met     */    public abstract double t(        StatisticalSummary sampleStats1,        StatisticalSummary sampleStats2)        throws IllegalArgumentException;    /**     * Computes a 2-sample t statistic, comparing the means of the datasets     * described by two {@link StatisticalSummary} instances, under the     * assumption of equal subpopulation variances.  To compute a t-statistic     * without the equal variances assumption, use      * {@link #t(StatisticalSummary, StatisticalSummary)}.     * <p>     * This statistic can be used to perform a (homoscedastic) two-sample     * t-test to compare sample means.</p>     * <p>     * The t-statisitc returned is</p>     * <p>     * &nbsp;&nbsp;<code>  t = (m1 - m2) / (sqrt(1/n1 +1/n2) sqrt(var))</code>     * </p><p>     * where <strong><code>n1</code></strong> is the size of first sample;      * <strong><code> n2</code></strong> is the size of second sample;      * <strong><code> m1</code></strong> is the mean of first sample;       * <strong><code> m2</code></strong> is the mean of second sample     * and <strong><code>var</code></strong> is the pooled variance estimate:     * </p><p>     * <code>var = sqrt(((n1 - 1)var1 + (n2 - 1)var2) / ((n1-1) + (n2-1)))</code>     * </p><p>      * with <strong><code>var1<code></strong> the variance of the first sample and     * <strong><code>var2</code></strong> the variance of the second sample.     * </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 t statistic     * @throws IllegalArgumentException if the precondition is not met     */    public abstract double homoscedasticT(        StatisticalSummary sampleStats1,        StatisticalSummary sampleStats2)        throws IllegalArgumentException;    /**     * Returns the <i>observed significance level</i>, or      * <i>p-value</i>, associated with a one-sample, two-tailed t-test      * comparing the mean of the input array with the constant <code>mu</code>.     * <p>     * The number returned is the smallest significance level     * at which one can reject the null hypothesis that the mean equals      * <code>mu</code> in favor of the two-sided alternative that the mean     * is different from <code>mu</code>. For a one-sided test, divide the      * returned value by 2.</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 length must be at least 2.     * </li></ul></p>     *     * @param mu constant value to compare sample mean against     * @param sample array of sample data values     * @return p-value     * @throws IllegalArgumentException if the precondition is not met     * @throws MathException if an error occurs computing the p-value     */    public abstract double tTest(double mu, double[] sample)        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 the mean of the population from     * which <code>sample</code> is drawn equals <code>mu</code>.     * <p>     * Returns <code>true</code> iff the null hypothesis can be      * rejected with confidence <code>1 - alpha</code>.  To      * perform a 1-sided test, use <code>alpha * 2</code></p>     * <p>     * <strong>Examples:</strong><br><ol>     * <li>To test the (2-sided) hypothesis <code>sample mean = mu </code> at     * the 95% level, use <br><code>tTest(mu, sample, 0.05) </code>     * </li>     * <li>To test the (one-sided) hypothesis <code> sample mean < mu </code>     * at the 99% level, first verify that the measured sample mean is less      * than <code>mu</code> and then use      * <br><code>tTest(mu, sample, 0.02) </code>     * </li></ol></p>     * <p>     * <strong>Usage Note:</strong><br>     * The validity of the test depends on the assumptions of the one-sample      * parametric t-test procedure, as discussed      * <a href="http://www.basic.nwu.edu/statguidefiles/sg_glos.html#one-sample">here</a>     * </p><p>     * <strong>Preconditions</strong>: <ul>     * <li>The observed array length must be at least 2.     * </li></ul></p>     *     * @param mu constant value to compare sample mean against     * @param sample array of sample data values     * @param alpha significance level of the test     * @return p-value     * @throws IllegalArgumentException if the precondition is not met     * @throws MathException if an error computing the p-value     */    public abstract boolean tTest(double mu, double[] sample, double alpha)        throws IllegalArgumentException, MathException;    /**     * Returns the <i>observed significance level</i>, or      * <i>p-value</i>, associated with a one-sample, two-tailed t-test      * comparing the mean of the dataset described by <code>sampleStats</code>     * with the constant <code>mu</code>.     * <p>     * The number returned is the smallest significance level     * at which one can reject the null hypothesis that the mean equals      * <code>mu</code> in favor of the two-sided alternative that the mean     * is different from <code>mu</code>. For a one-sided test, divide the      * returned value by 2.</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 sample must contain at least 2 observations.     * </li></ul></p>     *     * @param mu constant value to compare sample mean against     * @param sampleStats StatisticalSummary describing sample data     * @return p-value     * @throws IllegalArgumentException if the precondition is not met     * @throws MathException if an error occurs computing the p-value     */    public abstract double tTest(double mu, StatisticalSummary sampleStats)        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 the mean of the     * population from which the dataset described by <code>stats</code> is     * drawn equals <code>mu</code>.     * <p>     * Returns <code>true</code> iff the null hypothesis can be rejected with     * confidence <code>1 - alpha</code>.  To  perform a 1-sided test, use     * <code>alpha * 2.</code></p>     * <p>     * <strong>Examples:</strong><br><ol>     * <li>To test the (2-sided) hypothesis <code>sample mean = mu </code> at     * the 95% level, use <br><code>tTest(mu, sampleStats, 0.05) </code>     * </li>     * <li>To test the (one-sided) hypothesis <code> sample mean < mu </code>     * at the 99% level, first verify that the measured sample mean is less      * than <code>mu</code> and then use      * <br><code>tTest(mu, sampleStats, 0.02) </code>     * </li></ol></p>     * <p>     * <strong>Usage Note:</strong><br>     * The validity of the test depends on the assumptions of the one-sample      * parametric t-test procedure, as discussed      * <a href="http://www.basic.nwu.edu/statguidefiles/sg_glos.html#one-sample">here</a>     * </p><p>     * <strong>Preconditions</strong>: <ul>     * <li>The sample must include at least 2 observations.     * </li></ul></p>     *     * @param mu constant value to compare sample mean against     * @param sampleStats StatisticalSummary describing sample data values     * @param alpha significance level of the test     * @return p-value     * @throws IllegalArgumentException if the precondition is not met     * @throws MathException if an error occurs computing the p-value     */    public abstract boolean tTest(        double mu,        StatisticalSummary sampleStats,        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 input arrays.     * <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.  The t-statistic used is as defined in     * {@link #t(double[], double[])} and the Welch-Satterthwaite approximation     * to the degrees of freedom is used,      * as described      * <a href="http://www.itl.nist.gov/div898/handbook/prc/section3/prc31.htm">     * here.</a>  To perform the test under the assumption of equal subpopulation     * variances, use {@link #homoscedasticTTest(double[], double[])}.</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 observed array lengths must both be at least 2.     * </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 tTest(double[] sample1, double[] sample2)        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 input arrays, under the assumption that     * the two samples are drawn from subpopulations with equal variances.     * To perform the test without the equal variances assumption, use     * {@link #tTest(double[], double[])}.</p>     * <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>     * A pooled variance estimate is used to compute the t-statistic.  See     * {@link #homoscedasticT(double[], double[])}. 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 observed array lengths must both be at least 2.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -