jhplot.math.num.random
Class BernoulliRandomVariable

java.lang.Object
  extended by jhplot.math.num.random.AbstractDiscreteRandomVariable
      extended by jhplot.math.num.random.BernoulliRandomVariable
All Implemented Interfaces:
DiscreteRandomVariable

public class BernoulliRandomVariable
extends AbstractDiscreteRandomVariable

A random variable generator for the Bernoulli distribution.

References:

  1. Wikipedia contributors, "Bernoulli Distribution," Wikipedia, The Free Encyclopedia, http://en.wikipedia.org/wiki/Bernoulli_distribution

Since:
1.3

Constructor Summary
BernoulliRandomVariable()
          Default constructor.
BernoulliRandomVariable(double p)
          Create a random variable with the given probability of success.
BernoulliRandomVariable(double p, RNG source)
          Create a random variable with the given probability of success and source generator.
 
Method Summary
 int nextRandomVariable()
          Access the next random variable from this generator.
static int nextRandomVariable(double p, RNG source)
          Access the next random variable using the given generator.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BernoulliRandomVariable

public BernoulliRandomVariable()
Default constructor. The probability of success is set to 0.5.


BernoulliRandomVariable

public BernoulliRandomVariable(double p)
Create a random variable with the given probability of success.

Parameters:
p - the probability of success.

BernoulliRandomVariable

public BernoulliRandomVariable(double p,
                               RNG source)
Create a random variable with the given probability of success and source generator.

Parameters:
p - the probability of success.
source - the source generator.
Method Detail

nextRandomVariable

public static int nextRandomVariable(double p,
                                     RNG source)
Access the next random variable using the given generator.

Parameters:
p - the probability of success.
source - the source generator.
Returns:
the next random variable.

nextRandomVariable

public int nextRandomVariable()
Access the next random variable from this generator.

Returns:
the next random variable.


jHepWork 3.0 ©