mirror of
https://github.com/apache/commons-math.git
synced 2025-02-07 10:38:55 +00:00
Eliminated MathException from distribution interfaces and impls.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1178295 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0cf21a482b
commit
2568420bf6
@ -18,9 +18,9 @@ package org.apache.commons.math.distribution;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import org.apache.commons.math.MathException;
|
|
||||||
import org.apache.commons.math.analysis.UnivariateRealFunction;
|
import org.apache.commons.math.analysis.UnivariateRealFunction;
|
||||||
import org.apache.commons.math.analysis.solvers.UnivariateRealSolverUtils;
|
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.NotStrictlyPositiveException;
|
||||||
import org.apache.commons.math.exception.OutOfRangeException;
|
import org.apache.commons.math.exception.OutOfRangeException;
|
||||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||||
@ -69,13 +69,9 @@ public abstract class AbstractContinuousDistribution
|
|||||||
*
|
*
|
||||||
* @param p Desired probability.
|
* @param p Desired probability.
|
||||||
* @return {@code x}, such that {@code P(X < x) = p}.
|
* @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.
|
* @throws OutOfRangeException if {@code p} is not a valid probability.
|
||||||
*/
|
*/
|
||||||
public double inverseCumulativeProbability(final double p)
|
public double inverseCumulativeProbability(final double p) {
|
||||||
throws MathException {
|
|
||||||
try {
|
|
||||||
|
|
||||||
if (p < 0.0 || p > 1.0) {
|
if (p < 0.0 || p > 1.0) {
|
||||||
throw new OutOfRangeException(p, 0, 1);
|
throw new OutOfRangeException(p, 0, 1);
|
||||||
@ -86,16 +82,7 @@ public abstract class AbstractContinuousDistribution
|
|||||||
UnivariateRealFunction rootFindingFunction =
|
UnivariateRealFunction rootFindingFunction =
|
||||||
new UnivariateRealFunction() {
|
new UnivariateRealFunction() {
|
||||||
public double value(double x) {
|
public double value(double x) {
|
||||||
double ret = Double.NaN;
|
return cumulativeProbability(x) - p;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -120,7 +107,7 @@ public abstract class AbstractContinuousDistribution
|
|||||||
return upperBound;
|
return upperBound;
|
||||||
}
|
}
|
||||||
// Failed bracket convergence was not because of corner solution
|
// Failed bracket convergence was not because of corner solution
|
||||||
throw new MathException(ex);
|
throw new MathInternalError(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// find root
|
// find root
|
||||||
@ -129,35 +116,6 @@ public abstract class AbstractContinuousDistribution
|
|||||||
// absolute accuracy different from the default.
|
// absolute accuracy different from the default.
|
||||||
bracket[0],bracket[1], getSolverAbsoluteAccuracy());
|
bracket[0],bracket[1], getSolverAbsoluteAccuracy());
|
||||||
return root;
|
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 AbstractContinuousDistribution
|
|||||||
* </a>
|
* </a>
|
||||||
*
|
*
|
||||||
* @return a random value.
|
* @return a random value.
|
||||||
* @throws MathException if an error occurs generating the random value.
|
|
||||||
* @since 2.2
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
public double sample() throws MathException {
|
public double sample() {
|
||||||
return randomData.nextInversionDeviate(this);
|
return randomData.nextInversionDeviate(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,11 +148,10 @@ public abstract class AbstractContinuousDistribution
|
|||||||
*
|
*
|
||||||
* @param sampleSize Number of random values to generate.
|
* @param sampleSize Number of random values to generate.
|
||||||
* @return an array representing the random sample.
|
* @return an array representing the random sample.
|
||||||
* @throws MathException if an error occurs generating the sample.
|
|
||||||
* @throws NotStrictlyPositiveException if {@code sampleSize} is not positive.
|
* @throws NotStrictlyPositiveException if {@code sampleSize} is not positive.
|
||||||
* @since 2.2
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
public double[] sample(int sampleSize) throws MathException {
|
public double[] sample(int sampleSize) {
|
||||||
if (sampleSize <= 0) {
|
if (sampleSize <= 0) {
|
||||||
throw new NotStrictlyPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES,
|
throw new NotStrictlyPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES,
|
||||||
sampleSize);
|
sampleSize);
|
||||||
|
@ -18,7 +18,6 @@ package org.apache.commons.math.distribution;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import org.apache.commons.math.MathException;
|
|
||||||
import org.apache.commons.math.exception.NumberIsTooLargeException;
|
import org.apache.commons.math.exception.NumberIsTooLargeException;
|
||||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||||
|
|
||||||
@ -65,12 +64,9 @@ public abstract class AbstractDistribution
|
|||||||
* @return the probability that a random variable with this distribution
|
* @return the probability that a random variable with this distribution
|
||||||
* will take a value between {@code x0} and {@code x1},
|
* will take a value between {@code x0} and {@code x1},
|
||||||
* including the endpoints.
|
* 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}
|
* @throws NumberIsTooLargeException if {@code x0 > x1}
|
||||||
*/
|
*/
|
||||||
public double cumulativeProbability(double x0, double x1)
|
public double cumulativeProbability(double x0, double x1) {
|
||||||
throws MathException {
|
|
||||||
if (x0 > x1) {
|
if (x0 > x1) {
|
||||||
throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT,
|
throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT,
|
||||||
x0, x1, true);
|
x0, x1, true);
|
||||||
|
@ -18,7 +18,7 @@ package org.apache.commons.math.distribution;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
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.NotStrictlyPositiveException;
|
||||||
import org.apache.commons.math.exception.NumberIsTooSmallException;
|
import org.apache.commons.math.exception.NumberIsTooSmallException;
|
||||||
import org.apache.commons.math.exception.OutOfRangeException;
|
import org.apache.commons.math.exception.OutOfRangeException;
|
||||||
@ -60,10 +60,8 @@ public abstract class AbstractIntegerDistribution extends AbstractDistribution
|
|||||||
* @param x Value at which the distribution function is evaluated.
|
* @param x Value at which the distribution function is evaluated.
|
||||||
* @return the cumulative probability that a random variable with this
|
* @return the cumulative probability that a random variable with this
|
||||||
* distribution takes a value less than or equal to {@code x}.
|
* 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));
|
return cumulativeProbability((int) FastMath.floor(x));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,13 +75,10 @@ public abstract class AbstractIntegerDistribution extends AbstractDistribution
|
|||||||
* @return the probability that a random variable with this distribution
|
* @return the probability that a random variable with this distribution
|
||||||
* will take a value between {@code x0} and {@code x1},
|
* will take a value between {@code x0} and {@code x1},
|
||||||
* including the endpoints.
|
* 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}.
|
* @throws NumberIsTooSmallException if {@code x1 > x0}.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public double cumulativeProbability(double x0, double x1)
|
public double cumulativeProbability(double x0, double x1) {
|
||||||
throws MathException {
|
|
||||||
if (x1 < x0) {
|
if (x1 < x0) {
|
||||||
throw new NumberIsTooSmallException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT,
|
throw new NumberIsTooSmallException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT,
|
||||||
x1, x0, true);
|
x1, x0, true);
|
||||||
@ -105,10 +100,8 @@ public abstract class AbstractIntegerDistribution extends AbstractDistribution
|
|||||||
*
|
*
|
||||||
* @param x Value at which the PDF is evaluated.
|
* @param x Value at which the PDF is evaluated.
|
||||||
* @return PDF for this distribution.
|
* @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
|
* For a random variable {@code X} whose values are distributed according
|
||||||
@ -136,11 +129,9 @@ public abstract class AbstractIntegerDistribution extends AbstractDistribution
|
|||||||
* @param x0 Inclusive lower bound.
|
* @param x0 Inclusive lower bound.
|
||||||
* @param x1 Inclusive upper bound.
|
* @param x1 Inclusive upper bound.
|
||||||
* @return the cumulative probability.
|
* @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}.
|
* @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) {
|
if (x1 < x0) {
|
||||||
throw new NumberIsTooSmallException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT,
|
throw new NumberIsTooSmallException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT,
|
||||||
x1, x0, true);
|
x1, x0, true);
|
||||||
@ -155,11 +146,9 @@ public abstract class AbstractIntegerDistribution extends AbstractDistribution
|
|||||||
*
|
*
|
||||||
* @param p Desired probability.
|
* @param p Desired probability.
|
||||||
* @return the largest {@code x} such that {@code P(X < x) <= p}.
|
* @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}.
|
* @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) {
|
if (p < 0 || p > 1) {
|
||||||
throw new OutOfRangeException(p, 0, 1);
|
throw new OutOfRangeException(p, 0, 1);
|
||||||
}
|
}
|
||||||
@ -221,9 +210,8 @@ public abstract class AbstractIntegerDistribution extends AbstractDistribution
|
|||||||
*
|
*
|
||||||
* @return a random value.
|
* @return a random value.
|
||||||
* @since 2.2
|
* @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);
|
return randomData.nextInversionDeviate(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,10 +223,9 @@ public abstract class AbstractIntegerDistribution extends AbstractDistribution
|
|||||||
* @param sampleSize number of random values to generate.
|
* @param sampleSize number of random values to generate.
|
||||||
* @since 2.2
|
* @since 2.2
|
||||||
* @return an array representing the random sample.
|
* @return an array representing the random sample.
|
||||||
* @throws MathException if an error occurs generating the sample.
|
|
||||||
* @throws NotStrictlyPositiveException if {@code sampleSize <= 0}.
|
* @throws NotStrictlyPositiveException if {@code sampleSize <= 0}.
|
||||||
*/
|
*/
|
||||||
public int[] sample(int sampleSize) throws MathException {
|
public int[] sample(int sampleSize) {
|
||||||
if (sampleSize <= 0) {
|
if (sampleSize <= 0) {
|
||||||
throw new NotStrictlyPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES,
|
throw new NotStrictlyPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES,
|
||||||
sampleSize);
|
sampleSize);
|
||||||
@ -253,20 +240,21 @@ public abstract class AbstractIntegerDistribution extends AbstractDistribution
|
|||||||
/**
|
/**
|
||||||
* Computes the cumulative probability function and checks for NaN
|
* Computes the cumulative probability function and checks for NaN
|
||||||
* values returned.
|
* 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
|
* 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.
|
* @param argument Input value.
|
||||||
* @return the cumulative probability.
|
* @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)
|
private double checkedCumulativeProbability(int argument)
|
||||||
throws MathException {
|
throws MathInternalError {
|
||||||
double result = Double.NaN;
|
double result = Double.NaN;
|
||||||
result = cumulativeProbability(argument);
|
result = cumulativeProbability(argument);
|
||||||
if (Double.isNaN(result)) {
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.commons.math.distribution;
|
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.NumberIsTooSmallException;
|
||||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||||
import org.apache.commons.math.special.Gamma;
|
import org.apache.commons.math.special.Gamma;
|
||||||
@ -128,7 +127,7 @@ public class BetaDistributionImpl
|
|||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public double inverseCumulativeProbability(double p) throws MathException {
|
public double inverseCumulativeProbability(double p) {
|
||||||
if (p == 0) {
|
if (p == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
} else if (p == 1) {
|
} else if (p == 1) {
|
||||||
@ -157,7 +156,7 @@ public class BetaDistributionImpl
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
public double cumulativeProbability(double x) throws MathException {
|
public double cumulativeProbability(double x) {
|
||||||
if (x <= 0) {
|
if (x <= 0) {
|
||||||
return 0;
|
return 0;
|
||||||
} else if (x >= 1) {
|
} else if (x >= 1) {
|
||||||
@ -169,7 +168,7 @@ public class BetaDistributionImpl
|
|||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public double cumulativeProbability(double x0, double x1) throws MathException {
|
public double cumulativeProbability(double x0, double x1) {
|
||||||
return cumulativeProbability(x1) - cumulativeProbability(x0);
|
return cumulativeProbability(x1) - cumulativeProbability(x0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@ package org.apache.commons.math.distribution;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import org.apache.commons.math.MathException;
|
|
||||||
import org.apache.commons.math.exception.OutOfRangeException;
|
import org.apache.commons.math.exception.OutOfRangeException;
|
||||||
import org.apache.commons.math.exception.NotPositiveException;
|
import org.apache.commons.math.exception.NotPositiveException;
|
||||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||||
@ -104,11 +103,10 @@ public class BinomialDistributionImpl extends AbstractIntegerDistribution
|
|||||||
*
|
*
|
||||||
* @param x Value at which the PDF is evaluated.
|
* @param x Value at which the PDF is evaluated.
|
||||||
* @return PDF for this distribution.
|
* @return PDF for this distribution.
|
||||||
* @throws MathException if the cumulative probability can not be computed
|
|
||||||
* due to convergence or other numerical errors.
|
* due to convergence or other numerical errors.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public double cumulativeProbability(int x) throws MathException {
|
public double cumulativeProbability(int x) {
|
||||||
double ret;
|
double ret;
|
||||||
if (x < 0) {
|
if (x < 0) {
|
||||||
ret = 0.0;
|
ret = 0.0;
|
||||||
@ -146,13 +144,10 @@ public class BinomialDistributionImpl extends AbstractIntegerDistribution
|
|||||||
*
|
*
|
||||||
* @param p Desired probability.
|
* @param p Desired probability.
|
||||||
* @return the largest {@code x} such that {@code P(X < x) <= p}.
|
* @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}.
|
* @throws OutOfRangeException if {@code p < 0} or {@code p > 1}.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int inverseCumulativeProbability(final double p)
|
public int inverseCumulativeProbability(final double p) {
|
||||||
throws MathException {
|
|
||||||
// handle extreme values explicitly
|
// handle extreme values explicitly
|
||||||
if (p == 0) {
|
if (p == 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -18,7 +18,6 @@ package org.apache.commons.math.distribution;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import org.apache.commons.math.MathException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default implementation of {@link ChiSquaredDistribution}
|
* The default implementation of {@link ChiSquaredDistribution}
|
||||||
@ -85,10 +84,8 @@ public class ChiSquaredDistributionImpl
|
|||||||
*
|
*
|
||||||
* @param x the value at which the CDF is evaluated.
|
* @param x the value at which the CDF is evaluated.
|
||||||
* @return CDF for this distribution.
|
* @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);
|
return gamma.cumulativeProbability(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,14 +97,11 @@ public class ChiSquaredDistributionImpl
|
|||||||
*
|
*
|
||||||
* @param p Desired probability.
|
* @param p Desired probability.
|
||||||
* @return {@code x}, such that {@code P(X < x) = p}.
|
* @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
|
* @throws org.apache.commons.math.exception.OutOfRangeException if
|
||||||
* {@code p} is not a valid probability.
|
* {@code p} is not a valid probability.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public double inverseCumulativeProbability(final double p)
|
public double inverseCumulativeProbability(final double p) {
|
||||||
throws MathException {
|
|
||||||
if (p == 0) {
|
if (p == 0) {
|
||||||
return 0d;
|
return 0d;
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.commons.math.distribution;
|
package org.apache.commons.math.distribution;
|
||||||
|
|
||||||
import org.apache.commons.math.MathException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base interface for continuous distributions.
|
* Base interface for continuous distributions.
|
||||||
*
|
*
|
||||||
@ -30,10 +28,8 @@ public interface ContinuousDistribution extends Distribution {
|
|||||||
*
|
*
|
||||||
* @param p Cumulative probability.
|
* @param p Cumulative probability.
|
||||||
* @return {@code x} such that {@code P(X < x) = p}.
|
* @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.
|
* Probability density for a particular point.
|
||||||
@ -55,20 +51,18 @@ public interface ContinuousDistribution extends Distribution {
|
|||||||
* Generate a random value sampled from this distribution.
|
* Generate a random value sampled from this distribution.
|
||||||
*
|
*
|
||||||
* @return a random value.
|
* @return a random value.
|
||||||
* @throws MathException if an error occurs generating the random value.
|
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
double sample() throws MathException;
|
double sample();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a random sample from the distribution.
|
* Generate a random sample from the distribution.
|
||||||
*
|
*
|
||||||
* @param sampleSize number of random values to generate.
|
* @param sampleSize number of random values to generate.
|
||||||
* @return an array representing the random sample.
|
* @return an array representing the random sample.
|
||||||
* @throws MathException if an error occurs generating the sample.
|
|
||||||
* @throws org.apache.commons.math.exception.NotStrictlyPositiveException
|
* @throws org.apache.commons.math.exception.NotStrictlyPositiveException
|
||||||
* if {@code sampleSize} is not positive.
|
* if {@code sampleSize} is not positive.
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
double[] sample(int sampleSize) throws MathException;
|
double[] sample(int sampleSize);
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.commons.math.distribution;
|
package org.apache.commons.math.distribution;
|
||||||
|
|
||||||
import org.apache.commons.math.MathException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base interface for probability distributions.
|
* Base interface for probability distributions.
|
||||||
*
|
*
|
||||||
@ -33,10 +31,8 @@ public interface Distribution {
|
|||||||
* @param x the value at which the distribution function is evaluated.
|
* @param x the value at which the distribution function is evaluated.
|
||||||
* @return the probability that a random variable with this
|
* @return the probability that a random variable with this
|
||||||
* distribution takes a value less than or equal to <code>x</code>
|
* 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
|
* 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
|
* @return the probability that a random variable with this distribution
|
||||||
* will take a value between <code>x0</code> and <code>x1</code>,
|
* will take a value between <code>x0</code> and <code>x1</code>,
|
||||||
* including the endpoints
|
* 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>
|
* @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
|
* Use this method to get the numerical value of the mean of this
|
||||||
|
@ -18,7 +18,6 @@ package org.apache.commons.math.distribution;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import org.apache.commons.math.MathException;
|
|
||||||
import org.apache.commons.math.exception.NotStrictlyPositiveException;
|
import org.apache.commons.math.exception.NotStrictlyPositiveException;
|
||||||
import org.apache.commons.math.exception.OutOfRangeException;
|
import org.apache.commons.math.exception.OutOfRangeException;
|
||||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||||
@ -99,10 +98,8 @@ public class ExponentialDistributionImpl extends AbstractContinuousDistribution
|
|||||||
*
|
*
|
||||||
* @param x Value at which the CDF is evaluated.
|
* @param x Value at which the CDF is evaluated.
|
||||||
* @return the CDF for this distribution.
|
* @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;
|
double ret;
|
||||||
if (x <= 0.0) {
|
if (x <= 0.0) {
|
||||||
ret = 0.0;
|
ret = 0.0;
|
||||||
@ -120,12 +117,10 @@ public class ExponentialDistributionImpl extends AbstractContinuousDistribution
|
|||||||
*
|
*
|
||||||
* @param p Desired probability.
|
* @param p Desired probability.
|
||||||
* @return {@code x}, such that {@code P(X < x) = p}.
|
* @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}.
|
* @throws OutOfRangeException if {@code p < 0} or {@code p > 1}.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public double inverseCumulativeProbability(double p) throws MathException {
|
public double inverseCumulativeProbability(double p) {
|
||||||
double ret;
|
double ret;
|
||||||
|
|
||||||
if (p < 0.0 || p > 1.0) {
|
if (p < 0.0 || p > 1.0) {
|
||||||
@ -148,11 +143,10 @@ public class ExponentialDistributionImpl extends AbstractContinuousDistribution
|
|||||||
* uniform deviates.</p>
|
* uniform deviates.</p>
|
||||||
*
|
*
|
||||||
* @return a random value.
|
* @return a random value.
|
||||||
* @throws MathException if an error occurs generating the random value.
|
|
||||||
* @since 2.2
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public double sample() throws MathException {
|
public double sample() {
|
||||||
return randomData.nextExponential(mean);
|
return randomData.nextExponential(mean);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ package org.apache.commons.math.distribution;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import org.apache.commons.math.MathException;
|
|
||||||
import org.apache.commons.math.exception.NotStrictlyPositiveException;
|
import org.apache.commons.math.exception.NotStrictlyPositiveException;
|
||||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||||
import org.apache.commons.math.special.Beta;
|
import org.apache.commons.math.special.Beta;
|
||||||
@ -123,10 +122,8 @@ public class FDistributionImpl
|
|||||||
*
|
*
|
||||||
* @param x Value at which the CDF is evaluated.
|
* @param x Value at which the CDF is evaluated.
|
||||||
* @return CDF for this distribution.
|
* @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;
|
double ret;
|
||||||
if (x <= 0) {
|
if (x <= 0) {
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@ -148,14 +145,11 @@ public class FDistributionImpl
|
|||||||
*
|
*
|
||||||
* @param p Desired probability.
|
* @param p Desired probability.
|
||||||
* @return {@code x}, such that {@code P(X < x) = p}.
|
* @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
|
* @throws IllegalArgumentException if {@code p} is not a valid
|
||||||
* probability.
|
* probability.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public double inverseCumulativeProbability(final double p)
|
public double inverseCumulativeProbability(final double p) {
|
||||||
throws MathException {
|
|
||||||
if (p == 0) {
|
if (p == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ package org.apache.commons.math.distribution;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import org.apache.commons.math.MathException;
|
|
||||||
import org.apache.commons.math.exception.NotStrictlyPositiveException;
|
import org.apache.commons.math.exception.NotStrictlyPositiveException;
|
||||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||||
import org.apache.commons.math.special.Gamma;
|
import org.apache.commons.math.special.Gamma;
|
||||||
@ -95,10 +94,8 @@ public class GammaDistributionImpl extends AbstractContinuousDistribution
|
|||||||
*
|
*
|
||||||
* @param x Value at which the CDF is evaluated.
|
* @param x Value at which the CDF is evaluated.
|
||||||
* @return CDF for this distribution.
|
* @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;
|
double ret;
|
||||||
|
|
||||||
if (x <= 0) {
|
if (x <= 0) {
|
||||||
@ -118,14 +115,11 @@ public class GammaDistributionImpl extends AbstractContinuousDistribution
|
|||||||
*
|
*
|
||||||
* @param p Desired probability.
|
* @param p Desired probability.
|
||||||
* @return {@code x}, such that {@code P(X < x) = p}.
|
* @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
|
* @throws org.apache.commons.math.exception.OutOfRangeException if
|
||||||
* {@code p} is not a valid probability.
|
* {@code p} is not a valid probability.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public double inverseCumulativeProbability(final double p)
|
public double inverseCumulativeProbability(final double p) {
|
||||||
throws MathException {
|
|
||||||
if (p == 0) {
|
if (p == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.commons.math.distribution;
|
package org.apache.commons.math.distribution;
|
||||||
|
|
||||||
import org.apache.commons.math.MathException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for discrete distributions of integer-valued random variables.
|
* Interface for discrete distributions of integer-valued random variables.
|
||||||
*
|
*
|
||||||
@ -43,10 +41,8 @@ public interface IntegerDistribution extends DiscreteDistribution {
|
|||||||
*
|
*
|
||||||
* @param x Value at which the PDF is evaluated.
|
* @param x Value at which the PDF is evaluated.
|
||||||
* @return PDF for this distribution.
|
* @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
|
* For this distribution, {@code X}, this method returns
|
||||||
@ -55,11 +51,9 @@ public interface IntegerDistribution extends DiscreteDistribution {
|
|||||||
* @param x0 the inclusive, lower bound
|
* @param x0 the inclusive, lower bound
|
||||||
* @param x1 the inclusive, upper bound
|
* @param x1 the inclusive, upper bound
|
||||||
* @return the cumulative probability.
|
* @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}.
|
* @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
|
* For this distribution, {@code X}, this method returns the largest
|
||||||
@ -82,12 +76,10 @@ public interface IntegerDistribution extends DiscreteDistribution {
|
|||||||
*
|
*
|
||||||
* @param p Cumulative probability.
|
* @param p Cumulative probability.
|
||||||
* @return the largest {@code x} such that {@code P(X < x) <= p}.
|
* @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
|
* @throws IllegalArgumentException if {@code p} is not between 0 and 1
|
||||||
* (inclusive).
|
* (inclusive).
|
||||||
*/
|
*/
|
||||||
int inverseCumulativeProbability(double p) throws MathException;
|
int inverseCumulativeProbability(double p);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reseed the random generator used to generate samples.
|
* Reseed the random generator used to generate samples.
|
||||||
@ -101,20 +93,18 @@ public interface IntegerDistribution extends DiscreteDistribution {
|
|||||||
* Generate a random value sampled from this distribution.
|
* Generate a random value sampled from this distribution.
|
||||||
*
|
*
|
||||||
* @return a random value.
|
* @return a random value.
|
||||||
* @throws MathException if an error occurs generating the random value.
|
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
int sample() throws MathException;
|
int sample();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a random sample from the distribution.
|
* Generate a random sample from the distribution.
|
||||||
*
|
*
|
||||||
* @param sampleSize number of random values to generate.
|
* @param sampleSize number of random values to generate.
|
||||||
* @return an array representing the random sample.
|
* @return an array representing the random sample.
|
||||||
* @throws MathException if an error occurs generating the sample.
|
|
||||||
* @throws org.apache.commons.math.exception.NotStrictlyPositiveException
|
* @throws org.apache.commons.math.exception.NotStrictlyPositiveException
|
||||||
* if {@code sampleSize} is not positive.
|
* if {@code sampleSize} is not positive.
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
int[] sample(int sampleSize) throws MathException;
|
int[] sample(int sampleSize);
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ package org.apache.commons.math.distribution;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import org.apache.commons.math.MathException;
|
|
||||||
import org.apache.commons.math.exception.NotStrictlyPositiveException;
|
import org.apache.commons.math.exception.NotStrictlyPositiveException;
|
||||||
import org.apache.commons.math.exception.NumberIsTooLargeException;
|
import org.apache.commons.math.exception.NumberIsTooLargeException;
|
||||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||||
@ -121,9 +120,8 @@ public class NormalDistributionImpl extends AbstractContinuousDistribution
|
|||||||
*
|
*
|
||||||
* @param x Value at which the CDF is evaluated.
|
* @param x Value at which the CDF is evaluated.
|
||||||
* @return CDF evaluated at {@code x}.
|
* @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;
|
final double dev = x - mean;
|
||||||
if (FastMath.abs(dev) > 40 * standardDeviation) {
|
if (FastMath.abs(dev) > 40 * standardDeviation) {
|
||||||
return dev < 0 ? 0.0d : 1.0d;
|
return dev < 0 ? 0.0d : 1.0d;
|
||||||
@ -135,7 +133,7 @@ public class NormalDistributionImpl extends AbstractContinuousDistribution
|
|||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public double cumulativeProbability(double x0, double x1) throws MathException {
|
public double cumulativeProbability(double x0, double x1) {
|
||||||
if (x0 > x1) {
|
if (x0 > x1) {
|
||||||
throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT,
|
throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT,
|
||||||
x0, x1, true);
|
x0, x1, true);
|
||||||
@ -166,14 +164,12 @@ public class NormalDistributionImpl extends AbstractContinuousDistribution
|
|||||||
*
|
*
|
||||||
* @param p Desired probability.
|
* @param p Desired probability.
|
||||||
* @return {@code x}, such that {@code P(X < x) = p}.
|
* @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
|
* @throws org.apache.commons.math.exception.OutOfRangeException if
|
||||||
* {@code p} is not a valid probability.
|
* {@code p} is not a valid probability.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public double inverseCumulativeProbability(final double p)
|
public double inverseCumulativeProbability(final double p)
|
||||||
throws MathException {
|
{
|
||||||
if (p == 0) {
|
if (p == 0) {
|
||||||
return Double.NEGATIVE_INFINITY;
|
return Double.NEGATIVE_INFINITY;
|
||||||
}
|
}
|
||||||
@ -188,10 +184,9 @@ public class NormalDistributionImpl extends AbstractContinuousDistribution
|
|||||||
*
|
*
|
||||||
* @return a random value.
|
* @return a random value.
|
||||||
* @since 2.2
|
* @since 2.2
|
||||||
* @throws MathException if an error occurs generating the random value.
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public double sample() throws MathException {
|
public double sample() {
|
||||||
return randomData.nextGaussian(mean, standardDeviation);
|
return randomData.nextGaussian(mean, standardDeviation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@ package org.apache.commons.math.distribution;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import org.apache.commons.math.MathException;
|
|
||||||
import org.apache.commons.math.exception.OutOfRangeException;
|
import org.apache.commons.math.exception.OutOfRangeException;
|
||||||
import org.apache.commons.math.exception.NotPositiveException;
|
import org.apache.commons.math.exception.NotPositiveException;
|
||||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||||
@ -104,11 +103,10 @@ public class PascalDistributionImpl extends AbstractIntegerDistribution
|
|||||||
*
|
*
|
||||||
* @param x Value at which the PDF is evaluated.
|
* @param x Value at which the PDF is evaluated.
|
||||||
* @return PDF for this distribution.
|
* @return PDF for this distribution.
|
||||||
* @throws MathException if the cumulative probability can not be computed
|
|
||||||
* due to convergence or other numerical errors.
|
* due to convergence or other numerical errors.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public double cumulativeProbability(int x) throws MathException {
|
public double cumulativeProbability(int x) {
|
||||||
double ret;
|
double ret;
|
||||||
if (x < 0) {
|
if (x < 0) {
|
||||||
ret = 0.0;
|
ret = 0.0;
|
||||||
@ -145,13 +143,10 @@ public class PascalDistributionImpl extends AbstractIntegerDistribution
|
|||||||
*
|
*
|
||||||
* @param p Desired probability.
|
* @param p Desired probability.
|
||||||
* @return the largest {@code x} such that {@code P(X <= x) <= p}.
|
* @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}.
|
* @throws OutOfRangeException if {@code p < 0} or {@code p > 1}.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int inverseCumulativeProbability(final double p)
|
public int inverseCumulativeProbability(final double p) {
|
||||||
throws MathException {
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
// handle extreme values explicitly
|
// handle extreme values explicitly
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.commons.math.distribution;
|
package org.apache.commons.math.distribution;
|
||||||
|
|
||||||
import org.apache.commons.math.MathException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface representing the Poisson Distribution.
|
* Interface representing the Poisson Distribution.
|
||||||
@ -44,7 +43,6 @@ public interface PoissonDistribution extends IntegerDistribution {
|
|||||||
*
|
*
|
||||||
* @param x the upper bound, inclusive
|
* @param x the upper bound, inclusive
|
||||||
* @return the distribution function value calculated using a normal approximation
|
* @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) ;
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ package org.apache.commons.math.distribution;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import org.apache.commons.math.MathException;
|
|
||||||
import org.apache.commons.math.exception.NotStrictlyPositiveException;
|
import org.apache.commons.math.exception.NotStrictlyPositiveException;
|
||||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||||
import org.apache.commons.math.special.Gamma;
|
import org.apache.commons.math.special.Gamma;
|
||||||
@ -146,11 +145,10 @@ public class PoissonDistributionImpl extends AbstractIntegerDistribution
|
|||||||
*
|
*
|
||||||
* @param x Value at which the PDF is evaluated.
|
* @param x Value at which the PDF is evaluated.
|
||||||
* @return the Poisson distribution function evaluated at {@code x}.
|
* @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.
|
* due to convergence or other numerical errors.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public double cumulativeProbability(int x) throws MathException {
|
public double cumulativeProbability(int x) {
|
||||||
if (x < 0) {
|
if (x < 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -170,10 +168,9 @@ public class PoissonDistributionImpl extends AbstractIntegerDistribution
|
|||||||
* @param x Upper bound, inclusive.
|
* @param x Upper bound, inclusive.
|
||||||
* @return the distribution function value calculated using a normal
|
* @return the distribution function value calculated using a normal
|
||||||
* approximation.
|
* approximation.
|
||||||
* @throws MathException if an error occurs computing the normal
|
|
||||||
* approximation.
|
* approximation.
|
||||||
*/
|
*/
|
||||||
public double normalApproximateProbability(int x) throws MathException {
|
public double normalApproximateProbability(int x) {
|
||||||
// calculate the probability using half-correction
|
// calculate the probability using half-correction
|
||||||
return normal.cumulativeProbability(x + 0.5);
|
return normal.cumulativeProbability(x + 0.5);
|
||||||
}
|
}
|
||||||
@ -198,10 +195,9 @@ public class PoissonDistributionImpl extends AbstractIntegerDistribution
|
|||||||
*
|
*
|
||||||
* @return a random value.
|
* @return a random value.
|
||||||
* @since 2.2
|
* @since 2.2
|
||||||
* @throws MathException if an error occurs generating the random value.
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int sample() throws MathException {
|
public int sample() {
|
||||||
return (int) FastMath.min(randomData.nextPoisson(mean), Integer.MAX_VALUE);
|
return (int) FastMath.min(randomData.nextPoisson(mean), Integer.MAX_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@ package org.apache.commons.math.distribution;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import org.apache.commons.math.MathException;
|
|
||||||
import org.apache.commons.math.exception.NotStrictlyPositiveException;
|
import org.apache.commons.math.exception.NotStrictlyPositiveException;
|
||||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||||
import org.apache.commons.math.special.Beta;
|
import org.apache.commons.math.special.Beta;
|
||||||
@ -101,10 +100,8 @@ public class TDistributionImpl
|
|||||||
*
|
*
|
||||||
* @param x Value at which the CDF is evaluated.
|
* @param x Value at which the CDF is evaluated.
|
||||||
* @return CDF evaluated at {@code x}.
|
* @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;
|
double ret;
|
||||||
if (x == 0) {
|
if (x == 0) {
|
||||||
ret = 0.5;
|
ret = 0.5;
|
||||||
@ -132,14 +129,11 @@ public class TDistributionImpl
|
|||||||
*
|
*
|
||||||
* @param p Desired probability.
|
* @param p Desired probability.
|
||||||
* @return {@code x}, such that {@code P(X < x) = p}.
|
* @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
|
* @throws org.apache.commons.math.exception.OutOfRangeException if
|
||||||
* {@code p} is not a valid probability.
|
* {@code p} is not a valid probability.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public double inverseCumulativeProbability(final double p)
|
public double inverseCumulativeProbability(final double p) {
|
||||||
throws MathException {
|
|
||||||
if (p == 0) {
|
if (p == 0) {
|
||||||
return Double.NEGATIVE_INFINITY;
|
return Double.NEGATIVE_INFINITY;
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,6 @@ import java.security.NoSuchProviderException;
|
|||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.apache.commons.math.MathException;
|
|
||||||
import org.apache.commons.math.distribution.BetaDistributionImpl;
|
import org.apache.commons.math.distribution.BetaDistributionImpl;
|
||||||
import org.apache.commons.math.distribution.BinomialDistributionImpl;
|
import org.apache.commons.math.distribution.BinomialDistributionImpl;
|
||||||
import org.apache.commons.math.distribution.CauchyDistributionImpl;
|
import org.apache.commons.math.distribution.CauchyDistributionImpl;
|
||||||
@ -607,10 +606,9 @@ public class RandomDataImpl implements RandomData, Serializable {
|
|||||||
* @param alpha first distribution shape parameter
|
* @param alpha first distribution shape parameter
|
||||||
* @param beta second distribution shape parameter
|
* @param beta second distribution shape parameter
|
||||||
* @return random value sampled from the beta(alpha, beta) distribution
|
* @return random value sampled from the beta(alpha, beta) distribution
|
||||||
* @throws MathException if an error occurs generating the random value
|
|
||||||
* @since 2.2
|
* @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));
|
return nextInversionDeviate(new BetaDistributionImpl(alpha, beta));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -622,10 +620,9 @@ public class RandomDataImpl implements RandomData, Serializable {
|
|||||||
* @param numberOfTrials number of trials of the Binomial distribution
|
* @param numberOfTrials number of trials of the Binomial distribution
|
||||||
* @param probabilityOfSuccess probability of success of the Binomial distribution
|
* @param probabilityOfSuccess probability of success of the Binomial distribution
|
||||||
* @return random value sampled from the Binomial(numberOfTrials, probabilityOfSuccess) distribution
|
* @return random value sampled from the Binomial(numberOfTrials, probabilityOfSuccess) distribution
|
||||||
* @throws MathException if an error occurs generating the random value
|
|
||||||
* @since 2.2
|
* @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));
|
return nextInversionDeviate(new BinomialDistributionImpl(numberOfTrials, probabilityOfSuccess));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -637,10 +634,9 @@ public class RandomDataImpl implements RandomData, Serializable {
|
|||||||
* @param median the median of the Cauchy distribution
|
* @param median the median of the Cauchy distribution
|
||||||
* @param scale the scale parameter of the Cauchy distribution
|
* @param scale the scale parameter of the Cauchy distribution
|
||||||
* @return random value sampled from the Cauchy(median, scale) distribution
|
* @return random value sampled from the Cauchy(median, scale) distribution
|
||||||
* @throws MathException if an error occurs generating the random value
|
|
||||||
* @since 2.2
|
* @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));
|
return nextInversionDeviate(new CauchyDistributionImpl(median, scale));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,10 +647,9 @@ public class RandomDataImpl implements RandomData, Serializable {
|
|||||||
*
|
*
|
||||||
* @param df the degrees of freedom of the ChiSquare distribution
|
* @param df the degrees of freedom of the ChiSquare distribution
|
||||||
* @return random value sampled from the ChiSquare(df) distribution
|
* @return random value sampled from the ChiSquare(df) distribution
|
||||||
* @throws MathException if an error occurs generating the random value
|
|
||||||
* @since 2.2
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
public double nextChiSquare(double df) throws MathException {
|
public double nextChiSquare(double df) {
|
||||||
return nextInversionDeviate(new ChiSquaredDistributionImpl(df));
|
return nextInversionDeviate(new ChiSquaredDistributionImpl(df));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -666,10 +661,9 @@ public class RandomDataImpl implements RandomData, Serializable {
|
|||||||
* @param numeratorDf the numerator degrees of freedom of the F distribution
|
* @param numeratorDf the numerator degrees of freedom of the F distribution
|
||||||
* @param denominatorDf the denominator 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
|
* @return random value sampled from the F(numeratorDf, denominatorDf) distribution
|
||||||
* @throws MathException if an error occurs generating the random value
|
|
||||||
* @since 2.2
|
* @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));
|
return nextInversionDeviate(new FDistributionImpl(numeratorDf, denominatorDf));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -692,10 +686,9 @@ public class RandomDataImpl implements RandomData, Serializable {
|
|||||||
* @param shape the median of the Gamma distribution
|
* @param shape the median of the Gamma distribution
|
||||||
* @param scale the scale parameter of the Gamma distribution
|
* @param scale the scale parameter of the Gamma distribution
|
||||||
* @return random value sampled from the Gamma(shape, scale) distribution
|
* @return random value sampled from the Gamma(shape, scale) distribution
|
||||||
* @throws MathException if an error occurs generating the random value
|
|
||||||
* @since 2.2
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
public double nextGamma(double shape, double scale) throws MathException {
|
public double nextGamma(double shape, double scale) {
|
||||||
if (shape < 1) {
|
if (shape < 1) {
|
||||||
// [1]: p. 228, Algorithm GS
|
// [1]: p. 228, Algorithm GS
|
||||||
|
|
||||||
@ -770,10 +763,9 @@ public class RandomDataImpl implements RandomData, Serializable {
|
|||||||
* @param numberOfSuccesses number of successes in the population of the Hypergeometric distribution
|
* @param numberOfSuccesses number of successes in the population of the Hypergeometric distribution
|
||||||
* @param sampleSize the sample size of the Hypergeometric distribution
|
* @param sampleSize the sample size of the Hypergeometric distribution
|
||||||
* @return random value sampled from the Hypergeometric(numberOfSuccesses, sampleSize) distribution
|
* @return random value sampled from the Hypergeometric(numberOfSuccesses, sampleSize) distribution
|
||||||
* @throws MathException if an error occurs generating the random value
|
|
||||||
* @since 2.2
|
* @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));
|
return nextInversionDeviate(new HypergeometricDistributionImpl(populationSize, numberOfSuccesses, sampleSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -785,10 +777,9 @@ public class RandomDataImpl implements RandomData, Serializable {
|
|||||||
* @param r the number of successes of the Pascal distribution
|
* @param r the number of successes of the Pascal distribution
|
||||||
* @param p the probability of success of the Pascal distribution
|
* @param p the probability of success of the Pascal distribution
|
||||||
* @return random value sampled from the Pascal(r, p) distribution
|
* @return random value sampled from the Pascal(r, p) distribution
|
||||||
* @throws MathException if an error occurs generating the random value
|
|
||||||
* @since 2.2
|
* @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));
|
return nextInversionDeviate(new PascalDistributionImpl(r, p));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -799,10 +790,9 @@ public class RandomDataImpl implements RandomData, Serializable {
|
|||||||
*
|
*
|
||||||
* @param df the degrees of freedom of the T distribution
|
* @param df the degrees of freedom of the T distribution
|
||||||
* @return random value from the T(df) distribution
|
* @return random value from the T(df) distribution
|
||||||
* @throws MathException if an error occurs generating the random value
|
|
||||||
* @since 2.2
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
public double nextT(double df) throws MathException {
|
public double nextT(double df) {
|
||||||
return nextInversionDeviate(new TDistributionImpl(df));
|
return nextInversionDeviate(new TDistributionImpl(df));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -814,10 +804,9 @@ public class RandomDataImpl implements RandomData, Serializable {
|
|||||||
* @param shape the shape parameter of the Weibull distribution
|
* @param shape the shape parameter of the Weibull distribution
|
||||||
* @param scale the scale parameter of the Weibull distribution
|
* @param scale the scale parameter of the Weibull distribution
|
||||||
* @return random value sampled from the Weibull(shape, size) distribution
|
* @return random value sampled from the Weibull(shape, size) distribution
|
||||||
* @throws MathException if an error occurs generating the random value
|
|
||||||
* @since 2.2
|
* @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));
|
return nextInversionDeviate(new WeibullDistributionImpl(shape, scale));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -829,10 +818,9 @@ public class RandomDataImpl implements RandomData, Serializable {
|
|||||||
* @param numberOfElements the number of elements of the ZipfDistribution
|
* @param numberOfElements the number of elements of the ZipfDistribution
|
||||||
* @param exponent the exponent of the ZipfDistribution
|
* @param exponent the exponent of the ZipfDistribution
|
||||||
* @return random value sampled from the Zipf(numberOfElements, exponent) distribution
|
* @return random value sampled from the Zipf(numberOfElements, exponent) distribution
|
||||||
* @throws MathException if an error occurs generating the random value
|
|
||||||
* @since 2.2
|
* @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));
|
return nextInversionDeviate(new ZipfDistributionImpl(numberOfElements, exponent));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1044,10 +1032,9 @@ public class RandomDataImpl implements RandomData, Serializable {
|
|||||||
*
|
*
|
||||||
* @param distribution Continuous distribution to generate a random value from
|
* @param distribution Continuous distribution to generate a random value from
|
||||||
* @return a random value sampled from the given distribution
|
* @return a random value sampled from the given distribution
|
||||||
* @throws MathException if an error occurs computing the inverse cumulative distribution function
|
|
||||||
* @since 2.2
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
public double nextInversionDeviate(ContinuousDistribution distribution) throws MathException {
|
public double nextInversionDeviate(ContinuousDistribution distribution) {
|
||||||
return distribution.inverseCumulativeProbability(nextUniform(0, 1));
|
return distribution.inverseCumulativeProbability(nextUniform(0, 1));
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1058,10 +1045,9 @@ public class RandomDataImpl implements RandomData, Serializable {
|
|||||||
*
|
*
|
||||||
* @param distribution Integer distribution to generate a random value from
|
* @param distribution Integer distribution to generate a random value from
|
||||||
* @return a random value sampled from the given distribution
|
* @return a random value sampled from the given distribution
|
||||||
* @throws MathException if an error occurs computing the inverse cumulative distribution function
|
|
||||||
* @since 2.2
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
public int nextInversionDeviate(IntegerDistribution distribution) throws MathException {
|
public int nextInversionDeviate(IntegerDistribution distribution) {
|
||||||
final double target = nextUniform(0, 1);
|
final double target = nextUniform(0, 1);
|
||||||
final int glb = distribution.inverseCumulativeProbability(target);
|
final int glb = distribution.inverseCumulativeProbability(target);
|
||||||
if (distribution.cumulativeProbability(glb) == 1.0d) { // No mass above
|
if (distribution.cumulativeProbability(glb) == 1.0d) { // No mass above
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
package org.apache.commons.math.distribution;
|
package org.apache.commons.math.distribution;
|
||||||
|
|
||||||
import org.apache.commons.math.MathException;
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@ -128,7 +127,7 @@ public class AbtractIntegerDistributionTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double cumulativeProbability(int x) throws MathException {
|
public double cumulativeProbability(int x) {
|
||||||
if (x < 1) {
|
if (x < 1) {
|
||||||
return 0;
|
return 0;
|
||||||
} else if (x >= 6) {
|
} else if (x >= 6) {
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.commons.math.distribution;
|
package org.apache.commons.math.distribution;
|
||||||
|
|
||||||
import org.apache.commons.math.MathException;
|
|
||||||
import org.apache.commons.math.util.FastMath;
|
import org.apache.commons.math.util.FastMath;
|
||||||
import org.apache.commons.math.exception.NotStrictlyPositiveException;
|
import org.apache.commons.math.exception.NotStrictlyPositiveException;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
@ -169,7 +168,7 @@ public class PoissonDistributionTest extends IntegerDistributionAbstractTest {
|
|||||||
Assert.assertTrue("Zero cum probaility returned for mean = " +
|
Assert.assertTrue("Zero cum probaility returned for mean = " +
|
||||||
mean + " x = " + x, p > 0);
|
mean + " x = " + x, p > 0);
|
||||||
}
|
}
|
||||||
} catch (MathException ex) {
|
} catch (Exception ex) {
|
||||||
Assert.fail("mean of " + mean + " and x of " + x + " caused " + ex.getMessage());
|
Assert.fail("mean of " + mean + " and x of " + x + " caused " + ex.getMessage());
|
||||||
}
|
}
|
||||||
x -= dx;
|
x -= dx;
|
||||||
@ -216,7 +215,7 @@ public class PoissonDistributionTest extends IntegerDistributionAbstractTest {
|
|||||||
// Verify that returned value satisties definition
|
// Verify that returned value satisties definition
|
||||||
Assert.assertTrue(p >= dist.cumulativeProbability(ret));
|
Assert.assertTrue(p >= dist.cumulativeProbability(ret));
|
||||||
Assert.assertTrue(p < dist.cumulativeProbability(ret + 1));
|
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());
|
Assert.fail("mean of " + mean + " and p of " + p + " caused " + ex.getMessage());
|
||||||
}
|
}
|
||||||
p += dp;
|
p += dp;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user