Java Code Examples for org.apache.commons.math3.exception.util.LocalizedFormats#NAN_NOT_ALLOWED

The following examples show how to use org.apache.commons.math3.exception.util.LocalizedFormats#NAN_NOT_ALLOWED . 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: RandomDataImpl.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * <p>
 * <strong>Algorithm Description</strong>: if the lower bound is excluded,
 * scales the output of Random.nextDouble(), but rejects 0 values (i.e.,
 * will generate another random double if Random.nextDouble() returns 0).
 * This is necessary to provide a symmetric output interval (both
 * endpoints excluded).
 * </p>
 *
 * @throws MathIllegalArgumentException if one of the bounds is infinite or
 * {@code NaN}
 * @since 3.0
 */
public double nextUniform(double lower, double upper,
    boolean lowerInclusive) {

    if (lower >= upper) {
        throw new NumberIsTooLargeException(LocalizedFormats.LOWER_BOUND_NOT_BELOW_UPPER_BOUND,
                                            lower, upper, false);
    }

    if (Double.isInfinite(lower) || Double.isInfinite(upper)) {
        throw new MathIllegalArgumentException(LocalizedFormats.INFINITE_BOUND);
    }

    if (Double.isNaN(lower) || Double.isNaN(upper)) {
        throw new MathIllegalArgumentException(LocalizedFormats.NAN_NOT_ALLOWED);
    }

    final RandomGenerator generator = getRan();

    // ensure nextDouble() isn't 0.0
    double u = generator.nextDouble();
    while (!lowerInclusive && u <= 0.0) {
        u = generator.nextDouble();
    }

    return u * upper + (1.0 - u) * lower;
}
 
Example 2
Source File: RandomDataImpl.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * <p>
 * <strong>Algorithm Description</strong>: if the lower bound is excluded,
 * scales the output of Random.nextDouble(), but rejects 0 values (i.e.,
 * will generate another random double if Random.nextDouble() returns 0).
 * This is necessary to provide a symmetric output interval (both
 * endpoints excluded).
 * </p>
 *
 * @throws MathIllegalArgumentException if one of the bounds is infinite or
 * {@code NaN}
 * @since 3.0
 */
public double nextUniform(double lower, double upper,
    boolean lowerInclusive) {

    if (lower >= upper) {
        throw new NumberIsTooLargeException(LocalizedFormats.LOWER_BOUND_NOT_BELOW_UPPER_BOUND,
                                            lower, upper, false);
    }

    if (Double.isInfinite(lower) || Double.isInfinite(upper)) {
        throw new MathIllegalArgumentException(LocalizedFormats.INFINITE_BOUND);
    }

    if (Double.isNaN(lower) || Double.isNaN(upper)) {
        throw new MathIllegalArgumentException(LocalizedFormats.NAN_NOT_ALLOWED);
    }

    final RandomGenerator generator = getRan();

    // ensure nextDouble() isn't 0.0
    double u = generator.nextDouble();
    while (!lowerInclusive && u <= 0.0) {
        u = generator.nextDouble();
    }

    return u * upper + (1.0 - u) * lower;
}
 
Example 3
Source File: NotANumberException.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Construct the exception.
 */
public NotANumberException() {
    super(LocalizedFormats.NAN_NOT_ALLOWED, Double.valueOf(Double.NaN));
}
 
Example 4
Source File: NotANumberException.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Construct the exception.
 */
public NotANumberException() {
    super(LocalizedFormats.NAN_NOT_ALLOWED, Double.NaN);
}
 
Example 5
Source File: NotANumberException.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Construct the exception.
 */
public NotANumberException() {
    super(LocalizedFormats.NAN_NOT_ALLOWED, Double.valueOf(Double.NaN));
}
 
Example 6
Source File: NotANumberException.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Construct the exception.
 */
public NotANumberException() {
    super(LocalizedFormats.NAN_NOT_ALLOWED, Double.NaN);
}
 
Example 7
Source File: NotANumberException.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Construct the exception.
 */
public NotANumberException() {
    super(LocalizedFormats.NAN_NOT_ALLOWED, Double.valueOf(Double.NaN));
}
 
Example 8
Source File: NotANumberException.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Construct the exception.
 */
public NotANumberException() {
    super(LocalizedFormats.NAN_NOT_ALLOWED, Double.valueOf(Double.NaN));
}