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

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

Introduction

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

Prototype

LocalizedFormats NUMBER_OF_TRIALS

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

Click Source Link

Usage

From source file:org.nd4j.linalg.api.rng.distribution.impl.BinomialDistribution.java

/**
 * Creates a binomial distribution./*w w  w .j av a2s  . c o  m*/
 *
 * @param rng    Random number generator.
 * @param trials Number of trials.
 * @param p      Probability of success.
 * @throws org.apache.commons.math3.exception.NotPositiveException if {@code trials < 0}.
 * @throws org.apache.commons.math3.exception.OutOfRangeException  if {@code p < 0} or {@code p > 1}.
 * @since 3.1
 */
public BinomialDistribution(Random rng, int trials, double p) {
    super(rng);

    if (trials < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_TRIALS, trials);
    }
    if (p < 0 || p > 1) {
        throw new OutOfRangeException(p, 0, 1);
    }

    probabilityOfSuccess = p;
    numberOfTrials = trials;
}