SourcePro® 2023.1 |
SourcePro® API Reference Guide |
Used to generate random numbers from a gamma distribution. More...
#include <rw/rand.h>
Public Member Functions | |
RWTRandGamma (int ord=1) | |
RWTRandGamma (const RWTRandGamma< Generator > &g) | |
RWTRandGamma (const Generator &g, int ord=1) | |
virtual double | operator() () |
virtual size_t | operator() (double *out, size_t n) |
int | order () const |
void | setOrder (int order) |
Public Member Functions inherited from RWTRand< Generator > | |
RWTRand () | |
RWTRand (const Generator &g) | |
RWTRand (const RWTRand< Generator > &x) | |
const Generator & | generator () const |
Generator & | generator () |
void | setGenerator (const Generator &x) |
void | setGenerator (const RWTRand< Generator > &x) |
Class RWTRandGamma generates random numbers from a gamma distribution:
\[ f(x) = \frac{x^{a-1}e^{-x}}{\Gamma (a)}, x > 0 \]
where a
is the order. 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 gamma 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.
RWTRandGamma< Generator >::RWTRandGamma | ( | int | ord = 1 | ) |
Constructs a generator with order = ord.
RWTRandGamma< Generator >::RWTRandGamma | ( | const RWTRandGamma< Generator > & | g | ) |
Constructs self as a copy of g.
RWTRandGamma< Generator >::RWTRandGamma | ( | const Generator & | g, |
int | ord = 1 |
||
) |
Constructs a generator with underlying uniform [0, 1] generator g order = ord
.
|
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.
|
inline |
Returns the value of order for the distribution.
|
inline |
Sets the value of lambda for the distribution to l.
Copyright © 2023 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |