Example usage for org.apache.commons.math3.exception.util LocalizedFormats NUMBER_OF_SUCCESSES

List of usage examples for org.apache.commons.math3.exception.util LocalizedFormats NUMBER_OF_SUCCESSES

Introduction

In this page you can find the example usage for org.apache.commons.math3.exception.util LocalizedFormats NUMBER_OF_SUCCESSES.

Prototype

LocalizedFormats NUMBER_OF_SUCCESSES

To view the source code for org.apache.commons.math3.exception.util LocalizedFormats NUMBER_OF_SUCCESSES.

Click Source Link

Usage

From source file:experiment.PascalDistribution_bug.java

/**
  * Create a Pascal distribution with the given number of successes and
  * probability of success.//from ww w  . j  av  a 2s  .co m
  *
  * @param rng Random number generator.
  * @param r Number of successes.
  * @param p Probability of success.
  * @throws NotStrictlyPositiveException if the number of successes is not positive
  * @throws OutOfRangeException if the probability of success is not in the
  * range {@code [0, 1]}.
  * @since 3.1
  */
public PascalDistribution_bug(RandomGenerator rng, int r, double p, int id)
        throws NotStrictlyPositiveException, OutOfRangeException {
    super(rng);

    if (r <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.NUMBER_OF_SUCCESSES, r);
    }
    if (p < 0 || p > 1) {
        throw new OutOfRangeException(p, 0, 1);
    }

    numberOfSuccesses = r;
    probabilityOfSuccess = p;
}