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

The following examples show how to use org.apache.commons.math3.exception.util.LocalizedFormats#NUMBER_OF_SUCCESSES . 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: PascalDistribution.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a Pascal distribution with the given number of successes and
 * probability of success.
 *
 * @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(RandomGenerator rng,
                          int r,
                          double p)
    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;
}
 
Example 2
Source File: PascalDistribution.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a Pascal distribution with the given number of successes and
 * probability of success.
 *
 * @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(RandomGenerator rng,
                          int r,
                          double p)
    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;
}
 
Example 3
Source File: PascalDistribution.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a Pascal distribution with the given number of successes and
 * probability of success.
 *
 * @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(RandomGenerator rng,
                          int r,
                          double p)
    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;
    logProbabilityOfSuccess = FastMath.log(p);
    log1mProbabilityOfSuccess = FastMath.log1p(-p);
}
 
Example 4
Source File: PascalDistribution.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a Pascal distribution with the given number of successes and
 * probability of success.
 *
 * @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(RandomGenerator rng,
                          int r,
                          double p)
    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;
    logProbabilityOfSuccess = FastMath.log(p);
    log1mProbabilityOfSuccess = FastMath.log1p(-p);
}
 
Example 5
Source File: PascalDistribution.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a Pascal distribution with the given number of successes and
 * probability of success.
 *
 * @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(RandomGenerator rng,
                          int r,
                          double p)
    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;
}
 
Example 6
Source File: PascalDistribution.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a Pascal distribution with the given number of successes and
 * probability of success.
 *
 * @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(RandomGenerator rng,
                          int r,
                          double p)
    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;
}
 
Example 7
Source File: PascalDistribution.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a Pascal distribution with the given number of successes and
 * probability of success.
 *
 * @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(RandomGenerator rng,
                          int r,
                          double p)
    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;
}
 
Example 8
Source File: HypergeometricDistribution.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new hypergeometric distribution.
 *
 * @param rng Random number generator.
 * @param populationSize Population size.
 * @param numberOfSuccesses Number of successes in the population.
 * @param sampleSize Sample size.
 * @throws NotPositiveException if {@code numberOfSuccesses < 0}.
 * @throws NotStrictlyPositiveException if {@code populationSize <= 0}.
 * @throws NumberIsTooLargeException if {@code numberOfSuccesses > populationSize},
 * or {@code sampleSize > populationSize}.
 * @since 3.1
 */
public HypergeometricDistribution(RandomGenerator rng,
                                  int populationSize,
                                  int numberOfSuccesses,
                                  int sampleSize)
throws NotPositiveException, NotStrictlyPositiveException, NumberIsTooLargeException {
    super(rng);

    if (populationSize <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.POPULATION_SIZE,
                                               populationSize);
    }
    if (numberOfSuccesses < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_SUCCESSES,
                                       numberOfSuccesses);
    }
    if (sampleSize < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES,
                                       sampleSize);
    }

    if (numberOfSuccesses > populationSize) {
        throw new NumberIsTooLargeException(LocalizedFormats.NUMBER_OF_SUCCESS_LARGER_THAN_POPULATION_SIZE,
                                            numberOfSuccesses, populationSize, true);
    }
    if (sampleSize > populationSize) {
        throw new NumberIsTooLargeException(LocalizedFormats.SAMPLE_SIZE_LARGER_THAN_POPULATION_SIZE,
                                            sampleSize, populationSize, true);
    }

    this.numberOfSuccesses = numberOfSuccesses;
    this.populationSize = populationSize;
    this.sampleSize = sampleSize;
}
 
Example 9
Source File: HypergeometricDistribution.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new hypergeometric distribution.
 *
 * @param rng Random number generator.
 * @param populationSize Population size.
 * @param numberOfSuccesses Number of successes in the population.
 * @param sampleSize Sample size.
 * @throws NotPositiveException if {@code numberOfSuccesses < 0}.
 * @throws NotStrictlyPositiveException if {@code populationSize <= 0}.
 * @throws NumberIsTooLargeException if {@code numberOfSuccesses > populationSize},
 * or {@code sampleSize > populationSize}.
 * @since 3.1
 */
public HypergeometricDistribution(RandomGenerator rng,
                                  int populationSize,
                                  int numberOfSuccesses,
                                  int sampleSize)
