Algorithm Description: Uses the Inversion - * Method to generate exponentially distributed random values from - * uniform deviates.

+ *

Algorithm Description: this implementation uses the + * + * Inversion Method to generate exponentially distributed random values + * from uniform deviates.

* * @return a random value. * @since 2.2 @@ -142,25 +145,13 @@ public class ExponentialDistributionImpl return randomData.nextExponential(mean); } - /** - * Access the domain value lower bound, based on {@code p}, used to - * bracket a CDF root. - * - * @param p Desired probability for the critical value. - * @return the domain value lower bound, i.e. {@code P(X < 'lower bound') < p}. - */ + /** {@inheritDoc} */ @Override protected double getDomainLowerBound(double p) { return 0; } - /** - * Access the domain value upper bound, based on {@code p}, used to - * bracket a CDF root. - * - * @param p Desired probability for the critical value. - * @return the domain value upper bound, i.e. {@code P(X < 'upper bound') > p}. - */ + /** {@inheritDoc} */ @Override protected double getDomainUpperBound(double p) { // NOTE: exponential is skewed to the left @@ -175,17 +166,12 @@ public class ExponentialDistributionImpl } } - /** - * Access the initial domain value, based on {@code p}, used to - * bracket a CDF root. - * - * @param p Desired probability for the critical value. - * @return the initial domain value. - */ + /** {@inheritDoc} */ @Override protected double getInitialDomain(double p) { // TODO: try to improve on this estimate - // TODO: what should really happen here is not derive from AbstractContinuousDistribution + // TODO: what should really happen here is not derive from + // AbstractContinuousDistribution // TODO: because the inverse cumulative distribution is simple. // Exponential is skewed to the left, therefore, P(X < μ) > .5 if (p < 0.5) { @@ -197,13 +183,7 @@ public class ExponentialDistributionImpl } } - /** - * Return the absolute accuracy setting of the solver used to estimate - * inverse cumulative probabilities. - * - * @return the solver absolute accuracy. - * @since 2.1 - */ + /** {@inheritDoc} */ @Override protected double getSolverAbsoluteAccuracy() { return solverAbsoluteAccuracy; @@ -237,10 +217,7 @@ public class ExponentialDistributionImpl /** * {@inheritDoc} * - * For mean parameter k, the mean is - * k - * - * @return {@inheritDoc} + * For mean parameter {@code k}, the mean is {@code k}. */ @Override protected double calculateNumericalMean() { @@ -250,10 +227,7 @@ public class ExponentialDistributionImpl /** * {@inheritDoc} * - * For mean parameter k, the variance is - * k^2 - * - * @return {@inheritDoc} + * For mean parameter {@code k}, the variance is {@code k^2}. */ @Override protected double calculateNumericalVariance() { @@ -261,17 +235,13 @@ public class ExponentialDistributionImpl return m * m; } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ @Override public boolean isSupportLowerBoundInclusive() { return true; } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ @Override public boolean isSupportUpperBoundInclusive() { return false; Copied: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/FDistribution.java (from r1206052, commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/FDistributionImpl.java) URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/FDistribution.java?p2=commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/FDistribution.java&p1=commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/FDistributionImpl.java&r1=1206052&r2=1206399&rev=1206399&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/FDistributionImpl.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/FDistribution.java Sat Nov 26 06:17:49 2011 @@ -26,14 +26,15 @@ import org.apache.commons.math.special.B import org.apache.commons.math.util.FastMath; /** - * Default implementation of - * {@link org.apache.commons.math.distribution.FDistribution}. + * Implementation of the F-distribution. * + * @see F-distribution (Wikipedia) + * @see F-distribution (MathWorld) * @version \$Id\$ */ -public class FDistributionImpl +public class FDistribution extends AbstractContinuousDistribution - implements FDistribution, Serializable { + implements Serializable { /** * Default inverse cumulative probability accuracy. * @since 2.1 @@ -52,11 +53,13 @@ public class FDistributionImpl * Create a F distribution using the given degrees of freedom. * @param numeratorDegreesOfFreedom Numerator degrees of freedom. * @param denominatorDegreesOfFreedom Denominator degrees of freedom. - * @throws NotStrictlyPositiveException if {@code numeratorDegreesOfFreedom <= 0} - * or {@code denominatorDegreesOfFreedom <= 0}. - */ - public FDistributionImpl(double numeratorDegreesOfFreedom, - double denominatorDegreesOfFreedom) { + * @throws NotStrictlyPositiveException if + * {@code numeratorDegreesOfFreedom <= 0} or + * {@code denominatorDegreesOfFreedom <= 0}. + */ + public FDistribution(double numeratorDegreesOfFreedom, + double denominatorDegreesOfFreedom) + throws NotStrictlyPositiveException { this(numeratorDegreesOfFreedom, denominatorDegreesOfFreedom, DEFAULT_INVERSE_ABSOLUTE_ACCURACY); } @@ -69,13 +72,15 @@ public class FDistributionImpl * @param inverseCumAccuracy the maximum absolute error in inverse * cumulative probability estimates. * (defaults to {@link #DEFAULT_INVERSE_ABSOLUTE_ACCURACY}) - * @throws NotStrictlyPositiveException if {@code numeratorDegreesOfFreedom <= 0} - * or {@code denominatorDegreesOfFreedom <= 0}. + * @throws NotStrictlyPositiveException if + * {@code numeratorDegreesOfFreedom <= 0} or + * {@code denominatorDegreesOfFreedom <= 0}. * @since 2.1 */ - public FDistributionImpl(double numeratorDegreesOfFreedom, + public FDistribution(double numeratorDegreesOfFreedom, double denominatorDegreesOfFreedom, - double inverseCumAccuracy) { + double inverseCumAccuracy) + throws NotStrictlyPositiveException { if (numeratorDegreesOfFreedom <= 0) { throw new NotStrictlyPositiveException(LocalizedFormats.DEGREES_OF_FREEDOM, numeratorDegreesOfFreedom); @@ -136,8 +141,8 @@ public class FDistributionImpl /** * {@inheritDoc} * - * It will return {@code 0} when {@code p = 0} and - * {@code Double.POSITIVE_INFINITY} when {@code p = 1}. + * Returns {@code 0} when {@code p == 0} and + * {@code Double.POSITIVE_INFINITY} when {@code p == 1}. */ @Override public double inverseCumulativeProbability(final double p) throws OutOfRangeException { @@ -150,40 +155,19 @@ public class FDistributionImpl return super.inverseCumulativeProbability(p); } - /** - * Access the domain value lower bound, based on {@code p}, used to - * bracket a CDF root. This method is used by - * {@link #inverseCumulativeProbability(double)} to find critical values. - * - * @param p Desired probability for the critical value. - * @return the domain value lower bound, i.e. {@code P(X < 'lower bound') < p}. - */ + /** {@inheritDoc} */ @Override protected double getDomainLowerBound(double p) { return 0; } - /** - * Access the domain value upper bound, based on {@code p}, used to - * bracket a CDF root. This method is used by - * {@link #inverseCumulativeProbability(double)} to find critical values. - * - * @param p Desired probability for the critical value. - * @return the domain value upper bound, i.e. {@code P(X < 'upper bound') > p}. - */ + /** {@inheritDoc} */ @Override protected double getDomainUpperBound(double p) { return Double.MAX_VALUE; } - /** - * Access the initial domain value, based on {@code p}, used to - * bracket a CDF root. This method is used by - * {@link #inverseCumulativeProbability(double)} to find critical values. - * - * @param p Desired probability for the critical value. - * @return the initial domain value. - */ + /** {@inheritDoc} */ @Override protected double getInitialDomain(double p) { double ret = 1; @@ -196,26 +180,24 @@ public class FDistributionImpl } /** - * {@inheritDoc} + * Access the numerator degrees of freedom. + * + * @return the numerator degrees of freedom. */ public double getNumeratorDegreesOfFreedom() { return numeratorDegreesOfFreedom; } /** - * {@inheritDoc} + * Access the denominator degrees of freedom. + * + * @return the denominator degrees of freedom. */ public double getDenominatorDegreesOfFreedom() { return denominatorDegreesOfFreedom; } - /** - * Return the absolute accuracy setting of the solver used to estimate - * inverse cumulative probabilities. - * - * @return the solver absolute accuracy - * @since 2.1 - */ + /** {@inheritDoc} */ @Override protected double getSolverAbsoluteAccuracy() { return solverAbsoluteAccuracy; @@ -249,14 +231,11 @@ public class FDistributionImpl /** * {@inheritDoc} * - * For denominator degrees of freedom parameter b, - * the mean is + * For denominator degrees of freedom parameter {@code b}, the mean is *
- *
• if b > 2 then b / (b - 2)
• - *
• else undefined + *
• if {@code b > 2} then {@code b / (b - 2)},
• + *
• else undefined ({@code Double.NaN}). *
- * - * @return {@inheritDoc} */ @Override protected double calculateNumericalMean() { @@ -272,18 +251,15 @@ public class FDistributionImpl /** * {@inheritDoc} * - * For numerator degrees of freedom parameter a - * and denominator degrees of freedom parameter b, - * the variance is + * For numerator degrees of freedom parameter {@code a} and denominator + * degrees of freedom parameter {@code b}, the variance is *
*
• - * if b > 4 then - * [ 2 * b^2 * (a + b - 2) ] / [ a * (b - 2)^2 * (b - 4) ] + * if {@code b > 4} then + * {@code [2 * b^2 * (a + b - 2)] / [a * (b - 2)^2 * (b - 4)]}, *
• - *
• else undefined + *
• else undefined ({@code Double.NaN}). *