Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://www.atnf.csiro.au/computing/software/casacore/casacore-1.2.0/doc/html/classcasa_1_1Random.html
Дата изменения: Unknown Дата индексирования: Mon Feb 14 20:21:48 2011 Кодировка: Поисковые слова: crab nebula |
Base class for random number distributions. More...
#include <Random.h>
Public Types | |
enum | Types { BINOMIAL, DISCRETEUNIFORM, ERLANG, GEOMETRIC, HYPERGEOMETRIC, NORMAL, LOGNORMAL, NEGATIVEEXPONENTIAL, POISSON, UNIFORM, WEIBULL, UNKNOWN, NUMBER_TYPES } |
This enumerator lists all the predefined random number distributions. More... | |
Public Member Functions | |
virtual | ~Random () |
A virtual destructor is needed to ensure that the destructor of derived classes gets used. | |
virtual Double | operator() ()=0 |
This function returns a random number from the appropriate distribution. | |
RNG * | generator () |
Functions that allow you to access and change the class that generates the random bits. | |
void | generator (RNG *p) |
virtual void | setParameters (const Vector< Double > &parms)=0 |
These function allow you to manipulate the parameters (mean variance etc. | |
virtual Vector< Double > | parameters () const =0 |
virtual Bool | checkParameters (const Vector< Double > &parms) const =0 |
Static Public Member Functions | |
static String | asString (Random::Types type) |
Convert the enumerator to a lower-case string. | |
static Random::Types | asType (const String &str) |
Convert the string to enumerator. | |
static Random * | construct (Random::Types type, RNG *gen) |
Convert the Random::Type enumerator to a specific object (derived from Random but upcast to a Random object). | |
static Vector< Double > | defaultParameters (Random::Types type) |
returns the default parameters for the specified distribution. | |
Protected Member Functions | |
Random (RNG *generator) | |
Protected Attributes | |
RNG * | itsRNG |
Base class for random number distributions.
Public interface
A random number generator may be declared by first constructing a RNG
object and then a Random
. For example,
ACG gen(10, 20); NegativeExpntl rnd (1.0, &gen);
declares an additive congruential generator with seed 10 and table size 20, that is used to generate exponentially distributed values with mean of 1.0.
The virtual member Random::operator()
is the common way of extracting a random number from a particular distribution. The base class, Random
does not implement operator()
. This is performed by each of the derived classes. Thus, given the above declaration of rnd
, new random values may be obtained via, for example, Double nextExpRand = rnd();
Currently, the following subclasses are provided:
Definition at line 425 of file Random.h.
enum casa::Random::Types |
This enumerator lists all the predefined random number distributions.
virtual casa::Random::~Random | ( | ) | [virtual] |
A virtual destructor is needed to ensure that the destructor of derived classes gets used.
Not that this destructor does NOT delete the pointer to the RNG object
casa::Random::Random | ( | RNG * | generator | ) | [inline, protected] |
static String casa::Random::asString | ( | Random::Types | type | ) | [static] |
Convert the enumerator to a lower-case string.
static Random::Types casa::Random::asType | ( | const String & | str | ) | [static] |
Convert the string to enumerator.
The parsing of the string is case insensitive. Returns the Random::UNKNOWN value if the string does not cotrtrespond to any of the enumerators.
static Random* casa::Random::construct | ( | Random::Types | type, | |
RNG * | gen | |||
) | [static] |
Convert the Random::Type enumerator to a specific object (derived from Random but upcast to a Random object).
Returns a null pointer if the object could not be constructed. This will occur is the enumerator is UNKNOWN or NUMBER_TYPES or there is insufficient memory. The caller of this function is responsible for deleting the pointer.
static Vector<Double> casa::Random::defaultParameters | ( | Random::Types | type | ) | [static] |
returns the default parameters for the specified distribution.
Returns an empty Vector if a non-predifined distribution is used.
RNG * casa::Random::generator | ( | ) | [inline] |