Java Code Examples for org.apache.commons.math.exception.util.LocalizedFormats#LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT
The following examples show how to use
org.apache.commons.math.exception.util.LocalizedFormats#LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractIntegerDistribution.java From astor with GNU General Public License v2.0 | 6 votes |
/** * For a random variable {@code X} whose values are distributed * according to this distribution, this method returns * {@code P(x0 < X < x1)}. * * @param x0 Inclusive lower bound. * @param x1 Inclusive upper bound. * @return the probability that a random variable with this distribution * will take a value between {@code x0} and {@code x1}, * including the endpoints. * @throws 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 { if (x1 < x0) { throw new NumberIsTooSmallException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x1, x0, true); } if (FastMath.floor(x0) < x0) { return cumulativeProbability(((int) FastMath.floor(x0)) + 1, (int) FastMath.floor(x1)); // don't want to count mass below x0 } else { // x0 is mathematical integer, so use as is return cumulativeProbability((int) FastMath.floor(x0), (int) FastMath.floor(x1)); } }
Example 2
Source File: AbstractIntegerDistribution.java From astor with GNU General Public License v2.0 | 6 votes |
/** * For a random variable {@code X} whose values are distributed * according to this distribution, this method returns * {@code P(x0 <= X <= x1)}. * * @param x0 Inclusive lower bound. * @param x1 Inclusive upper bound. * @return the probability that a random variable with this distribution * will take a value between {@code x0} and {@code x1}, * including the endpoints. * @throws 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 { if (x1 < x0) { throw new NumberIsTooSmallException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x1, x0, true); } if (FastMath.floor(x0) < x0) { return cumulativeProbability(((int) FastMath.floor(x0)) + 1, (int) FastMath.floor(x1)); // don't want to count mass below x0 } else { // x0 is mathematical integer, so use as is return cumulativeProbability((int) FastMath.floor(x0), (int) FastMath.floor(x1)); } }
Example 3
Source File: AbstractIntegerDistribution.java From astor with GNU General Public License v2.0 | 6 votes |
/** * For a random variable {@code X} whose values are distributed * according to this distribution, this method returns * {@code P(x0 <= X <= x1)}. * * @param x0 Inclusive lower bound. * @param x1 Inclusive upper bound. * @return the probability that a random variable with this distribution * will take a value between {@code x0} and {@code x1}, * including the endpoints. * @throws 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 { if (x1 < x0) { throw new NumberIsTooSmallException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x1, x0, true); } if (FastMath.floor(x0) < x0) { return cumulativeProbability(((int) FastMath.floor(x0)) + 1, (int) FastMath.floor(x1)); // don't want to count mass below x0 } else { // x0 is mathematical integer, so use as is return cumulativeProbability((int) FastMath.floor(x0), (int) FastMath.floor(x1)); } }
Example 4
Source File: AbstractIntegerDistribution.java From astor with GNU General Public License v2.0 | 3 votes |
/** * For a random variable {@code X} whose values are distributed according * to this distribution, this method returns {@code P(x0 < X < x1)}. * * @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 { if (x1 < x0) { throw new NumberIsTooSmallException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x1, x0, true); } return cumulativeProbability(x1) - cumulativeProbability(x0 - 1); }
Example 5
Source File: AbstractDistribution.java From astor with GNU General Public License v2.0 | 3 votes |
/** * For a random variable X whose values are distributed according * to this distribution, this method returns P(x0 ≤ X ≤ x1). * <p> * The default implementation uses the identity</p> * <p> * P(x0 ≤ X ≤ x1) = P(X ≤ x1) - P(X ≤ x0) </p> * * @param x0 the (inclusive) lower bound * @param x1 the (inclusive) upper bound * @return the probability that a random variable with this distribution * will take a value between {@code x0} and {@code x1}, * including the endpoints. * @throws 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 { if (x0 > x1) { throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x0, x1, true); } return cumulativeProbability(x1) - cumulativeProbability(x0); }
Example 6
Source File: AbstractIntegerDistribution.java From astor with GNU General Public License v2.0 | 3 votes |
/** * For a random variable {@code X} whose values are distributed according * to this distribution, this method returns {@code P(x0 < X < x1)}. * * @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 { if (x1 < x0) { throw new NumberIsTooSmallException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x1, x0, true); } return cumulativeProbability(x1) - cumulativeProbability(x0 - 1); }
Example 7
Source File: AbstractDistribution.java From astor with GNU General Public License v2.0 | 3 votes |
/** * For a random variable X whose values are distributed according * to this distribution, this method returns P(x0 ≤ X ≤ x1). * <p> * The default implementation uses the identity</p> * <p> * P(x0 ≤ X ≤ x1) = P(X ≤ x1) - P(X ≤ x0) </p> * * @param x0 the (inclusive) lower bound * @param x1 the (inclusive) upper bound * @return the probability that a random variable with this distribution * will take a value between {@code x0} and {@code x1}, * including the endpoints. * @throws 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 { if (x0 > x1) { throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x0, x1, true); } return cumulativeProbability(x1) - cumulativeProbability(x0); }
Example 8
Source File: AbstractIntegerDistribution.java From astor with GNU General Public License v2.0 | 3 votes |
/** * For a random variable {@code X} whose values are distributed according * to this distribution, this method returns {@code P(x0 < X < x1)}. * * @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 { if (x1 < x0) { throw new NumberIsTooSmallException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x1, x0, true); } return cumulativeProbability(x1) - cumulativeProbability(x0 - 1); }
Example 9
Source File: AbstractDistribution.java From astor with GNU General Public License v2.0 | 3 votes |
/** * For a random variable X whose values are distributed according * to this distribution, this method returns P(x0 ≤ X ≤ x1). * <p> * The default implementation uses the identity</p> * <p> * P(x0 ≤ X ≤ x1) = P(X ≤ x1) - P(X ≤ x0) </p> * * @param x0 the (inclusive) lower bound * @param x1 the (inclusive) upper bound * @return the probability that a random variable with this distribution * will take a value between {@code x0} and {@code x1}, * including the endpoints. * @throws 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 { if (x0 > x1) { throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x0, x1, true); } return cumulativeProbability(x1) - cumulativeProbability(x0); }