diff --git a/src/main/java/org/apache/commons/math/distribution/AbstractContinuousDistribution.java b/src/main/java/org/apache/commons/math/distribution/AbstractContinuousDistribution.java
index 10a6bb574..b38469d1e 100644
--- a/src/main/java/org/apache/commons/math/distribution/AbstractContinuousDistribution.java
+++ b/src/main/java/org/apache/commons/math/distribution/AbstractContinuousDistribution.java
@@ -60,18 +60,21 @@ public abstract class AbstractContinuousDistribution
/**
* {@inheritDoc}
+ *
+ * For continuous distributions {@code P(X = x)} always evaluates to 0.
+ *
+ * @return 0
*/
- public abstract double density(double x);
+ @Override
+ public final double probability(double x) {
+ return 0.0;
+ }
/**
- * For this distribution, {@code X}, this method returns the critical
- * point {@code x}, such that {@code P(X < x) = p}.
- *
- * @param p Desired probability.
- * @return {@code x}, such that {@code P(X < x) = p}.
- * @throws OutOfRangeException if {@code p} is not a valid probability.
+ * {@inheritDoc}
*/
- public double inverseCumulativeProbability(final double p) {
+ @Override
+ public double inverseCumulativeProbability(final double p) throws OutOfRangeException {
if (p < 0.0 || p > 1.0) {
throw new OutOfRangeException(p, 0, 1);
@@ -81,6 +84,7 @@ public abstract class AbstractContinuousDistribution
// subclasses can override if there is a better method.
UnivariateRealFunction rootFindingFunction =
new UnivariateRealFunction() {
+ @Override
public double value(double x) {
return cumulativeProbability(x) - p;
}
@@ -124,6 +128,7 @@ public abstract class AbstractContinuousDistribution
* @param seed New seed.
* @since 2.2
*/
+ @Override
public void reseedRandomGenerator(long seed) {
randomData.reSeed(seed);
}
@@ -138,6 +143,7 @@ public abstract class AbstractContinuousDistribution
* @return a random value.
* @since 2.2
*/
+ @Override
public double sample() {
return randomData.nextInversionDeviate(this);
}
@@ -151,6 +157,7 @@ public abstract class AbstractContinuousDistribution
* @throws NotStrictlyPositiveException if {@code sampleSize} is not positive.
* @since 2.2
*/
+ @Override
public double[] sample(int sampleSize) {
if (sampleSize <= 0) {
throw new NotStrictlyPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES,
diff --git a/src/main/java/org/apache/commons/math/distribution/AbstractDistribution.java b/src/main/java/org/apache/commons/math/distribution/AbstractDistribution.java
index 53c18a08b..e12c69f9f 100644
--- a/src/main/java/org/apache/commons/math/distribution/AbstractDistribution.java
+++ b/src/main/java/org/apache/commons/math/distribution/AbstractDistribution.java
@@ -52,21 +52,13 @@ public abstract class AbstractDistribution
}
/**
- * For a random variable X whose values are distributed according
- * to this distribution, this method returns P(x0 ≤ X ≤ x1).
- *
- * The default implementation uses the identity
- *
- * P(x0 ≤ X ≤ x1) = P(X ≤ x1) - P(X ≤ x0)
+ * {@inheritDoc}
*
- * @param x0 the (inclusive) lower bound
- * @param x1 the (inclusive) upper bound
- * @return the probability that a random variable with this distribution
- * will take a value between {@code x0} and {@code x1},
- * including the endpoints.
- * @throws NumberIsTooLargeException if {@code x0 > x1}
+ * The default implementation uses the identity
+ * {@code P(x0 < X <= x1) = P(X <= x1) - P(X <= x0)}
*/
- public double cumulativeProbability(double x0, double x1) {
+ @Override
+ public double cumulativeProbability(double x0, double x1) throws NumberIsTooLargeException {
if (x0 > x1) {
throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT,
x0, x1, true);
@@ -89,6 +81,7 @@ public abstract class AbstractDistribution
*
* @return the mean or Double.NaN if it's not defined
*/
+ @Override
public double getNumericalMean() {
if (!numericalMeanIsCalculated) {
numericalMean = calculateNumericalMean();
@@ -115,6 +108,7 @@ public abstract class AbstractDistribution
* for certain cases in {@link TDistributionImpl}) or
* Double.NaN if it's not defined
*/
+ @Override
public double getNumericalVariance() {
if (!numericalVarianceIsCalculated) {
numericalVariance = calculateNumericalVariance();
@@ -130,6 +124,7 @@ public abstract class AbstractDistribution
*
* @return whether the lower bound of the support is inclusive or not
*/
+ @Override
public abstract boolean isSupportLowerBoundInclusive();
/**
@@ -138,6 +133,7 @@ public abstract class AbstractDistribution
*
* @return whether the upper bound of the support is inclusive or not
*/
+ @Override
public abstract boolean isSupportUpperBoundInclusive();
/**
@@ -159,6 +155,7 @@ public abstract class AbstractDistribution
*
* @return whether the support limits given by subclassed methods are connected or not
*/
+ @Override
public boolean isSupportConnected() {
return true;
}
diff --git a/src/main/java/org/apache/commons/math/distribution/BetaDistributionImpl.java b/src/main/java/org/apache/commons/math/distribution/BetaDistributionImpl.java
index 97b838093..e7af78506 100644
--- a/src/main/java/org/apache/commons/math/distribution/BetaDistributionImpl.java
+++ b/src/main/java/org/apache/commons/math/distribution/BetaDistributionImpl.java
@@ -166,12 +166,6 @@ public class BetaDistributionImpl
}
}
- /** {@inheritDoc} */
- @Override
- public double cumulativeProbability(double x0, double x1) {
- return cumulativeProbability(x1) - cumulativeProbability(x0);
- }
-
/**
* Return the absolute accuracy setting of the solver used to estimate
* inverse cumulative probabilities.
diff --git a/src/main/java/org/apache/commons/math/distribution/CauchyDistributionImpl.java b/src/main/java/org/apache/commons/math/distribution/CauchyDistributionImpl.java
index 05abf9ee8..00fbaf8cd 100644
--- a/src/main/java/org/apache/commons/math/distribution/CauchyDistributionImpl.java
+++ b/src/main/java/org/apache/commons/math/distribution/CauchyDistributionImpl.java
@@ -87,11 +87,9 @@ public class CauchyDistributionImpl extends AbstractContinuousDistribution
}
/**
- * For this distribution, {@code X}, this method returns {@code P(X < x)}.
- *
- * @param x Value at which the CDF is evaluated.
- * @return CDF evaluated at {@code x}.
+ * {@inheritDoc}
*/
+ @Override
public double cumulativeProbability(double x) {
return 0.5 + (FastMath.atan((x - median) / scale) / FastMath.PI);
}
@@ -99,6 +97,7 @@ public class CauchyDistributionImpl extends AbstractContinuousDistribution
/**
* {@inheritDoc}
*/
+ @Override
public double getMedian() {
return median;
}
@@ -106,6 +105,7 @@ public class CauchyDistributionImpl extends AbstractContinuousDistribution
/**
* {@inheritDoc}
*/
+ @Override
public double getScale() {
return scale;
}
@@ -120,17 +120,13 @@ public class CauchyDistributionImpl extends AbstractContinuousDistribution
}
/**
- * For this distribution, {@code X}, this method returns the critical
- * point {@code x}, such that {@code P(X < x) = p}.
- * It will return {@code Double.NEGATIVE_INFINITY} when p = 0 and
- * {@code Double.POSITIVE_INFINITY} when p = 1.
+ * {@inheritDoc}
*
- * @param p Desired probability.
- * @return {@code x}, such that {@code P(X < x) = p}.
- * @throws OutOfRangeException if {@code p} is not a valid probability.
+ * It will return {@code Double.NEGATIVE_INFINITY} when {@code p = 0}
+ * and {@code Double.POSITIVE_INFINITY} when {@code p = 1}.
*/
@Override
- public double inverseCumulativeProbability(double p) {
+ public double inverseCumulativeProbability(double p) throws OutOfRangeException {
double ret;
if (p < 0 || p > 1) {
throw new OutOfRangeException(p, 0, 1);
diff --git a/src/main/java/org/apache/commons/math/distribution/ChiSquaredDistributionImpl.java b/src/main/java/org/apache/commons/math/distribution/ChiSquaredDistributionImpl.java
index 2c6e30cc0..b11b3cad9 100644
--- a/src/main/java/org/apache/commons/math/distribution/ChiSquaredDistributionImpl.java
+++ b/src/main/java/org/apache/commons/math/distribution/ChiSquaredDistributionImpl.java
@@ -67,6 +67,7 @@ public class ChiSquaredDistributionImpl
/**
* {@inheritDoc}
*/
+ @Override
public double getDegreesOfFreedom() {
return gamma.getAlpha() * 2.0;
}
@@ -80,25 +81,18 @@ public class ChiSquaredDistributionImpl
}
/**
- * For this distribution, {@code X}, this method returns {@code P(X < x)}.
- *
- * @param x the value at which the CDF is evaluated.
- * @return CDF for this distribution.
+ * {@inheritDoc}
*/
+ @Override
public double cumulativeProbability(double x) {
return gamma.cumulativeProbability(x);
}
/**
- * For this distribution, X, this method returns the critical point
- * {@code x}, such that {@code P(X < x) = p}.
- * It will return 0 when p = 0 and {@code Double.POSITIVE_INFINITY}
- * when p = 1.
+ * {@inheritDoc}
*
- * @param p Desired probability.
- * @return {@code x}, such that {@code P(X < x) = p}.
- * @throws org.apache.commons.math.exception.OutOfRangeException if
- * {@code p} is not a valid probability.
+ * It will return {@code 0} when {@code p = 0} and
+ * {@code Double.POSITIVE_INFINITY} when {@code p = 1}.
*/
@Override
public double inverseCumulativeProbability(final double p) {
diff --git a/src/main/java/org/apache/commons/math/distribution/ContinuousDistribution.java b/src/main/java/org/apache/commons/math/distribution/ContinuousDistribution.java
index 03d61100b..6f02cc2f0 100644
--- a/src/main/java/org/apache/commons/math/distribution/ContinuousDistribution.java
+++ b/src/main/java/org/apache/commons/math/distribution/ContinuousDistribution.java
@@ -16,6 +16,8 @@
*/
package org.apache.commons.math.distribution;
+import org.apache.commons.math.exception.OutOfRangeException;
+
/**
* Base interface for continuous distributions.
*
@@ -23,19 +25,27 @@ package org.apache.commons.math.distribution;
*/
public interface ContinuousDistribution extends Distribution {
/**
- * For a distribution, {@code X}, compute {@code x} such that
- * {@code P(X < x) = p}.
+ * Computes the quantile function of this distribution. For a random
+ * variable {@code X} distributed according to this distribution, the
+ * returned value is
+ *
+ * inf{x in R | P(X<=x) >= p}
for {@code 0 < p <= 1},
+ * inf{x in R | P(X<=x) > 0}
for {@code p = 0}.
+ *
*
- * @param p Cumulative probability.
- * @return {@code x} such that {@code P(X < x) = p}.
+ * @param p the cumulative probability
+ * @return the smallest {@code p}-quantile of this distribution
+ * (largest 0-quantile for {@code p = 0})
+ * @throws OutOfRangeException if {@code p < 0} or {@code p > 1}
*/
- double inverseCumulativeProbability(double p);
+ double inverseCumulativeProbability(double p) throws OutOfRangeException;
/**
- * Probability density for a particular point.
+ * Returns the probability density function (PDF) of this distribution
+ * evaluated at the specified point.
*
- * @param x Point at which the density should be computed.
- * @return the pdf at point {@code x}.
+ * @param x the point at which the PDF should be evaluated
+ * @return the PDF at point {@code x}
*/
double density(double x);
diff --git a/src/main/java/org/apache/commons/math/distribution/Distribution.java b/src/main/java/org/apache/commons/math/distribution/Distribution.java
index 1bc6ef9ea..7c2835b6b 100644
--- a/src/main/java/org/apache/commons/math/distribution/Distribution.java
+++ b/src/main/java/org/apache/commons/math/distribution/Distribution.java
@@ -16,6 +16,8 @@
*/
package org.apache.commons.math.distribution;
+import org.apache.commons.math.exception.NumberIsTooLargeException;
+
/**
* Base interface for probability distributions.
*
@@ -23,29 +25,40 @@ package org.apache.commons.math.distribution;
*/
public interface Distribution {
/**
- * For a random variable X whose values are distributed according
- * to this distribution, this method returns P(X ≤ x). In other words,
- * this method represents the (cumulative) distribution function, or
- * CDF, for this distribution.
+ * For a random variable {@code X} whose values are distributed according
+ * to this distribution, this method returns {@code P(X = x)}. In other
+ * words, this method represents the probability mass function (PMF)
+ * for the distribution.
*
- * @param x the value at which the distribution function is evaluated.
+ * @param x the value at which the PMF is evaluated
+ * @return the value of the probability mass function at {@code x}
+ */
+ double probability(double x);
+
+ /**
+ * For a random variable {@code X} whose values are distributed according
+ * to this distribution, this method returns {@code P(X <= x)}. In other
+ * words, this method represents the (cumulative) distribution function
+ * (CDF) for this distribution.
+ *
+ * @param x the value at which the CDF is evaluated
* @return the probability that a random variable with this
- * distribution takes a value less than or equal to x
+ * distribution takes a value less than or equal to {@code x}
*/
double cumulativeProbability(double x);
/**
- * For a random variable X whose values are distributed according
- * to this distribution, this method returns P(x0 ≤ X ≤ x1).
+ * For a random variable {@code X} whose values are distributed according
+ * to this distribution, this method returns {@code P(x0 < X <= x1)}.
*
- * @param x0 the (inclusive) lower bound
- * @param x1 the (inclusive) upper bound
+ * @param x0 the exclusive lower bound
+ * @param x1 the inclusive upper bound
* @return the probability that a random variable with this distribution
- * will take a value between x0
and x1
,
- * including the endpoints
- * @throws IllegalArgumentException if x0 > x1
+ * takes a value between {@code x0} and {@code x1},
+ * excluding the lower and including the upper endpoint
+ * @throws NumberIsTooLargeException if {@code x0 > x1}
*/
- double cumulativeProbability(double x0, double x1);
+ double cumulativeProbability(double x0, double x1) throws NumberIsTooLargeException;
/**
* Use this method to get the numerical value of the mean of this
diff --git a/src/main/java/org/apache/commons/math/distribution/ExponentialDistributionImpl.java b/src/main/java/org/apache/commons/math/distribution/ExponentialDistributionImpl.java
index fda4792f1..0b792a07c 100644
--- a/src/main/java/org/apache/commons/math/distribution/ExponentialDistributionImpl.java
+++ b/src/main/java/org/apache/commons/math/distribution/ExponentialDistributionImpl.java
@@ -71,6 +71,7 @@ public class ExponentialDistributionImpl extends AbstractContinuousDistribution
/**
* {@inheritDoc}
*/
+ @Override
public double getMean() {
return mean;
}
@@ -87,7 +88,7 @@ public class ExponentialDistributionImpl extends AbstractContinuousDistribution
}
/**
- * For this distribution, X, this method returns P(X < x).
+ * {@inheritDoc}
*
* The implementation of this method is based on:
*
@@ -95,10 +96,8 @@ public class ExponentialDistributionImpl extends AbstractContinuousDistribution
*
* Exponential Distribution, equation (1).
*
- *
- * @param x Value at which the CDF is evaluated.
- * @return the CDF for this distribution.
*/
+ @Override
public double cumulativeProbability(double x) {
double ret;
if (x <= 0.0) {
@@ -110,17 +109,13 @@ public class ExponentialDistributionImpl extends AbstractContinuousDistribution
}
/**
- * For this distribution, X, this method returns the critical point x, such
- * that {@code P(X < x) = p}.
- * It will return 0 when p = 0 and {@code Double.POSITIVE_INFINITY}
- * when p = 1.
+ * {@inheritDoc}
*
- * @param p Desired probability.
- * @return {@code x}, such that {@code P(X < x) = p}.
- * @throws OutOfRangeException if {@code p < 0} or {@code p > 1}.
+ * It will return {@code 0} when {@code p = 0} and
+ * {@code Double.POSITIVE_INFINITY} when {@code p = 1}.
*/
@Override
- public double inverseCumulativeProbability(double p) {
+ public double inverseCumulativeProbability(double p) throws OutOfRangeException {
double ret;
if (p < 0.0 || p > 1.0) {
diff --git a/src/main/java/org/apache/commons/math/distribution/FDistributionImpl.java b/src/main/java/org/apache/commons/math/distribution/FDistributionImpl.java
index 74764c557..282f32669 100644
--- a/src/main/java/org/apache/commons/math/distribution/FDistributionImpl.java
+++ b/src/main/java/org/apache/commons/math/distribution/FDistributionImpl.java
@@ -20,6 +20,7 @@ package org.apache.commons.math.distribution;
import java.io.Serializable;
import org.apache.commons.math.exception.NotStrictlyPositiveException;
+import org.apache.commons.math.exception.OutOfRangeException;
import org.apache.commons.math.exception.util.LocalizedFormats;
import org.apache.commons.math.special.Beta;
import org.apache.commons.math.util.FastMath;
@@ -89,10 +90,8 @@ public class FDistributionImpl
}
/**
- * Returns the probability density for a particular point.
+ * {@inheritDoc}
*
- * @param x The point at which the density should be computed.
- * @return The pdf at point x.
* @since 2.1
*/
@Override
@@ -110,7 +109,7 @@ public class FDistributionImpl
}
/**
- * For this distribution, {@code X}, this method returns {@code P(X < x)}.
+ * {@inheritDoc}
*
* The implementation of this method is based on
*
@@ -119,10 +118,8 @@ public class FDistributionImpl
* F-Distribution, equation (4).
*
*
- *
- * @param x Value at which the CDF is evaluated.
- * @return CDF for this distribution.
*/
+ @Override
public double cumulativeProbability(double x) {
double ret;
if (x <= 0) {
@@ -139,17 +136,13 @@ public class FDistributionImpl
}
/**
- * For this distribution, {@code X}, this method returns the critical
- * point {@code x}, such that {@code P(X < x) = p}.
- * Returns 0 when p = 0 and {@code Double.POSITIVE_INFINITY} when p = 1.
+ * {@inheritDoc}
*
- * @param p Desired probability.
- * @return {@code x}, such that {@code P(X < x) = p}.
- * @throws IllegalArgumentException if {@code p} is not a valid
- * probability.
+ * It will return {@code 0} when {@code p = 0} and
+ * {@code Double.POSITIVE_INFINITY} when {@code p = 1}.
*/
@Override
- public double inverseCumulativeProbability(final double p) {
+ public double inverseCumulativeProbability(final double p) throws OutOfRangeException {
if (p == 0) {
return 0;
}
@@ -207,6 +200,7 @@ public class FDistributionImpl
/**
* {@inheritDoc}
*/
+ @Override
public double getNumeratorDegreesOfFreedom() {
return numeratorDegreesOfFreedom;
}
@@ -214,6 +208,7 @@ public class FDistributionImpl
/**
* {@inheritDoc}
*/
+ @Override
public double getDenominatorDegreesOfFreedom() {
return denominatorDegreesOfFreedom;
}
diff --git a/src/main/java/org/apache/commons/math/distribution/GammaDistributionImpl.java b/src/main/java/org/apache/commons/math/distribution/GammaDistributionImpl.java
index 6af4215f3..d4aa2b25d 100644
--- a/src/main/java/org/apache/commons/math/distribution/GammaDistributionImpl.java
+++ b/src/main/java/org/apache/commons/math/distribution/GammaDistributionImpl.java
@@ -79,7 +79,7 @@ public class GammaDistributionImpl extends AbstractContinuousDistribution
}
/**
- * For this distribution, {@code X}, this method returns {@code P(X < x)}.
+ * {@inheritDoc}
*
* The implementation of this method is based on:
*
@@ -91,10 +91,8 @@ public class GammaDistributionImpl extends AbstractContinuousDistribution
* Belmont, CA: Duxbury Press.
*
*
- *
- * @param x Value at which the CDF is evaluated.
- * @return CDF for this distribution.
*/
+ @Override
public double cumulativeProbability(double x) {
double ret;
@@ -108,15 +106,10 @@ public class GammaDistributionImpl extends AbstractContinuousDistribution
}
/**
- * For this distribution, {@code X}, this method returns the critical
- * point {@code x}, such that {@code P(X < x) = p}.
- * It will return 0 when p = 0 and {@code Double.POSITIVE_INFINITY}
- * when p = 1.
+ * {@inheritDoc}
*
- * @param p Desired probability.
- * @return {@code x}, such that {@code P(X < x) = p}.
- * @throws org.apache.commons.math.exception.OutOfRangeException if
- * {@code p} is not a valid probability.
+ * It will return {@code 0} when {@cod p = 0} and
+ * {@code Double.POSITIVE_INFINITY} when {@code p = 1}.
*/
@Override
public double inverseCumulativeProbability(final double p) {
@@ -132,6 +125,7 @@ public class GammaDistributionImpl extends AbstractContinuousDistribution
/**
* {@inheritDoc}
*/
+ @Override
public double getAlpha() {
return alpha;
}
@@ -139,6 +133,7 @@ public class GammaDistributionImpl extends AbstractContinuousDistribution
/**
* {@inheritDoc}
*/
+ @Override
public double getBeta() {
return beta;
}
diff --git a/src/main/java/org/apache/commons/math/distribution/NormalDistributionImpl.java b/src/main/java/org/apache/commons/math/distribution/NormalDistributionImpl.java
index 8575d5792..389a2c8df 100644
--- a/src/main/java/org/apache/commons/math/distribution/NormalDistributionImpl.java
+++ b/src/main/java/org/apache/commons/math/distribution/NormalDistributionImpl.java
@@ -92,6 +92,7 @@ public class NormalDistributionImpl extends AbstractContinuousDistribution
/**
* {@inheritDoc}
*/
+ @Override
public double getMean() {
return mean;
}
@@ -99,6 +100,7 @@ public class NormalDistributionImpl extends AbstractContinuousDistribution
/**
* {@inheritDoc}
*/
+ @Override
public double getStandardDeviation() {
return standardDeviation;
}
@@ -114,13 +116,12 @@ public class NormalDistributionImpl extends AbstractContinuousDistribution
}
/**
- * For this distribution, {@code X}, this method returns {@code P(X < x)}.
- * If {@code x}is more than 40 standard deviations from the mean, 0 or 1 is returned,
- * as in these cases the actual value is within {@code Double.MIN_VALUE} of 0 or 1.
+ * {@inheritDoc}
*
- * @param x Value at which the CDF is evaluated.
- * @return CDF evaluated at {@code x}.
+ * If {@code x} is more than 40 standard deviations from the mean, 0 or 1 is returned,
+ * as in these cases the actual value is within {@code Double.MIN_VALUE} of 0 or 1.
*/
+ @Override
public double cumulativeProbability(double x) {
final double dev = x - mean;
if (FastMath.abs(dev) > 40 * standardDeviation) {
@@ -133,7 +134,7 @@ public class NormalDistributionImpl extends AbstractContinuousDistribution
* {@inheritDoc}
*/
@Override
- public double cumulativeProbability(double x0, double x1) {
+ public double cumulativeProbability(double x0, double x1) throws NumberIsTooLargeException {
if (x0 > x1) {
throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT,
x0, x1, true);
@@ -157,19 +158,13 @@ public class NormalDistributionImpl extends AbstractContinuousDistribution
}
/**
- * For this distribution, X, this method returns the critical point
- * {@code x}, such that {@code P(X < x) = p}.
- * It will return {@code Double.NEGATIVE_INFINITY} when p = 0 and
- * {@code Double.POSITIVE_INFINITY} for p = 1.
+ * {@inheritDoc}
*
- * @param p Desired probability.
- * @return {@code x}, such that {@code P(X < x) = p}.
- * @throws org.apache.commons.math.exception.OutOfRangeException if
- * {@code p} is not a valid probability.
+ * It will return {@code Double.NEGATIVE_INFINITY} when {@code p = 0}
+ * and {@code Double.POSITIVE_INFINITY} for {@code p = 1}.
*/
@Override
- public double inverseCumulativeProbability(final double p)
- {
+ public double inverseCumulativeProbability(final double p) {
if (p == 0) {
return Double.NEGATIVE_INFINITY;
}
diff --git a/src/main/java/org/apache/commons/math/distribution/TDistributionImpl.java b/src/main/java/org/apache/commons/math/distribution/TDistributionImpl.java
index e5e0e2818..1e19b7ae2 100644
--- a/src/main/java/org/apache/commons/math/distribution/TDistributionImpl.java
+++ b/src/main/java/org/apache/commons/math/distribution/TDistributionImpl.java
@@ -79,6 +79,7 @@ public class TDistributionImpl
*
* @return the degrees of freedom.
*/
+ @Override
public double getDegreesOfFreedom() {
return degreesOfFreedom;
}
@@ -96,11 +97,9 @@ public class TDistributionImpl
}
/**
- * For this distribution, X, this method returns {@code P(X < x}).
- *
- * @param x Value at which the CDF is evaluated.
- * @return CDF evaluated at {@code x}.
+ * {@inheritDoc}
*/
+ @Override
public double cumulativeProbability(double x) {
double ret;
if (x == 0) {
@@ -122,15 +121,10 @@ public class TDistributionImpl
}
/**
- * For this distribution, {@code X}, this method returns the critical
- * point {@code x}, such that {@code P(X < x) = p}.
- * Returns {@code Double.NEGATIVE_INFINITY} when p = 0 and
- * {@code Double.POSITIVE_INFINITY} when p = 1.
+ * {@inheritDoc}
*
- * @param p Desired probability.
- * @return {@code x}, such that {@code P(X < x) = p}.
- * @throws org.apache.commons.math.exception.OutOfRangeException if
- * {@code p} is not a valid probability.
+ * It will return {@code Double.NEGATIVE_INFINITY} when {@cod p = 0}
+ * and {@code Double.POSITIVE_INFINITY} when {@code p = 1}.
*/
@Override
public double inverseCumulativeProbability(final double p) {
diff --git a/src/main/java/org/apache/commons/math/distribution/WeibullDistributionImpl.java b/src/main/java/org/apache/commons/math/distribution/WeibullDistributionImpl.java
index fe94518c1..47c80b4e3 100644
--- a/src/main/java/org/apache/commons/math/distribution/WeibullDistributionImpl.java
+++ b/src/main/java/org/apache/commons/math/distribution/WeibullDistributionImpl.java
@@ -88,11 +88,9 @@ public class WeibullDistributionImpl extends AbstractContinuousDistribution
}
/**
- * For this distribution, {@code X}, this method returns {@code P(X < x)}.
- *
- * @param x Value at which the CDF is evaluated.
- * @return the CDF evaluated at {@code x}.
+ * {@inheritDoc}
*/
+ @Override
public double cumulativeProbability(double x) {
double ret;
if (x <= 0.0) {
@@ -106,6 +104,7 @@ public class WeibullDistributionImpl extends AbstractContinuousDistribution
/**
* {@inheritDoc}
*/
+ @Override
public double getShape() {
return shape;
}
@@ -113,6 +112,7 @@ public class WeibullDistributionImpl extends AbstractContinuousDistribution
/**
* {@inheritDoc}
*/
+ @Override
public double getScale() {
return scale;
}
@@ -140,14 +140,10 @@ public class WeibullDistributionImpl extends AbstractContinuousDistribution
}
/**
- * For this distribution, {@code X}, this method returns the critical
- * point {@code x}, such that {@code P(X < x) = p}.
- * It will return {@code Double.NEGATIVE_INFINITY} when p = 0 and
- * {@code Double.POSITIVE_INFINITY} when p = 1.
+ * {@inheritDoc}
*
- * @param p Desired probability.
- * @return {@code x}, such that {@code P(X < x) = p}.
- * @throws OutOfRangeException if {@code p} is not a valid probability.
+ * It will return {@code 0} when {@code p = 0} and
+ * {@code Double.POSITIVE_INFINITY} when {@code p = 1}.
*/
@Override
public double inverseCumulativeProbability(double p) {
diff --git a/src/test/java/org/apache/commons/math/distribution/ContinuousDistributionAbstractTest.java b/src/test/java/org/apache/commons/math/distribution/ContinuousDistributionAbstractTest.java
index 84498236a..629c740cb 100644
--- a/src/test/java/org/apache/commons/math/distribution/ContinuousDistributionAbstractTest.java
+++ b/src/test/java/org/apache/commons/math/distribution/ContinuousDistributionAbstractTest.java
@@ -238,7 +238,7 @@ public abstract class ContinuousDistributionAbstractTest {
distribution.cumulativeProbability
(cumulativeTestPoints[i], cumulativeTestPoints[i]), tolerance);
- // check that P(a < X < b) = P(X < b) - P(X < a)
+ // check that P(a < X <= b) = P(X <= b) - P(X <= a)
double upper = FastMath.max(cumulativeTestPoints[i], cumulativeTestPoints[i -1]);
double lower = FastMath.min(cumulativeTestPoints[i], cumulativeTestPoints[i -1]);
double diff = distribution.cumulativeProbability(upper) -
diff --git a/src/test/java/org/apache/commons/math/distribution/TDistributionTest.java b/src/test/java/org/apache/commons/math/distribution/TDistributionTest.java
index 2bedadfdf..472349160 100644
--- a/src/test/java/org/apache/commons/math/distribution/TDistributionTest.java
+++ b/src/test/java/org/apache/commons/math/distribution/TDistributionTest.java
@@ -72,7 +72,7 @@ public class TDistributionTest extends ContinuousDistributionAbstractTest {
* Bug report that prompted this unit test.
*/
@Test
- public void testCumulativeProbabilityAgaintStackOverflow() throws Exception {
+ public void testCumulativeProbabilityAgainstStackOverflow() throws Exception {
TDistributionImpl td = new TDistributionImpl(5.);
td.cumulativeProbability(.1);
td.cumulativeProbability(.01);