SourcePro® 2024.1 |
SourcePro® API Reference Guide |
Used to generate random numbers from an exponential distribution. More...
#include <rw/rand.h>
Public Member Functions | |
RWTRandExponential (const Generator &g, double lam=1) | |
RWTRandExponential (const RWTRandExponential< Generator > &g) | |
RWTRandExponential (double lam=1) | |
double | highBound () const |
double | lambda () const |
double | lowBound () const |
virtual double | operator() () |
virtual size_t | operator() (double *out, size_t n) |
void | setLambda (double l) |
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 RWTRandExponential generates random numbers from an exponential distribution:
\[ g(w) = \left\{\begin{matrix} \lambda e^{-\lambda \omega } , & 0 < w \\ 0 \hfill, & w \leq 0 \end{matrix}\right. \]
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 exponentially distributed random numbers may be changed by varying the Generator template parameter responsible for generating these 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.
RWTRandExponential< Generator >::RWTRandExponential | ( | double | lam = 1 | ) |
Constructs a generator with lambda = lam.
RWTRandExponential< Generator >::RWTRandExponential | ( | const RWTRandExponential< Generator > & | g | ) |
Constructs self as a copy of g.
RWTRandExponential< Generator >::RWTRandExponential | ( | const Generator & | g, |
double | lam = 1 ) |
Constructs a generator with underlying uniform [0, 1] generator g lambda=lam.
double RWTRandExponential< Generator >::highBound | ( | ) | const |
Returns the upper bound of 99% of the distribution.
|
inline |
Returns the value of lambda for the distribution.
double RWTRandExponential< Generator >::lowBound | ( | ) | const |
Returns the lower bound of 99% of 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.
|
inline |
Sets the value of lambda
for the distribution to l.
Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |