Example usage for org.apache.commons.math3.exception.util LocalizedFormats SIGNIFICANCE_LEVEL

List of usage examples for org.apache.commons.math3.exception.util LocalizedFormats SIGNIFICANCE_LEVEL

Introduction

In this page you can find the example usage for org.apache.commons.math3.exception.util LocalizedFormats SIGNIFICANCE_LEVEL.

Prototype

LocalizedFormats SIGNIFICANCE_LEVEL

To view the source code for org.apache.commons.math3.exception.util LocalizedFormats SIGNIFICANCE_LEVEL.

Click Source Link

Usage

From source file:experiment.SimpleRegression_bug.java

/**
 * Returns the half-width of a (100-100*alpha)% confidence interval for
 * the slope estimate.//from ww w.  j  a v  a  2 s.  com
 * <p>
 * The (100-100*alpha)% confidence interval is </p>
 * <p>
 * <code>(getSlope() - getSlopeConfidenceInterval(),
 * getSlope() + getSlopeConfidenceInterval())</code></p>
 * <p>
 * To request, for example, a 99% confidence interval, use
 * <code>alpha = .01</code></p>
 * <p>
 * <strong>Usage Note</strong>:<br>
 * The validity of this statistic depends on the assumption that the
 * observations included in the model are drawn from a
 * <a href="http://mathworld.wolfram.com/BivariateNormalDistribution.html">
 * Bivariate Normal Distribution</a>.</p>
 * <p>
 * <strong> Preconditions:</strong><ul>
 * <li>If there are fewer that <strong>three</strong> observations in the
 * model, or if there is no variation in x, this returns
 * <code>Double.NaN</code>.
 * </li>
 * <li><code>(0 < alpha < 1)</code>; otherwise an
 * <code>OutOfRangeException</code> is thrown.
 * </li></ul></p>
 *
 * @param alpha the desired significance level
 * @return half-width of 95% confidence interval for the slope estimate
 * @throws OutOfRangeException if the confidence interval can not be computed.
 */
public double getSlopeConfidenceInterval(final double alpha) throws OutOfRangeException {
    if (n < 3) {
        return Double.NaN;
    }
    if (alpha >= 1 || alpha <= 0) {
        throw new OutOfRangeException(LocalizedFormats.SIGNIFICANCE_LEVEL, alpha, 0, 1);
    }
    // No advertised NotStrictlyPositiveException here - will return NaN above
    TDistribution distribution = new TDistribution(n - 2);
    return getSlopeStdErr() * distribution.inverseCumulativeProbability(1d - alpha / 2d);
}

From source file:embedded2.ESecure.TTest.java

/**
 * Check significance level./*from  w w  w  .  ja  va  2s  . com*/
 *
 * @param alpha significance level
 * @throws OutOfRangeException if the significance level is out of bounds.
 */
private static void checkSignificanceLevel(final double alpha) throws OutOfRangeException {

    if (alpha <= 0 || alpha > 0.5) {
        throw new OutOfRangeException(LocalizedFormats.SIGNIFICANCE_LEVEL, alpha, 0.0, 0.5);
    }

}