SourcePro® 2024.1 |
SourcePro® API Reference Guide |
Used to generate random numbers from a Poisson distribution. More...
#include <rw/rand.h>
Public Member Functions | |
RWTRandPoisson (const Generator &g, double m=1) | |
RWTRandPoisson (const RWTRandPoisson< Generator > &g) | |
RWTRandPoisson (double m=1) | |
double | mean () const |
virtual double | operator() () |
virtual size_t | operator() (double *out, size_t n) |
void | setMean (double m) |
Public Member Functions inherited from RWTRand< Generator > | |
RWTRand () | |
RWTRand (const Generator &g) | |
RWTRand (const RWTRand< Generator > &x) | |
Generator & | generator () |
const Generator & | generator () const |
void | setGenerator (const Generator &x) |
void | setGenerator (const RWTRand< Generator > &x) |
Class RWTRandPoisson generates random numbers from a Poisson distribution:
\[ f(x) = \left\{\begin{matrix} \frac{\mu^xe^{- \mu}}{x!} & \text{x = 0, 1, 2, ...} \\ \text{0} & \text{otherwise} \end{matrix}\right. \]
where \( \mu\) is the mean. The algorithm used to generate the random numbers begins with random numbers generated from a uniform distribution on the interval [0, 1]. Thus, the speed and statistical properties of the Poisson random number generator may be varied by varying the Generator template parameter, which is responsible for generating the uniformly distributed numbers.
The class Generator must be a function object whose function call operator returns a uniform random double between 0 and 1. The class RWRandGenerator supplied with the library may be used.
RWTRandPoisson< Generator >::RWTRandPoisson | ( | double | m = 1 | ) |
Constructs a generator with mean = m.
RWTRandPoisson< Generator >::RWTRandPoisson | ( | const RWTRandPoisson< Generator > & | g | ) |
Constructs self as a copy of g.
RWTRandPoisson< Generator >::RWTRandPoisson | ( | const Generator & | g, |
double | m = 1 ) |
Constructs a generator with underlying uniform [0, 1] generator g and mean m.
|
inline |
Returns the value of mean for the distribution.
|
virtual |
Returns the next random number in the sequence.
Implements RWRandInterface.
|
virtual |
Assigns random numbers to n elements in out. Returns the number of random numbers generated.
Implements RWRandInterface.
void RWTRandPoisson< Generator >::setMean | ( | double | m | ) |
Sets the value of the mean of the distribution to m.
Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |