Fennel: BernoulliRng Class Reference (original) (raw)

BernoulliRng produces a series of values with a Bernoulli distribution. More...

#include <[BernoulliRng.h](BernoulliRng%5F8h-source.html)>

List of all members.

Public Member Functions
BernoulliRng (float successProbability)
void reseed (boost::uint32_t seed)
Reseed the uniform random number generator that forms the basis of the value stream.
bool nextValue ()
Returns the next value.
Private Attributes
boost::mt19937 uniformRng
uniform random number generator
boost::bernoulli_distribution< float > bernoulliDist
Bernoulli distribution converter.
boost::variate_generator< boost::mt19937 &, boost::bernoulli_distribution< float > > rng
Variate generator to produce value with Bernoulli distribution from a uniform RNG.

Detailed Description

BernoulliRng produces a series of values with a Bernoulli distribution.

That is, a series of values where the value true (1) appears with success probability p and the values false (0) appears with failure probability q = 1 - p. This class simply combines boost::mt19937 (a Meresenne Twister PRNG) with boost::bernoulli_distribution using boost::variate_generator.

Version:

Id

//open/dev/fennel/common/BernoulliRng.h#5

Definition at line 41 of file BernoulliRng.h.


Constructor & Destructor Documentation

BernoulliRng::BernoulliRng ( float successProbability ) [explicit]

Member Function Documentation

Reseed the uniform random number generator that forms the basis of the value stream.

The RNG will seed itself initially, but it's recommended that you call this method with a better seed. The usual warnings about not calling this method frequently with an input of 'time(0)' apply.

Definition at line 34 of file BernoulliRng.cpp.

References uniformRng.

| bool BernoulliRng::nextValue | ( | | ) | | ---------------------------- | - | | - |

Returns the next value.

Definition at line 39 of file BernoulliRng.cpp.

References rng.

00040 { 00041 return rng(); 00042 }


Member Data Documentation

boost::variate_generator< boost::mt19937 &, boost::bernoulli_distribution > BernoulliRng::rng [private]

Variate generator to produce value with Bernoulli distribution from a uniform RNG.

Definition at line 60 of file BernoulliRng.h.

Referenced by nextValue().


The documentation for this class was generated from the following files:


Generated on Mon Jun 22 04:00:24 2009 for Fennel by doxygen 1.5.1