List of usage examples for org.apache.commons.math3.exception.util LocalizedFormats LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT
LocalizedFormats LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT
To view the source code for org.apache.commons.math3.exception.util LocalizedFormats LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT.
Click Source Link
From source file:org.nd4j.linalg.api.rng.distribution.BaseDistribution.java
/** * For a random variable {@code X} whose values are distributed according * to this distribution, this method returns {@code P(x0 < X <= x1)}. * * @param x0 Lower bound (excluded).//w ww .ja v a2 s . c om * @param x1 Upper bound (included). * @return the probability that a random variable with this distribution * takes a value between {@code x0} and {@code x1}, excluding the lower * and including the upper endpoint. * @throws org.apache.commons.math3.exception.NumberIsTooLargeException if {@code x0 > x1}. * <p/> * The default implementation uses the identity * {@code P(x0 < X <= x1) = P(X <= x1) - P(X <= x0)} * @since 3.1 */ public double probability(double x0, double x1) { if (x0 > x1) { throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x0, x1, true); } return cumulativeProbability(x1) - cumulativeProbability(x0); }
From source file:org.nd4j.linalg.api.rng.distribution.impl.LogNormalDistribution.java
/** * {@inheritDoc}/*from w w w . ja v a2 s . c o m*/ */ @Override public double probability(double x0, double x1) throws NumberIsTooLargeException { if (x0 > x1) { throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x0, x1, true); } final double denom = standardDeviation * SQRT2; final double v0 = (x0 - mean) / denom; final double v1 = (x1 - mean) / denom; return 0.5 * Erf.erf(v0, v1); }