Author: erans
Date: Sat Aug 4 18:06:59 2012
New Revision: 1369381
URL: http://svn.apache.org/viewvc?rev=1369381&view=rev
Log:
MATH-839
Added new method "probability(double, double)" to "AbstractRealDistribution".
Deprecated "cumulativeProbability(double, double)".
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/AbstractRealDistribution.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/RealDistribution.java
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/AbstractRealDistribution.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/AbstractRealDistribution.java?rev=1369381&r1=1369380&r2=1369381&view=diff
==============================================================================
---
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/AbstractRealDistribution.java
(original)
+++
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/AbstractRealDistribution.java
Sat Aug 4 18:06:59 2012
@@ -75,11 +75,36 @@ implements RealDistribution, Serializabl
*
* The default implementation uses the identity
* <p>{@code P(x0 < X <= x1) = P(X <= x1) - P(X <= x0)}</p>
+ *
+ * @deprecated As of 3.1 (to be removed in 4.0). Please use
+ * {@link #probability(double,double)} instead.
*/
+ @Deprecated
public double cumulativeProbability(double x0, double x1) throws
NumberIsTooLargeException {
+ return probability(x0, 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 Lower bound (excluded).
+ * @param x1 Upper bound (included).
+ * @return the probability that a random variable with this distribution
+ * takes a value between {@code x0} and {@code x1}, excluding the lower
+ * and including the upper endpoint.
+ * @throws NumberIsTooLargeException if {@code x0 > x1}.
+ *
+ * The default implementation uses the identity
+ * {@code P(x0 < X <= x1) = P(X <= x1) - P(X <= x0)}
+ *
+ * @since 3.1
+ */
+ public double probability(double x0,
+ double x1) {
if (x0 > x1) {
throw new
NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT,
- x0, x1, true);
+ x0, x1, true);
}
return cumulativeProbability(x1) - cumulativeProbability(x0);
}
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/RealDistribution.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/RealDistribution.java?rev=1369381&r1=1369380&r2=1369381&view=diff
==============================================================================
---
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/RealDistribution.java
(original)
+++
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/RealDistribution.java
Sat Aug 4 18:06:59 2012
@@ -73,7 +73,11 @@ public interface RealDistribution {
* takes a value between {@code x0} and {@code x1},
* excluding the lower and including the upper endpoint
* @throws NumberIsTooLargeException if {@code x0 > x1}
+ *
+ * @deprecate As of 3.1. In 4.0, this method will be renamed
+ * {@code probability(double x0, double x1)}.
*/
+ @Deprecated
double cumulativeProbability(double x0, double x1) throws
NumberIsTooLargeException;
/**