BernoulliRng Class Reference

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

#include <BernoulliRng.h>

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.

Author:
Stephan Zuercher
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]

Definition at line 28 of file BernoulliRng.cpp.

00029     : bernoulliDist(successProbability), rng(uniformRng, bernoulliDist)
00030 {
00031 }


Member Function Documentation

void BernoulliRng::reseed ( boost::uint32_t  seed  ) 

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.

00035 {
00036     uniformRng.seed(seed);
00037 }

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::mt19937 BernoulliRng::uniformRng [private]

uniform random number generator

Definition at line 47 of file BernoulliRng.h.

Referenced by reseed().

boost::bernoulli_distribution<float> BernoulliRng::bernoulliDist [private]

Bernoulli distribution converter.

Definition at line 52 of file BernoulliRng.h.

boost::variate_generator< boost::mt19937 &, boost::bernoulli_distribution<float> > 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