ImageScience 3.0.0

imagescience.random
Class BinomialGenerator

java.lang.Object
  extended by imagescience.random.BinomialGenerator
All Implemented Interfaces:
RandomGenerator

public class BinomialGenerator
extends java.lang.Object
implements RandomGenerator

Binomial random number generator. This implementation is based on the algorithm described by W. H. Press, S. A. Teukolsky, W. T. Vetterling, B. P. Flannery, Numerical Recipes in C: The Art of Scientific Computing (2nd edition), Cambridge University Press, Cambridge, 1992, Section 7.3, and uses UniformGenerator as a source of uniform random numbers.


Constructor Summary
BinomialGenerator()
          Constructs a generator of random numbers from the binomial distribution with one trial of probability 0.5 and initialized with a random seed.
BinomialGenerator(int seed)
          Constructs a generator of random numbers from the binomial distribution with one trial of probability 0.5 and initialized with the given seed.
BinomialGenerator(int trials, double probability)
          Constructs a generator of random numbers from the binomial distribution with given number of trials of given probability and initialized with a random seed.
BinomialGenerator(int trials, double probability, int seed)
          Constructs a generator of random numbers from the binomial distribution with given number of trials of given probability and initialized with the given seed.
 
Method Summary
 double next()
          Returns a random number from the binomial distribution with number of trials and probability specified at construction.
 double next(int trials, double probability)
          Returns a random number from the binomial distribution with given number of trials of given probability.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BinomialGenerator

public BinomialGenerator()
Constructs a generator of random numbers from the binomial distribution with one trial of probability 0.5 and initialized with a random seed.


BinomialGenerator

public BinomialGenerator(int seed)
Constructs a generator of random numbers from the binomial distribution with one trial of probability 0.5 and initialized with the given seed.

Parameters:
seed - The seed used for initialization of the generator.

BinomialGenerator

public BinomialGenerator(int trials,
                         double probability)
Constructs a generator of random numbers from the binomial distribution with given number of trials of given probability and initialized with a random seed.

Parameters:
trials - The number of trials. Must be larger than or equal to 0.
probability - The probability for each trial. Must be in the range [0,1].
Throws:
java.lang.IllegalArgumentException - If trials is less than 0, or if probability is outside the range [0,1].

BinomialGenerator

public BinomialGenerator(int trials,
                         double probability,
                         int seed)
Constructs a generator of random numbers from the binomial distribution with given number of trials of given probability and initialized with the given seed.

Parameters:
trials - The number of trials. Must be larger than or equal to 0.
probability - The probability for each trial. Must be in the range [0,1].
seed - The seed used for initialization of the generator.
Throws:
java.lang.IllegalArgumentException - If trials is less than 0, or if probability is outside the range [0,1].
Method Detail

next

public double next()
Returns a random number from the binomial distribution with number of trials and probability specified at construction.

Specified by:
next in interface RandomGenerator
Returns:
A random number from the binomial distribution with number of trials and probability specified at construction.

next

public double next(int trials,
                   double probability)
Returns a random number from the binomial distribution with given number of trials of given probability.

Parameters:
trials - The number of trials. Must be larger than or equal to 0.
probability - The probability for each trial. Must be in the range [0,1].
Returns:
A random number from the binomial distribution with given number of trials of given probability.
Throws:
java.lang.IllegalArgumentException - If trials is less than 0, or if probability is outside the range [0,1].

ImageScience 3.0.0

Copyright (C) Erik Meijering. Permission to use this software and corresponding documentation for educational, research, and not-for-profit purposes, without a fee and without a signed licensing agreement, is granted, subject to the following terms and conditions.

IT IS NOT ALLOWED TO REDISTRIBUTE, SELL, OR LEASE THIS SOFTWARE, OR DERIVATIVE WORKS THEREOF, WITHOUT PERMISSION IN WRITING FROM THE COPYRIGHT HOLDER. THE COPYRIGHT HOLDER IS FREE TO MAKE VERSIONS OF THE SOFTWARE AVAILABLE FOR A FEE OR COMMERCIALLY ONLY.

IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OF ANY KIND WHATSOEVER, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.

THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE EXPRESS OR IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE AND CORRESPONDING DOCUMENTATION IS PROVIDED "AS IS". THE COPYRIGHT HOLDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.