throws NotPositiveException, NotStrictlyPositiveException, NumberIsTooLargeException {
    super(rng);

    if (populationSize <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.POPULATION_SIZE,
                                               populationSize);
    }
    if (numberOfSuccesses < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_SUCCESSES,
                                       numberOfSuccesses);
    }
    if (sampleSize < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES,
                                       sampleSize);
    }

    if (numberOfSuccesses > populationSize) {
        throw new NumberIsTooLargeException(LocalizedFormats.NUMBER_OF_SUCCESS_LARGER_THAN_POPULATION_SIZE,
                                            numberOfSuccesses, populationSize, true);
    }
    if (sampleSize > populationSize) {
        throw new NumberIsTooLargeException(LocalizedFormats.SAMPLE_SIZE_LARGER_THAN_POPULATION_SIZE,
                                            sampleSize, populationSize, true);
    }

    this.numberOfSuccesses = numberOfSuccesses;
    this.populationSize = populationSize;
    this.sampleSize = sampleSize;
}
 
Example 10
Source File: HypergeometricDistribution.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new hypergeometric distribution.
 *
 * @param rng Random number generator.
 * @param populationSize Population size.
 * @param numberOfSuccesses Number of successes in the population.
 * @param sampleSize Sample size.
 * @throws NotPositiveException if {@code numberOfSuccesses < 0}.
 * @throws NotStrictlyPositiveException if {@code populationSize <= 0}.
 * @throws NumberIsTooLargeException if {@code numberOfSuccesses > populationSize},
 * or {@code sampleSize > populationSize}.
 * @since 3.1
 */
public HypergeometricDistribution(RandomGenerator rng,
                                  int populationSize,
                                  int numberOfSuccesses,
                                  int sampleSize)
throws NotPositiveException, NotStrictlyPositiveException, NumberIsTooLargeException {
    super(rng);

    if (populationSize <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.POPULATION_SIZE,
                                               populationSize);
    }
    if (numberOfSuccesses < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_SUCCESSES,
                                       numberOfSuccesses);
    }
    if (sampleSize < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES,
                                       sampleSize);
    }

    if (numberOfSuccesses > populationSize) {
        throw new NumberIsTooLargeException(LocalizedFormats.NUMBER_OF_SUCCESS_LARGER_THAN_POPULATION_SIZE,
                                            numberOfSuccesses, populationSize, true);
    }
    if (sampleSize > populationSize) {
        throw new NumberIsTooLargeException(LocalizedFormats.SAMPLE_SIZE_LARGER_THAN_POPULATION_SIZE,
                                            sampleSize, populationSize, true);
    }

    this.numberOfSuccesses = numberOfSuccesses;
    this.populationSize = populationSize;
    this.sampleSize = sampleSize;
}
 
Example 11
Source File: PascalDistribution.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a Pascal distribution with the given number of successes and
 * probability of success.
 *
 * @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 [0, 1]
 */
public PascalDistribution(int r, double p)
    throws NotStrictlyPositiveException, OutOfRangeException {
    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;
}
 
Example 12
Source File: HypergeometricDistribution.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Construct a new hypergeometric distribution with the specified population
 * size, number of successes in the population, and sample size.
 *
 * @param populationSize Population size.
 * @param numberOfSuccesses Number of successes in the population.
 * @param sampleSize Sample size.
 * @throws NotPositiveException if {@code numberOfSuccesses < 0}.
 * @throws NotStrictlyPositiveException if {@code populationSize <= 0}.
 * @throws NumberIsTooLargeException if {@code numberOfSuccesses > populationSize},
 * or {@code sampleSize > populationSize}.
 */
public HypergeometricDistribution(int populationSize, int numberOfSuccesses, int sampleSize)
throws NotPositiveException, NotStrictlyPositiveException, NumberIsTooLargeException {
    if (populationSize <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.POPULATION_SIZE,
                                               populationSize);
    }
    if (numberOfSuccesses < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_SUCCESSES,
                                       numberOfSuccesses);
    }
    if (sampleSize < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES,
                                       sampleSize);
    }

    if (numberOfSuccesses > populationSize) {
        throw new NumberIsTooLargeException(LocalizedFormats.NUMBER_OF_SUCCESS_LARGER_THAN_POPULATION_SIZE,
                                            numberOfSuccesses, populationSize, true);
    }
    if (sampleSize > populationSize) {
        throw new NumberIsTooLargeException(LocalizedFormats.SAMPLE_SIZE_LARGER_THAN_POPULATION_SIZE,
                                            sampleSize, populationSize, true);
    }

    this.numberOfSuccesses = numberOfSuccesses;
    this.populationSize = populationSize;
    this.sampleSize = sampleSize;
}
 
Example 13
Source File: HypergeometricDistribution.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new hypergeometric distribution.
 *
 * @param rng Random number generator.
 * @param populationSize Population size.
 * @param numberOfSuccesses Number of successes in the population.
 * @param sampleSize Sample size.
 * @throws NotPositiveException if {@code numberOfSuccesses < 0}.
 * @throws NotStrictlyPositiveException if {@code populationSize <= 0}.
 * @throws NumberIsTooLargeException if {@code numberOfSuccesses > populationSize},
 * or {@code sampleSize > populationSize}.
 * @since 3.1
 */
public HypergeometricDistribution(RandomGenerator rng,
                                  int populationSize,
                                  int numberOfSuccesses,
                                  int sampleSize)
throws NotPositiveException, NotStrictlyPositiveException, NumberIsTooLargeException {
    super(rng);

    if (populationSize <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.POPULATION_SIZE,
                                               populationSize);
    }
    if (numberOfSuccesses < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_SUCCESSES,
                                       numberOfSuccesses);
    }
    if (sampleSize < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES,
                                       sampleSize);
    }

    if (numberOfSuccesses > populationSize) {
        throw new NumberIsTooLargeException(LocalizedFormats.NUMBER_OF_SUCCESS_LARGER_THAN_POPULATION_SIZE,
                                            numberOfSuccesses, populationSize, true);
    }
    if (sampleSize > populationSize) {
        throw new NumberIsTooLargeException(LocalizedFormats.SAMPLE_SIZE_LARGER_THAN_POPULATION_SIZE,
                                            sampleSize, populationSize, true);
    }

    this.numberOfSuccesses = numberOfSuccesses;
    this.populationSize = populationSize;
    this.sampleSize = sampleSize;
}
 
Example 14
Source File: Cardumen_00162_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Creates a new hypergeometric distribution.
 *
 * @param rng Random number generator.
 * @param populationSize Population size.
 * @param numberOfSuccesses Number of successes in the population.
 * @param sampleSize Sample size.
 * @throws NotPositiveException if {@code numberOfSuccesses < 0}.
 * @throws NotStrictlyPositiveException if {@code populationSize <= 0}.
 * @throws NumberIsTooLargeException if {@code numberOfSuccesses > populationSize},
 * or {@code sampleSize > populationSize}.
 * @since 3.1
 */
public HypergeometricDistribution(RandomGenerator rng,
                                  int populationSize,
                                  int numberOfSuccesses,
                                  int sampleSize)
throws NotPositiveException, NotStrictlyPositiveException, NumberIsTooLargeException {
    super(rng);

    if (populationSize <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.POPULATION_SIZE,
                                               populationSize);
    }
    if (numberOfSuccesses < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_SUCCESSES,
                                       numberOfSuccesses);
    }
    if (sampleSize < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES,
                                       sampleSize);
    }

    if (numberOfSuccesses > populationSize) {
        throw new NumberIsTooLargeException(LocalizedFormats.NUMBER_OF_SUCCESS_LARGER_THAN_POPULATION_SIZE,
                                            numberOfSuccesses, populationSize, true);
    }
    if (sampleSize > populationSize) {
        throw new NumberIsTooLargeException(LocalizedFormats.SAMPLE_SIZE_LARGER_THAN_POPULATION_SIZE,
                                            sampleSize, populationSize, true);
    }

    this.numberOfSuccesses = numberOfSuccesses;
    this.populationSize = populationSize;
    this.sampleSize = sampleSize;
}
 
Example 15
Source File: HypergeometricDistribution.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new hypergeometric distribution.
 *
 * @param rng Random number generator.
 * @param populationSize Population size.
 * @param numberOfSuccesses Number of successes in the population.
 * @param sampleSize Sample size.
 * @throws NotPositiveException if {@code numberOfSuccesses < 0}.
 * @throws NotStrictlyPositiveException if {@code populationSize <= 0}.
 * @throws NumberIsTooLargeException if {@code numberOfSuccesses > populationSize},
 * or {@code sampleSize > populationSize}.
 * @since 3.1
 */
public HypergeometricDistribution(RandomGenerator rng,
                                  int populationSize,
                                  int numberOfSuccesses,
                                  int sampleSize)
throws NotPositiveException, NotStrictlyPositiveException, NumberIsTooLargeException {
    super(rng);

    if (populationSize <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.POPULATION_SIZE,
                                               populationSize);
    }
    if (numberOfSuccesses < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_SUCCESSES,
                                       numberOfSuccesses);
    }
    if (sampleSize < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES,
                                       sampleSize);
    }

    if (numberOfSuccesses > populationSize) {
        throw new NumberIsTooLargeException(LocalizedFormats.NUMBER_OF_SUCCESS_LARGER_THAN_POPULATION_SIZE,
                                            numberOfSuccesses, populationSize, true);
    }
    if (sampleSize > populationSize) {
        throw new NumberIsTooLargeException(LocalizedFormats.SAMPLE_SIZE_LARGER_THAN_POPULATION_SIZE,
                                            sampleSize, populationSize, true);
    }

    this.numberOfSuccesses = numberOfSuccesses;
    this.populationSize = populationSize;
    this.sampleSize = sampleSize;
}
 
Example 16
Source File: Math_2_HypergeometricDistribution_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Creates a new hypergeometric distribution.
 *
 * @param rng Random number generator.
 * @param populationSize Population size.
 * @param numberOfSuccesses Number of successes in the population.
 * @param sampleSize Sample size.
 * @throws NotPositiveException if {@code numberOfSuccesses < 0}.
 * @throws NotStrictlyPositiveException if {@code populationSize <= 0}.
 * @throws NumberIsTooLargeException if {@code numberOfSuccesses > populationSize},
 * or {@code sampleSize > populationSize}.
 * @since 3.1
 */
public HypergeometricDistribution(RandomGenerator rng,
                                  int populationSize,
                                  int numberOfSuccesses,
                                  int sampleSize)
throws NotPositiveException, NotStrictlyPositiveException, NumberIsTooLargeException {
    super(rng);

    if (populationSize <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.POPULATION_SIZE,
                                               populationSize);
    }
    if (numberOfSuccesses < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_SUCCESSES,
                                       numberOfSuccesses);
    }
    if (sampleSize < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES,
                                       sampleSize);
    }

    if (numberOfSuccesses > populationSize) {
        throw new NumberIsTooLargeException(LocalizedFormats.NUMBER_OF_SUCCESS_LARGER_THAN_POPULATION_SIZE,
                                            numberOfSuccesses, populationSize, true);
    }
    if (sampleSize > populationSize) {
        throw new NumberIsTooLargeException(LocalizedFormats.SAMPLE_SIZE_LARGER_THAN_POPULATION_SIZE,
                                            sampleSize, populationSize, true);
    }

    this.numberOfSuccesses = numberOfSuccesses;
    this.populationSize = populationSize;
    this.sampleSize = sampleSize;
}
 
Example 17
Source File: Math_2_HypergeometricDistribution_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Creates a new hypergeometric distribution.
 *
 * @param rng Random number generator.
 * @param populationSize Population size.
 * @param numberOfSuccesses Number of successes in the population.
 * @param sampleSize Sample size.
 * @throws NotPositiveException if {@code numberOfSuccesses < 0}.
 * @throws NotStrictlyPositiveException if {@code populationSize <= 0}.
 * @throws NumberIsTooLargeException if {@code numberOfSuccesses > populationSize},
 * or {@code sampleSize > populationSize}.
 * @since 3.1
 */
public HypergeometricDistribution(RandomGenerator rng,
                                  int populationSize,
                                  int numberOfSuccesses,
                                  int sampleSize)
throws NotPositiveException, NotStrictlyPositiveException, NumberIsTooLargeException {
    super(rng);

    if (populationSize <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.POPULATION_SIZE,
                                               populationSize);
    }
    if (numberOfSuccesses < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_SUCCESSES,
                                       numberOfSuccesses);
    }
    if (sampleSize < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES,
                                       sampleSize);
    }

    if (numberOfSuccesses > populationSize) {
        throw new NumberIsTooLargeException(LocalizedFormats.NUMBER_OF_SUCCESS_LARGER_THAN_POPULATION_SIZE,
                                            numberOfSuccesses, populationSize, true);
    }
    if (sampleSize > populationSize) {
        throw new NumberIsTooLargeException(LocalizedFormats.SAMPLE_SIZE_LARGER_THAN_POPULATION_SIZE,
                                            sampleSize, populationSize, true);
    }

    this.numberOfSuccesses = numberOfSuccesses;
    this.populationSize = populationSize;
    this.sampleSize = sampleSize;
}
 
Example 18
Source File: Cardumen_0036_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Creates a new hypergeometric distribution.
 *
 * @param rng Random number generator.
 * @param populationSize Population size.
 * @param numberOfSuccesses Number of successes in the population.
 * @param sampleSize Sample size.
 * @throws NotPositiveException if {@code numberOfSuccesses < 0}.
 * @throws NotStrictlyPositiveException if {@code populationSize <= 0}.
 * @throws NumberIsTooLargeException if {@code numberOfSuccesses > populationSize},
 * or {@code sampleSize > populationSize}.
 * @since 3.1
 */
public HypergeometricDistribution(RandomGenerator rng,
                                  int populationSize,
                                  int numberOfSuccesses,
                                  int sampleSize)
throws NotPositiveException, NotStrictlyPositiveException, NumberIsTooLargeException {
    super(rng);

    if (populationSize <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.POPULATION_SIZE,
                                               populationSize);
    }
    if (numberOfSuccesses < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_SUCCESSES,
                                       numberOfSuccesses);
    }
    if (sampleSize < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES,
                                       sampleSize);
    }

    if (numberOfSuccesses > populationSize) {
        throw new NumberIsTooLargeException(LocalizedFormats.NUMBER_OF_SUCCESS_LARGER_THAN_POPULATION_SIZE,
                                            numberOfSuccesses, populationSize, true);
    }
    if (sampleSize > populationSize) {
        throw new NumberIsTooLargeException(LocalizedFormats.SAMPLE_SIZE_LARGER_THAN_POPULATION_SIZE,
                                            sampleSize, populationSize, true);
    }

    this.numberOfSuccesses = numberOfSuccesses;
    this.populationSize = populationSize;
    this.sampleSize = sampleSize;
}
 
Example 19
Source File: HypergeometricDistribution.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new hypergeometric distribution.
 *
 * @param rng Random number generator.
 * @param populationSize Population size.
 * @param numberOfSuccesses Number of successes in the population.
 * @param sampleSize Sample size.
 * @throws NotPositiveException if {@code numberOfSuccesses < 0}.
 * @throws NotStrictlyPositiveException if {@code populationSize <= 0}.
 * @throws NumberIsTooLargeException if {@code numberOfSuccesses > populationSize},
 * or {@code sampleSize > populationSize}.
 * @since 3.1
 */
public HypergeometricDistribution(RandomGenerator rng,
                                  int populationSize,
                                  int numberOfSuccesses,
                                  int sampleSize)
throws NotPositiveException, NotStrictlyPositiveException, NumberIsTooLargeException {
    super(rng);

    if (populationSize <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.POPULATION_SIZE,
                                               populationSize);
    }
    if (numberOfSuccesses < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_SUCCESSES,
                                       numberOfSuccesses);
    }
    if (sampleSize < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES,
                                       sampleSize);
    }

    if (numberOfSuccesses > populationSize) {
        throw new NumberIsTooLargeException(LocalizedFormats.NUMBER_OF_SUCCESS_LARGER_THAN_POPULATION_SIZE,
                                            numberOfSuccesses, populationSize, true);
    }
    if (sampleSize > populationSize) {
        throw new NumberIsTooLargeException(LocalizedFormats.SAMPLE_SIZE_LARGER_THAN_POPULATION_SIZE,
                                            sampleSize, populationSize, true);
    }

    this.numberOfSuccesses = numberOfSuccesses;
    this.populationSize = populationSize;
    this.sampleSize = sampleSize;
}
 
Example 20
Source File: Cardumen_00162_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Creates a new hypergeometric distribution.
 *
 * @param rng Random number generator.
 * @param populationSize Population size.
 * @param numberOfSuccesses Number of successes in the population.
 * @param sampleSize Sample size.
 * @throws NotPositiveException if {@code numberOfSuccesses < 0}.
 * @throws NotStrictlyPositiveException if {@code populationSize <= 0}.
 * @throws NumberIsTooLargeException if {@code numberOfSuccesses > populationSize},
 * or {@code sampleSize > populationSize}.
 * @since 3.1
 */
public HypergeometricDistribution(RandomGenerator rng,
                                  int populationSize,
                                  int numberOfSuccesses,
                                  int sampleSize)
throws NotPositiveException, NotStrictlyPositiveException, NumberIsTooLargeException {
    super(rng);

    if (populationSize <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.POPULATION_SIZE,
                                               populationSize);
    }
    if (numberOfSuccesses < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_SUCCESSES,
                                       numberOfSuccesses);
    }
    if (sampleSize < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES,
                                       sampleSize);
    }

    if (numberOfSuccesses > populationSize) {
        throw new NumberIsTooLargeException(LocalizedFormats.NUMBER_OF_SUCCESS_LARGER_THAN_POPULATION_SIZE,
                                            numberOfSuccesses, populationSize, true);
    }
    if (sampleSize > populationSize) {
        throw new NumberIsTooLargeException(LocalizedFormats.SAMPLE_SIZE_LARGER_THAN_POPULATION_SIZE,
                                            sampleSize, populationSize, true);
    }

    this.numberOfSuccesses = numberOfSuccesses;
    this.populationSize = populationSize;
    this.sampleSize = sampleSize;
}