You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ps...@apache.org on 2011/10/03 06:36:28 UTC
svn commit: r1178295 - in /commons/proper/math/trunk/src:
main/java/org/apache/commons/math/distribution/
main/java/org/apache/commons/math/random/
test/java/org/apache/commons/math/distribution/
Author: psteitz
Date: Mon Oct 3 04:36:27 2011
New Revision: 1178295
URL: http://svn.apache.org/viewvc?rev=1178295&view=rev
Log:
Eliminated MathException from distribution interfaces and impls.
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/AbstractContinuousDistribution.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/AbstractDistribution.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/AbstractIntegerDistribution.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/BetaDistributionImpl.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/BinomialDistributionImpl.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ChiSquaredDistributionImpl.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ContinuousDistribution.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/Distribution.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ExponentialDistributionImpl.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/FDistributionImpl.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/GammaDistributionImpl.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/IntegerDistribution.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/NormalDistributionImpl.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PascalDistributionImpl.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PoissonDistribution.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PoissonDistributionImpl.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/TDistributionImpl.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/RandomDataImpl.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/AbtractIntegerDistributionTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/PoissonDistributionTest.java
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/AbstractContinuousDistribution.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/AbstractContinuousDistribution.java?rev=1178295&r1=1178294&r2=1178295&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/AbstractContinuousDistribution.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/AbstractContinuousDistribution.java Mon Oct 3 04:36:27 2011
@@ -18,9 +18,9 @@ package org.apache.commons.math.distribu
import java.io.Serializable;
-import org.apache.commons.math.MathException;
import org.apache.commons.math.analysis.UnivariateRealFunction;
import org.apache.commons.math.analysis.solvers.UnivariateRealSolverUtils;
+import org.apache.commons.math.exception.MathInternalError;
import org.apache.commons.math.exception.NotStrictlyPositiveException;
import org.apache.commons.math.exception.OutOfRangeException;
import org.apache.commons.math.exception.util.LocalizedFormats;
@@ -69,13 +69,9 @@ public abstract class AbstractContinuous
*
* @param p Desired probability.
* @return {@code x}, such that {@code P(X < x) = p}.
- * @throws MathException if the inverse cumulative probability can not be
- * computed due to convergence or other numerical errors.
* @throws OutOfRangeException if {@code p} is not a valid probability.
*/
- public double inverseCumulativeProbability(final double p)
- throws MathException {
- try {
+ public double inverseCumulativeProbability(final double p) {
if (p < 0.0 || p > 1.0) {
throw new OutOfRangeException(p, 0, 1);
@@ -86,16 +82,7 @@ public abstract class AbstractContinuous
UnivariateRealFunction rootFindingFunction =
new UnivariateRealFunction() {
public double value(double x) {
- double ret = Double.NaN;
- try {
- ret = cumulativeProbability(x) - p;
- } catch (MathException ex) {
- throw new WrappingException(ex);
- }
- if (Double.isNaN(ret)) {
- throw new WrappingException(new MathException(LocalizedFormats.CUMULATIVE_PROBABILITY_RETURNED_NAN, x, p));
- }
- return ret;
+ return cumulativeProbability(x) - p;
}
};
@@ -120,7 +107,7 @@ public abstract class AbstractContinuous
return upperBound;
}
// Failed bracket convergence was not because of corner solution
- throw new MathException(ex);
+ throw new MathInternalError(ex);
}
// find root
@@ -129,35 +116,6 @@ public abstract class AbstractContinuous
// absolute accuracy different from the default.
bracket[0],bracket[1], getSolverAbsoluteAccuracy());
return root;
-
- } catch (WrappingException we) {
- throw we.getWrapped();
- }
- }
-
- /** Local exception wrapping a MathException. */
- private static class WrappingException extends RuntimeException {
-
- /** Serializable UID. */
- private static final long serialVersionUID = -2102700399222815344L;
-
- /** Wrapped exception. */
- private final MathException wrapped;
-
- /** simple constructor.
- * @param wrapped exception to wrap
- */
- public WrappingException(final MathException wrapped) {
- this.wrapped = wrapped;
- }
-
- /** Get the wrapped exception.
- * @return wrapped exception
- */
- public MathException getWrapped() {
- return wrapped;
- }
-
}
/**
@@ -178,10 +136,9 @@ public abstract class AbstractContinuous
* </a>
*
* @return a random value.
- * @throws MathException if an error occurs generating the random value.
* @since 2.2
*/
- public double sample() throws MathException {
+ public double sample() {
return randomData.nextInversionDeviate(this);
}
@@ -191,11 +148,10 @@ public abstract class AbstractContinuous
*
* @param sampleSize Number of random values to generate.
* @return an array representing the random sample.
- * @throws MathException if an error occurs generating the sample.
* @throws NotStrictlyPositiveException if {@code sampleSize} is not positive.
* @since 2.2
*/
- public double[] sample(int sampleSize) throws MathException {
+ public double[] sample(int sampleSize) {
if (sampleSize <= 0) {
throw new NotStrictlyPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES,
sampleSize);
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/AbstractDistribution.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/AbstractDistribution.java?rev=1178295&r1=1178294&r2=1178295&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/AbstractDistribution.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/AbstractDistribution.java Mon Oct 3 04:36:27 2011
@@ -18,7 +18,6 @@ package org.apache.commons.math.distribu
import java.io.Serializable;
-import org.apache.commons.math.MathException;
import org.apache.commons.math.exception.NumberIsTooLargeException;
import org.apache.commons.math.exception.util.LocalizedFormats;
@@ -65,12 +64,9 @@ public abstract class AbstractDistributi
* @return the probability that a random variable with this distribution
* will take a value between {@code x0} and {@code x1},
* including the endpoints.
- * @throws MathException if the cumulative probability can not be
- * computed due to convergence or other numerical errors.
* @throws NumberIsTooLargeException if {@code x0 > x1}
*/
- public double cumulativeProbability(double x0, double x1)
- throws MathException {
+ public double cumulativeProbability(double x0, double x1) {
if (x0 > x1) {
throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT,
x0, x1, true);
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/AbstractIntegerDistribution.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/AbstractIntegerDistribution.java?rev=1178295&r1=1178294&r2=1178295&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/AbstractIntegerDistribution.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/AbstractIntegerDistribution.java Mon Oct 3 04:36:27 2011
@@ -18,7 +18,7 @@ package org.apache.commons.math.distribu
import java.io.Serializable;
-import org.apache.commons.math.MathException;
+import org.apache.commons.math.exception.MathInternalError;
import org.apache.commons.math.exception.NotStrictlyPositiveException;
import org.apache.commons.math.exception.NumberIsTooSmallException;
import org.apache.commons.math.exception.OutOfRangeException;
@@ -60,10 +60,8 @@ public abstract class AbstractIntegerDis
* @param x Value at which the distribution function is evaluated.
* @return the cumulative probability that a random variable with this
* distribution takes a value less than or equal to {@code x}.
- * @throws MathException if the cumulative probability can not be
- * computed due to convergence or other numerical errors.
*/
- public double cumulativeProbability(double x) throws MathException {
+ public double cumulativeProbability(double x) {
return cumulativeProbability((int) FastMath.floor(x));
}
@@ -77,13 +75,10 @@ public abstract class AbstractIntegerDis
* @return the probability that a random variable with this distribution
* will take a value between {@code x0} and {@code x1},
* including the endpoints.
- * @throws MathException if the cumulative probability can not be
- * computed due to convergence or other numerical errors.
* @throws NumberIsTooSmallException if {@code x1 > x0}.
*/
@Override
- public double cumulativeProbability(double x0, double x1)
- throws MathException {
+ public double cumulativeProbability(double x0, double x1) {
if (x1 < x0) {
throw new NumberIsTooSmallException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT,
x1, x0, true);
@@ -105,10 +100,8 @@ public abstract class AbstractIntegerDis
*
* @param x Value at which the PDF is evaluated.
* @return PDF for this distribution.
- * @throws MathException if the cumulative probability can not be
- * computed due to convergence or other numerical errors.
*/
- public abstract double cumulativeProbability(int x) throws MathException;
+ public abstract double cumulativeProbability(int x);
/**
* For a random variable {@code X} whose values are distributed according
@@ -136,11 +129,9 @@ public abstract class AbstractIntegerDis
* @param x0 Inclusive lower bound.
* @param x1 Inclusive upper bound.
* @return the cumulative probability.
- * @throws MathException if the cumulative probability can not be
- * computed due to convergence or other numerical errors.
* @throws NumberIsTooSmallException {@code if x0 > x1}.
*/
- public double cumulativeProbability(int x0, int x1) throws MathException {
+ public double cumulativeProbability(int x0, int x1) {
if (x1 < x0) {
throw new NumberIsTooSmallException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT,
x1, x0, true);
@@ -155,11 +146,9 @@ public abstract class AbstractIntegerDis
*
* @param p Desired probability.
* @return the largest {@code x} such that {@code P(X < x) <= p}.
- * @throws MathException if the inverse cumulative probability can not be
- * computed due to convergence or other numerical errors.
* @throws OutOfRangeException if {@code p < 0} or {@code p > 1}.
*/
- public int inverseCumulativeProbability(final double p) throws MathException{
+ public int inverseCumulativeProbability(final double p) {
if (p < 0 || p > 1) {
throw new OutOfRangeException(p, 0, 1);
}
@@ -221,9 +210,8 @@ public abstract class AbstractIntegerDis
*
* @return a random value.
* @since 2.2
- * @throws MathException if an error occurs generating the random value.
*/
- public int sample() throws MathException {
+ public int sample() {
return randomData.nextInversionDeviate(this);
}
@@ -235,10 +223,9 @@ public abstract class AbstractIntegerDis
* @param sampleSize number of random values to generate.
* @since 2.2
* @return an array representing the random sample.
- * @throws MathException if an error occurs generating the sample.
* @throws NotStrictlyPositiveException if {@code sampleSize <= 0}.
*/
- public int[] sample(int sampleSize) throws MathException {
+ public int[] sample(int sampleSize) {
if (sampleSize <= 0) {
throw new NotStrictlyPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES,
sampleSize);
@@ -253,20 +240,21 @@ public abstract class AbstractIntegerDis
/**
* Computes the cumulative probability function and checks for NaN
* values returned.
- * Throws MathException if the value is NaN. Rethrows any MathException encountered
+ * Throws MathInternalError if the value is NaN. Rethrows any Exception encountered
* evaluating the cumulative probability function. Throws
- * MathException if the cumulative probability function returns NaN.
+ * MathInternalError if the cumulative probability function returns NaN.
*
* @param argument Input value.
* @return the cumulative probability.
- * @throws MathException if the cumulative probability is NaN
+ * @throws MathInternalError if the cumulative probability is NaN
*/
private double checkedCumulativeProbability(int argument)
- throws MathException {
+ throws MathInternalError {
double result = Double.NaN;
result = cumulativeProbability(argument);
if (Double.isNaN(result)) {
- throw new MathException(LocalizedFormats.DISCRETE_CUMULATIVE_PROBABILITY_RETURNED_NAN, argument);
+ throw new MathInternalError(
+ LocalizedFormats.DISCRETE_CUMULATIVE_PROBABILITY_RETURNED_NAN, argument);
}
return result;
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/BetaDistributionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/BetaDistributionImpl.java?rev=1178295&r1=1178294&r2=1178295&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/BetaDistributionImpl.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/BetaDistributionImpl.java Mon Oct 3 04:36:27 2011
@@ -16,7 +16,6 @@
*/
package org.apache.commons.math.distribution;
-import org.apache.commons.math.MathException;
import org.apache.commons.math.exception.NumberIsTooSmallException;
import org.apache.commons.math.exception.util.LocalizedFormats;
import org.apache.commons.math.special.Gamma;
@@ -128,7 +127,7 @@ public class BetaDistributionImpl
/** {@inheritDoc} */
@Override
- public double inverseCumulativeProbability(double p) throws MathException {
+ public double inverseCumulativeProbability(double p) {
if (p == 0) {
return 0;
} else if (p == 1) {
@@ -157,7 +156,7 @@ public class BetaDistributionImpl
}
/** {@inheritDoc} */
- public double cumulativeProbability(double x) throws MathException {
+ public double cumulativeProbability(double x) {
if (x <= 0) {
return 0;
} else if (x >= 1) {
@@ -169,7 +168,7 @@ public class BetaDistributionImpl
/** {@inheritDoc} */
@Override
- public double cumulativeProbability(double x0, double x1) throws MathException {
+ public double cumulativeProbability(double x0, double x1) {
return cumulativeProbability(x1) - cumulativeProbability(x0);
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/BinomialDistributionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/BinomialDistributionImpl.java?rev=1178295&r1=1178294&r2=1178295&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/BinomialDistributionImpl.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/BinomialDistributionImpl.java Mon Oct 3 04:36:27 2011
@@ -18,7 +18,6 @@ package org.apache.commons.math.distribu
import java.io.Serializable;
-import org.apache.commons.math.MathException;
import org.apache.commons.math.exception.OutOfRangeException;
import org.apache.commons.math.exception.NotPositiveException;
import org.apache.commons.math.exception.util.LocalizedFormats;
@@ -104,11 +103,10 @@ public class BinomialDistributionImpl ex
*
* @param x Value at which the PDF is evaluated.
* @return PDF for this distribution.
- * @throws MathException if the cumulative probability can not be computed
* due to convergence or other numerical errors.
*/
@Override
- public double cumulativeProbability(int x) throws MathException {
+ public double cumulativeProbability(int x) {
double ret;
if (x < 0) {
ret = 0.0;
@@ -146,13 +144,10 @@ public class BinomialDistributionImpl ex
*
* @param p Desired probability.
* @return the largest {@code x} such that {@code P(X < x) <= p}.
- * @throws MathException if the inverse cumulative probability can not be
- * computed due to convergence or other numerical errors.
* @throws OutOfRangeException if {@code p < 0} or {@code p > 1}.
*/
@Override
- public int inverseCumulativeProbability(final double p)
- throws MathException {
+ public int inverseCumulativeProbability(final double p) {
// handle extreme values explicitly
if (p == 0) {
return -1;
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ChiSquaredDistributionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ChiSquaredDistributionImpl.java?rev=1178295&r1=1178294&r2=1178295&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ChiSquaredDistributionImpl.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ChiSquaredDistributionImpl.java Mon Oct 3 04:36:27 2011
@@ -18,7 +18,6 @@ package org.apache.commons.math.distribu
import java.io.Serializable;
-import org.apache.commons.math.MathException;
/**
* The default implementation of {@link ChiSquaredDistribution}
@@ -85,10 +84,8 @@ public class ChiSquaredDistributionImpl
*
* @param x the value at which the CDF is evaluated.
* @return CDF for this distribution.
- * @throws MathException if the cumulative probability cannot be
- * computed due to convergence or other numerical errors.
*/
- public double cumulativeProbability(double x) throws MathException {
+ public double cumulativeProbability(double x) {
return gamma.cumulativeProbability(x);
}
@@ -100,14 +97,11 @@ public class ChiSquaredDistributionImpl
*
* @param p Desired probability.
* @return {@code x}, such that {@code P(X < x) = p}.
- * @throws MathException if the inverse cumulative probability can not be
- * computed due to convergence or other numerical errors.
* @throws org.apache.commons.math.exception.OutOfRangeException if
* {@code p} is not a valid probability.
*/
@Override
- public double inverseCumulativeProbability(final double p)
- throws MathException {
+ public double inverseCumulativeProbability(final double p) {
if (p == 0) {
return 0d;
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ContinuousDistribution.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ContinuousDistribution.java?rev=1178295&r1=1178294&r2=1178295&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ContinuousDistribution.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ContinuousDistribution.java Mon Oct 3 04:36:27 2011
@@ -16,8 +16,6 @@
*/
package org.apache.commons.math.distribution;
-import org.apache.commons.math.MathException;
-
/**
* Base interface for continuous distributions.
*
@@ -30,10 +28,8 @@ public interface ContinuousDistribution
*
* @param p Cumulative probability.
* @return {@code x} such that {@code P(X < x) = p}.
- * @throws MathException if the inverse cumulative probability cannot be
- * computed due to convergence or other numerical errors.
*/
- double inverseCumulativeProbability(double p) throws MathException;
+ double inverseCumulativeProbability(double p);
/**
* Probability density for a particular point.
@@ -55,20 +51,18 @@ public interface ContinuousDistribution
* Generate a random value sampled from this distribution.
*
* @return a random value.
- * @throws MathException if an error occurs generating the random value.
* @since 3.0
*/
- double sample() throws MathException;
+ double sample();
/**
* Generate a random sample from the distribution.
*
* @param sampleSize number of random values to generate.
* @return an array representing the random sample.
- * @throws MathException if an error occurs generating the sample.
* @throws org.apache.commons.math.exception.NotStrictlyPositiveException
* if {@code sampleSize} is not positive.
* @since 3.0
*/
- double[] sample(int sampleSize) throws MathException;
+ double[] sample(int sampleSize);
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/Distribution.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/Distribution.java?rev=1178295&r1=1178294&r2=1178295&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/Distribution.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/Distribution.java Mon Oct 3 04:36:27 2011
@@ -16,8 +16,6 @@
*/
package org.apache.commons.math.distribution;
-import org.apache.commons.math.MathException;
-
/**
* Base interface for probability distributions.
*
@@ -33,10 +31,8 @@ public interface Distribution {
* @param x the value at which the distribution function is evaluated.
* @return the probability that a random variable with this
* distribution takes a value less than or equal to <code>x</code>
- * @throws MathException if the cumulative probability can not be
- * computed due to convergence or other numerical errors.
*/
- double cumulativeProbability(double x) throws MathException;
+ double cumulativeProbability(double x);
/**
* For a random variable X whose values are distributed according
@@ -47,11 +43,9 @@ public interface Distribution {
* @return the probability that a random variable with this distribution
* will take a value between <code>x0</code> and <code>x1</code>,
* including the endpoints
- * @throws MathException if the cumulative probability can not be
- * computed due to convergence or other numerical errors.
* @throws IllegalArgumentException if <code>x0 > x1</code>
*/
- double cumulativeProbability(double x0, double x1) throws MathException;
+ double cumulativeProbability(double x0, double x1);
/**
* Use this method to get the numerical value of the mean of this
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ExponentialDistributionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ExponentialDistributionImpl.java?rev=1178295&r1=1178294&r2=1178295&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ExponentialDistributionImpl.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ExponentialDistributionImpl.java Mon Oct 3 04:36:27 2011
@@ -18,7 +18,6 @@ package org.apache.commons.math.distribu
import java.io.Serializable;
-import org.apache.commons.math.MathException;
import org.apache.commons.math.exception.NotStrictlyPositiveException;
import org.apache.commons.math.exception.OutOfRangeException;
import org.apache.commons.math.exception.util.LocalizedFormats;
@@ -99,10 +98,8 @@ public class ExponentialDistributionImpl
*
* @param x Value at which the CDF is evaluated.
* @return the CDF for this distribution.
- * @throws MathException if the cumulative probability can not be
- * computed due to convergence or other numerical errors.
*/
- public double cumulativeProbability(double x) throws MathException {
+ public double cumulativeProbability(double x) {
double ret;
if (x <= 0.0) {
ret = 0.0;
@@ -120,12 +117,10 @@ public class ExponentialDistributionImpl
*
* @param p Desired probability.
* @return {@code x}, such that {@code P(X < x) = p}.
- * @throws MathException if the inverse cumulative probability can not be
- * computed due to convergence or other numerical errors.
* @throws OutOfRangeException if {@code p < 0} or {@code p > 1}.
*/
@Override
- public double inverseCumulativeProbability(double p) throws MathException {
+ public double inverseCumulativeProbability(double p) {
double ret;
if (p < 0.0 || p > 1.0) {
@@ -148,11 +143,10 @@ public class ExponentialDistributionImpl
* uniform deviates.</p>
*
* @return a random value.
- * @throws MathException if an error occurs generating the random value.
* @since 2.2
*/
@Override
- public double sample() throws MathException {
+ public double sample() {
return randomData.nextExponential(mean);
}
Modified: 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/FDistributionImpl.java?rev=1178295&r1=1178294&r2=1178295&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/FDistributionImpl.java Mon Oct 3 04:36:27 2011
@@ -19,7 +19,6 @@ package org.apache.commons.math.distribu
import java.io.Serializable;
-import org.apache.commons.math.MathException;
import org.apache.commons.math.exception.NotStrictlyPositiveException;
import org.apache.commons.math.exception.util.LocalizedFormats;
import org.apache.commons.math.special.Beta;
@@ -123,10 +122,8 @@ public class FDistributionImpl
*
* @param x Value at which the CDF is evaluated.
* @return CDF for this distribution.
- * @throws MathException if the cumulative probability cannot be
- * computed due to convergence or other numerical errors.
*/
- public double cumulativeProbability(double x) throws MathException {
+ public double cumulativeProbability(double x) {
double ret;
if (x <= 0) {
ret = 0;
@@ -148,14 +145,11 @@ public class FDistributionImpl
*
* @param p Desired probability.
* @return {@code x}, such that {@code P(X < x) = p}.
- * @throws MathException if the inverse cumulative probability cannot be
- * computed due to convergence or other numerical errors.
* @throws IllegalArgumentException if {@code p} is not a valid
* probability.
*/
@Override
- public double inverseCumulativeProbability(final double p)
- throws MathException {
+ public double inverseCumulativeProbability(final double p) {
if (p == 0) {
return 0;
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/GammaDistributionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/GammaDistributionImpl.java?rev=1178295&r1=1178294&r2=1178295&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/GammaDistributionImpl.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/GammaDistributionImpl.java Mon Oct 3 04:36:27 2011
@@ -18,7 +18,6 @@ package org.apache.commons.math.distribu
import java.io.Serializable;
-import org.apache.commons.math.MathException;
import org.apache.commons.math.exception.NotStrictlyPositiveException;
import org.apache.commons.math.exception.util.LocalizedFormats;
import org.apache.commons.math.special.Gamma;
@@ -95,10 +94,8 @@ public class GammaDistributionImpl exten
*
* @param x Value at which the CDF is evaluated.
* @return CDF for this distribution.
- * @throws MathException if the cumulative probability can not be
- * computed due to convergence or other numerical errors.
*/
- public double cumulativeProbability(double x) throws MathException{
+ public double cumulativeProbability(double x) {
double ret;
if (x <= 0) {
@@ -118,14 +115,11 @@ public class GammaDistributionImpl exten
*
* @param p Desired probability.
* @return {@code x}, such that {@code P(X < x) = p}.
- * @throws MathException if the inverse cumulative probability cannot be
- * computed due to convergence or other numerical errors.
* @throws org.apache.commons.math.exception.OutOfRangeException if
* {@code p} is not a valid probability.
*/
@Override
- public double inverseCumulativeProbability(final double p)
- throws MathException {
+ public double inverseCumulativeProbability(final double p) {
if (p == 0) {
return 0;
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/IntegerDistribution.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/IntegerDistribution.java?rev=1178295&r1=1178294&r2=1178295&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/IntegerDistribution.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/IntegerDistribution.java Mon Oct 3 04:36:27 2011
@@ -16,8 +16,6 @@
*/
package org.apache.commons.math.distribution;
-import org.apache.commons.math.MathException;
-
/**
* Interface for discrete distributions of integer-valued random variables.
*
@@ -43,10 +41,8 @@ public interface IntegerDistribution ext
*
* @param x Value at which the PDF is evaluated.
* @return PDF for this distribution.
- * @throws MathException if the cumulative probability cannot be
- * computed due to convergence or other numerical errors.
*/
- double cumulativeProbability(int x) throws MathException;
+ double cumulativeProbability(int x);
/**
* For this distribution, {@code X}, this method returns
@@ -55,11 +51,9 @@ public interface IntegerDistribution ext
* @param x0 the inclusive, lower bound
* @param x1 the inclusive, upper bound
* @return the cumulative probability.
- * @throws MathException if the cumulative probability can not be
- * computed due to convergence or other numerical errors.
* @throws IllegalArgumentException if {@code x0 > x1}.
*/
- double cumulativeProbability(int x0, int x1) throws MathException;
+ double cumulativeProbability(int x0, int x1);
/**
* For this distribution, {@code X}, this method returns the largest
@@ -82,12 +76,10 @@ public interface IntegerDistribution ext
*
* @param p Cumulative probability.
* @return the largest {@code x} such that {@code P(X < x) <= p}.
- * @throws MathException if the inverse cumulative probability cannot be
- * computed due to convergence or other numerical errors.
* @throws IllegalArgumentException if {@code p} is not between 0 and 1
* (inclusive).
*/
- int inverseCumulativeProbability(double p) throws MathException;
+ int inverseCumulativeProbability(double p);
/**
* Reseed the random generator used to generate samples.
@@ -101,20 +93,18 @@ public interface IntegerDistribution ext
* Generate a random value sampled from this distribution.
*
* @return a random value.
- * @throws MathException if an error occurs generating the random value.
* @since 3.0
*/
- int sample() throws MathException;
+ int sample();
/**
* Generate a random sample from the distribution.
*
* @param sampleSize number of random values to generate.
* @return an array representing the random sample.
- * @throws MathException if an error occurs generating the sample.
* @throws org.apache.commons.math.exception.NotStrictlyPositiveException
* if {@code sampleSize} is not positive.
* @since 3.0
*/
- int[] sample(int sampleSize) throws MathException;
+ int[] sample(int sampleSize);
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/NormalDistributionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/NormalDistributionImpl.java?rev=1178295&r1=1178294&r2=1178295&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/NormalDistributionImpl.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/NormalDistributionImpl.java Mon Oct 3 04:36:27 2011
@@ -19,7 +19,6 @@ package org.apache.commons.math.distribu
import java.io.Serializable;
-import org.apache.commons.math.MathException;
import org.apache.commons.math.exception.NotStrictlyPositiveException;
import org.apache.commons.math.exception.NumberIsTooLargeException;
import org.apache.commons.math.exception.util.LocalizedFormats;
@@ -121,9 +120,8 @@ public class NormalDistributionImpl exte
*
* @param x Value at which the CDF is evaluated.
* @return CDF evaluated at {@code x}.
- * @throws MathException if the algorithm fails to converge
*/
- public double cumulativeProbability(double x) throws MathException {
+ public double cumulativeProbability(double x) {
final double dev = x - mean;
if (FastMath.abs(dev) > 40 * standardDeviation) {
return dev < 0 ? 0.0d : 1.0d;
@@ -135,7 +133,7 @@ public class NormalDistributionImpl exte
* {@inheritDoc}
*/
@Override
- public double cumulativeProbability(double x0, double x1) throws MathException {
+ public double cumulativeProbability(double x0, double x1) {
if (x0 > x1) {
throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT,
x0, x1, true);
@@ -166,14 +164,12 @@ public class NormalDistributionImpl exte
*
* @param p Desired probability.
* @return {@code x}, such that {@code P(X < x) = p}.
- * @throws MathException if the inverse cumulative probability cannot be
- * computed due to convergence or other numerical errors.
* @throws org.apache.commons.math.exception.OutOfRangeException if
* {@code p} is not a valid probability.
*/
@Override
public double inverseCumulativeProbability(final double p)
- throws MathException {
+ {
if (p == 0) {
return Double.NEGATIVE_INFINITY;
}
@@ -188,10 +184,9 @@ public class NormalDistributionImpl exte
*
* @return a random value.
* @since 2.2
- * @throws MathException if an error occurs generating the random value.
*/
@Override
- public double sample() throws MathException {
+ public double sample() {
return randomData.nextGaussian(mean, standardDeviation);
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PascalDistributionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PascalDistributionImpl.java?rev=1178295&r1=1178294&r2=1178295&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PascalDistributionImpl.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PascalDistributionImpl.java Mon Oct 3 04:36:27 2011
@@ -18,7 +18,6 @@ package org.apache.commons.math.distribu
import java.io.Serializable;
-import org.apache.commons.math.MathException;
import org.apache.commons.math.exception.OutOfRangeException;
import org.apache.commons.math.exception.NotPositiveException;
import org.apache.commons.math.exception.util.LocalizedFormats;
@@ -104,11 +103,10 @@ public class PascalDistributionImpl exte
*
* @param x Value at which the PDF is evaluated.
* @return PDF for this distribution.
- * @throws MathException if the cumulative probability can not be computed
* due to convergence or other numerical errors.
*/
@Override
- public double cumulativeProbability(int x) throws MathException {
+ public double cumulativeProbability(int x) {
double ret;
if (x < 0) {
ret = 0.0;
@@ -145,13 +143,10 @@ public class PascalDistributionImpl exte
*
* @param p Desired probability.
* @return the largest {@code x} such that {@code P(X <= x) <= p}.
- * @throws MathException if the inverse cumulative probability can not be
- * computed due to convergence or other numerical errors.
* @throws OutOfRangeException if {@code p < 0} or {@code p > 1}.
*/
@Override
- public int inverseCumulativeProbability(final double p)
- throws MathException {
+ public int inverseCumulativeProbability(final double p) {
int ret;
// handle extreme values explicitly
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PoissonDistribution.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PoissonDistribution.java?rev=1178295&r1=1178294&r2=1178295&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PoissonDistribution.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PoissonDistribution.java Mon Oct 3 04:36:27 2011
@@ -16,7 +16,6 @@
*/
package org.apache.commons.math.distribution;
-import org.apache.commons.math.MathException;
/**
* Interface representing the Poisson Distribution.
@@ -44,7 +43,6 @@ public interface PoissonDistribution ext
*
* @param x the upper bound, inclusive
* @return the distribution function value calculated using a normal approximation
- * @throws MathException if an error occurs computing the normal approximation
*/
- double normalApproximateProbability(int x) throws MathException;
+ double normalApproximateProbability(int x) ;
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PoissonDistributionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PoissonDistributionImpl.java?rev=1178295&r1=1178294&r2=1178295&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PoissonDistributionImpl.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PoissonDistributionImpl.java Mon Oct 3 04:36:27 2011
@@ -18,7 +18,6 @@ package org.apache.commons.math.distribu
import java.io.Serializable;
-import org.apache.commons.math.MathException;
import org.apache.commons.math.exception.NotStrictlyPositiveException;
import org.apache.commons.math.exception.util.LocalizedFormats;
import org.apache.commons.math.special.Gamma;
@@ -146,11 +145,10 @@ public class PoissonDistributionImpl ext
*
* @param x Value at which the PDF is evaluated.
* @return the Poisson distribution function evaluated at {@code x}.
- * @throws MathException if the cumulative probability cannot be computed
* due to convergence or other numerical errors.
*/
@Override
- public double cumulativeProbability(int x) throws MathException {
+ public double cumulativeProbability(int x) {
if (x < 0) {
return 0;
}
@@ -170,10 +168,9 @@ public class PoissonDistributionImpl ext
* @param x Upper bound, inclusive.
* @return the distribution function value calculated using a normal
* approximation.
- * @throws MathException if an error occurs computing the normal
* approximation.
*/
- public double normalApproximateProbability(int x) throws MathException {
+ public double normalApproximateProbability(int x) {
// calculate the probability using half-correction
return normal.cumulativeProbability(x + 0.5);
}
@@ -198,10 +195,9 @@ public class PoissonDistributionImpl ext
*
* @return a random value.
* @since 2.2
- * @throws MathException if an error occurs generating the random value.
*/
@Override
- public int sample() throws MathException {
+ public int sample() {
return (int) FastMath.min(randomData.nextPoisson(mean), Integer.MAX_VALUE);
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/TDistributionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/TDistributionImpl.java?rev=1178295&r1=1178294&r2=1178295&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/TDistributionImpl.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/TDistributionImpl.java Mon Oct 3 04:36:27 2011
@@ -18,7 +18,6 @@ package org.apache.commons.math.distribu
import java.io.Serializable;
-import org.apache.commons.math.MathException;
import org.apache.commons.math.exception.NotStrictlyPositiveException;
import org.apache.commons.math.exception.util.LocalizedFormats;
import org.apache.commons.math.special.Beta;
@@ -101,10 +100,8 @@ public class TDistributionImpl
*
* @param x Value at which the CDF is evaluated.
* @return CDF evaluated at {@code x}.
- * @throws MathException if the cumulative probability can not be
- * computed due to convergence or other numerical errors.
*/
- public double cumulativeProbability(double x) throws MathException{
+ public double cumulativeProbability(double x) {
double ret;
if (x == 0) {
ret = 0.5;
@@ -132,14 +129,11 @@ public class TDistributionImpl
*
* @param p Desired probability.
* @return {@code x}, such that {@code P(X < x) = p}.
- * @throws MathException if the inverse cumulative probability cannot be
- * computed due to convergence or other numerical errors.
* @throws org.apache.commons.math.exception.OutOfRangeException if
* {@code p} is not a valid probability.
*/
@Override
- public double inverseCumulativeProbability(final double p)
- throws MathException {
+ public double inverseCumulativeProbability(final double p) {
if (p == 0) {
return Double.NEGATIVE_INFINITY;
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/RandomDataImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/RandomDataImpl.java?rev=1178295&r1=1178294&r2=1178295&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/RandomDataImpl.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/RandomDataImpl.java Mon Oct 3 04:36:27 2011
@@ -24,7 +24,6 @@ import java.security.NoSuchProviderExcep
import java.security.SecureRandom;
import java.util.Collection;
-import org.apache.commons.math.MathException;
import org.apache.commons.math.distribution.BetaDistributionImpl;
import org.apache.commons.math.distribution.BinomialDistributionImpl;
import org.apache.commons.math.distribution.CauchyDistributionImpl;
@@ -607,10 +606,9 @@ public class RandomDataImpl implements R
* @param alpha first distribution shape parameter
* @param beta second distribution shape parameter
* @return random value sampled from the beta(alpha, beta) distribution
- * @throws MathException if an error occurs generating the random value
* @since 2.2
*/
- public double nextBeta(double alpha, double beta) throws MathException {
+ public double nextBeta(double alpha, double beta) {
return nextInversionDeviate(new BetaDistributionImpl(alpha, beta));
}
@@ -622,10 +620,9 @@ public class RandomDataImpl implements R
* @param numberOfTrials number of trials of the Binomial distribution
* @param probabilityOfSuccess probability of success of the Binomial distribution
* @return random value sampled from the Binomial(numberOfTrials, probabilityOfSuccess) distribution
- * @throws MathException if an error occurs generating the random value
* @since 2.2
*/
- public int nextBinomial(int numberOfTrials, double probabilityOfSuccess) throws MathException {
+ public int nextBinomial(int numberOfTrials, double probabilityOfSuccess) {
return nextInversionDeviate(new BinomialDistributionImpl(numberOfTrials, probabilityOfSuccess));
}
@@ -637,10 +634,9 @@ public class RandomDataImpl implements R
* @param median the median of the Cauchy distribution
* @param scale the scale parameter of the Cauchy distribution
* @return random value sampled from the Cauchy(median, scale) distribution
- * @throws MathException if an error occurs generating the random value
* @since 2.2
*/
- public double nextCauchy(double median, double scale) throws MathException {
+ public double nextCauchy(double median, double scale) {
return nextInversionDeviate(new CauchyDistributionImpl(median, scale));
}
@@ -651,10 +647,9 @@ public class RandomDataImpl implements R
*
* @param df the degrees of freedom of the ChiSquare distribution
* @return random value sampled from the ChiSquare(df) distribution
- * @throws MathException if an error occurs generating the random value
* @since 2.2
*/
- public double nextChiSquare(double df) throws MathException {
+ public double nextChiSquare(double df) {
return nextInversionDeviate(new ChiSquaredDistributionImpl(df));
}
@@ -666,10 +661,9 @@ public class RandomDataImpl implements R
* @param numeratorDf the numerator degrees of freedom of the F distribution
* @param denominatorDf the denominator degrees of freedom of the F distribution
* @return random value sampled from the F(numeratorDf, denominatorDf) distribution
- * @throws MathException if an error occurs generating the random value
* @since 2.2
*/
- public double nextF(double numeratorDf, double denominatorDf) throws MathException {
+ public double nextF(double numeratorDf, double denominatorDf) {
return nextInversionDeviate(new FDistributionImpl(numeratorDf, denominatorDf));
}
@@ -692,10 +686,9 @@ public class RandomDataImpl implements R
* @param shape the median of the Gamma distribution
* @param scale the scale parameter of the Gamma distribution
* @return random value sampled from the Gamma(shape, scale) distribution
- * @throws MathException if an error occurs generating the random value
* @since 2.2
*/
- public double nextGamma(double shape, double scale) throws MathException {
+ public double nextGamma(double shape, double scale) {
if (shape < 1) {
// [1]: p. 228, Algorithm GS
@@ -770,10 +763,9 @@ public class RandomDataImpl implements R
* @param numberOfSuccesses number of successes in the population of the Hypergeometric distribution
* @param sampleSize the sample size of the Hypergeometric distribution
* @return random value sampled from the Hypergeometric(numberOfSuccesses, sampleSize) distribution
- * @throws MathException if an error occurs generating the random value
* @since 2.2
*/
- public int nextHypergeometric(int populationSize, int numberOfSuccesses, int sampleSize) throws MathException {
+ public int nextHypergeometric(int populationSize, int numberOfSuccesses, int sampleSize) {
return nextInversionDeviate(new HypergeometricDistributionImpl(populationSize, numberOfSuccesses, sampleSize));
}
@@ -785,10 +777,9 @@ public class RandomDataImpl implements R
* @param r the number of successes of the Pascal distribution
* @param p the probability of success of the Pascal distribution
* @return random value sampled from the Pascal(r, p) distribution
- * @throws MathException if an error occurs generating the random value
* @since 2.2
*/
- public int nextPascal(int r, double p) throws MathException {
+ public int nextPascal(int r, double p) {
return nextInversionDeviate(new PascalDistributionImpl(r, p));
}
@@ -799,10 +790,9 @@ public class RandomDataImpl implements R
*
* @param df the degrees of freedom of the T distribution
* @return random value from the T(df) distribution
- * @throws MathException if an error occurs generating the random value
* @since 2.2
*/
- public double nextT(double df) throws MathException {
+ public double nextT(double df) {
return nextInversionDeviate(new TDistributionImpl(df));
}
@@ -814,10 +804,9 @@ public class RandomDataImpl implements R
* @param shape the shape parameter of the Weibull distribution
* @param scale the scale parameter of the Weibull distribution
* @return random value sampled from the Weibull(shape, size) distribution
- * @throws MathException if an error occurs generating the random value
* @since 2.2
*/
- public double nextWeibull(double shape, double scale) throws MathException {
+ public double nextWeibull(double shape, double scale) {
return nextInversionDeviate(new WeibullDistributionImpl(shape, scale));
}
@@ -829,10 +818,9 @@ public class RandomDataImpl implements R
* @param numberOfElements the number of elements of the ZipfDistribution
* @param exponent the exponent of the ZipfDistribution
* @return random value sampled from the Zipf(numberOfElements, exponent) distribution
- * @throws MathException if an error occurs generating the random value
* @since 2.2
*/
- public int nextZipf(int numberOfElements, double exponent) throws MathException {
+ public int nextZipf(int numberOfElements, double exponent) {
return nextInversionDeviate(new ZipfDistributionImpl(numberOfElements, exponent));
}
@@ -1044,10 +1032,9 @@ public class RandomDataImpl implements R
*
* @param distribution Continuous distribution to generate a random value from
* @return a random value sampled from the given distribution
- * @throws MathException if an error occurs computing the inverse cumulative distribution function
* @since 2.2
*/
- public double nextInversionDeviate(ContinuousDistribution distribution) throws MathException {
+ public double nextInversionDeviate(ContinuousDistribution distribution) {
return distribution.inverseCumulativeProbability(nextUniform(0, 1));
}
@@ -1058,10 +1045,9 @@ public class RandomDataImpl implements R
*
* @param distribution Integer distribution to generate a random value from
* @return a random value sampled from the given distribution
- * @throws MathException if an error occurs computing the inverse cumulative distribution function
* @since 2.2
*/
- public int nextInversionDeviate(IntegerDistribution distribution) throws MathException {
+ public int nextInversionDeviate(IntegerDistribution distribution) {
final double target = nextUniform(0, 1);
final int glb = distribution.inverseCumulativeProbability(target);
if (distribution.cumulativeProbability(glb) == 1.0d) { // No mass above
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/AbtractIntegerDistributionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/AbtractIntegerDistributionTest.java?rev=1178295&r1=1178294&r2=1178295&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/AbtractIntegerDistributionTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/AbtractIntegerDistributionTest.java Mon Oct 3 04:36:27 2011
@@ -17,7 +17,6 @@
package org.apache.commons.math.distribution;
-import org.apache.commons.math.MathException;
import org.junit.Assert;
import org.junit.Test;
@@ -128,7 +127,7 @@ public class AbtractIntegerDistributionT
}
@Override
- public double cumulativeProbability(int x) throws MathException {
+ public double cumulativeProbability(int x) {
if (x < 1) {
return 0;
} else if (x >= 6) {
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/PoissonDistributionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/PoissonDistributionTest.java?rev=1178295&r1=1178294&r2=1178295&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/PoissonDistributionTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/PoissonDistributionTest.java Mon Oct 3 04:36:27 2011
@@ -16,7 +16,6 @@
*/
package org.apache.commons.math.distribution;
-import org.apache.commons.math.MathException;
import org.apache.commons.math.util.FastMath;
import org.apache.commons.math.exception.NotStrictlyPositiveException;
import org.junit.Assert;
@@ -169,7 +168,7 @@ public class PoissonDistributionTest ext
Assert.assertTrue("Zero cum probaility returned for mean = " +
mean + " x = " + x, p > 0);
}
- } catch (MathException ex) {
+ } catch (Exception ex) {
Assert.fail("mean of " + mean + " and x of " + x + " caused " + ex.getMessage());
}
x -= dx;
@@ -216,7 +215,7 @@ public class PoissonDistributionTest ext
// Verify that returned value satisties definition
Assert.assertTrue(p >= dist.cumulativeProbability(ret));
Assert.assertTrue(p < dist.cumulativeProbability(ret + 1));
- } catch (MathException ex) {
+ } catch (Exception ex) {
Assert.fail("mean of " + mean + " and p of " + p + " caused " + ex.getMessage());
}
p += dp;