Used to generate random numbers from a uniform distribution in an interval [a, b]. More...
#include <rw/rand.h>
Public Member Functions | |
RWTRandUniform () | |
RWTRandUniform (double a, double b) | |
RWTRandUniform (const RWTRandUniform< Generator > &g) | |
RWTRandUniform (const Generator &g, double a=0, double b=1) | |
double | highBound () const |
double | lowBound () const |
virtual double | operator() () |
virtual size_t | operator() (double *out, size_t n) |
void | setRange (double a, double b) |
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 RWTRandUniform generates random numbers from a uniform distribution in an interval [a, b]. 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 uniform number generator may be changed by varying the Generator template parameter 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 may be used.
RWTRandUniform< Generator >::RWTRandUniform | ( | ) |
Constructs a generator with default range [0, 1].
RWTRandUniform< Generator >::RWTRandUniform | ( | double | a, |
double | b | ||
) |
Constructs a generator with range [a, b].
RWTRandUniform< Generator >::RWTRandUniform | ( | const RWTRandUniform< Generator > & | g | ) |
Constructs self as a copy of g.
RWTRandUniform< Generator >::RWTRandUniform | ( | const Generator & | g, |
double | a = 0 , |
||
double | b = 1 |
||
) |
Constructs a generator with underlying uniform [0, 1] generator g and range [a, b]
double RWTRandUniform< Generator >::highBound | ( | ) | const |
Returns the upper range value.
double RWTRandUniform< Generator >::lowBound | ( | ) | const |
Returns the lower range value.
|
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 RWTRandUniform< Generator >::setRange | ( | double | a, |
double | b | ||
) |
Sets the range to [a, b].
Copyright © 2021 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |