casa
$Rev:20696$
|
Discrete uniform distribution. More...
#include <Random.h>
Public Member Functions | |
DiscreteUniform (RNG *gen, Int low=-1, Int high=1) | |
Construct a random number generator for a discrete uniform distribution. | |
virtual | ~DiscreteUniform () |
The destructor is trivial. | |
virtual Double | operator() () |
Returns a value from the discrete uniform distribution. | |
Int | asInt () |
Int | low () const |
Functions that allow you to query and change the parameters of the discrete uniform distribution. | |
void | low (Int x) |
Int | high () const |
void | high (Int x) |
void | range (Int low, Int high) |
virtual void | setParameters (const Vector< Double > &parms) |
These function allow you to manipulate the parameters (low & high) described above through the base class. | |
virtual Vector< Double > | parameters () const |
virtual Bool | checkParameters (const Vector< Double > &parms) const |
Static Private Member Functions | |
static Double | calcDelta (Int low, Int high) |
Private Attributes | |
Int | itsLow |
Int | itsHigh |
Double | itsDelta |
Discrete uniform distribution.
The <tt>DiscreteUniform</tt> class implements a quantized uniform random variable over the closed interval ranging from <tt>[low..high]</tt>. The <tt>low</tt> parameter is the lowest possible return value and the <tt>high</tt> parameter is the highest. The <tt>operator()</tt> functions returns a value from this distribution. It is possible to get this same value as an integer using the asInt function. It is assumed that low limit is less than the high limit and an AipsError exception thrown if this is not true. The remaining members allow you to read and set the parameters. <h3>Example</h3> @anchor Random_example
casa::DiscreteUniform::DiscreteUniform | ( | RNG * | gen, |
Int | low = -1 , |
||
Int | high = 1 |
||
) |
Construct a random number generator for a discrete uniform distribution.
The first argument is a class that produces random bits. This pointer is NOT taken over by this class and the user is responsible for deleting it. The second and third arguments define the range of possible return values for this distribution as described in the synopsis.
virtual casa::DiscreteUniform::~DiscreteUniform | ( | ) | [virtual] |
The destructor is trivial.
static Double casa::DiscreteUniform::calcDelta | ( | Int | low, |
Int | high | ||
) | [static, private] |
virtual Bool casa::DiscreteUniform::checkParameters | ( | const Vector< Double > & | parms | ) | const [virtual] |
Implements casa::Random.
Int casa::DiscreteUniform::high | ( | ) | const [inline] |
void casa::DiscreteUniform::high | ( | Int | x | ) |
Int casa::DiscreteUniform::low | ( | ) | const [inline] |
void casa::DiscreteUniform::low | ( | Int | x | ) |
virtual Double casa::DiscreteUniform::operator() | ( | ) | [virtual] |
Returns a value from the discrete uniform distribution.
The returned value is a integer and using the asInt function bypasses the conversion to a floating point number.
Implements casa::Random.
virtual Vector<Double> casa::DiscreteUniform::parameters | ( | ) | const [virtual] |
Implements casa::Random.
void casa::DiscreteUniform::range | ( | Int | low, |
Int | high | ||
) |
virtual void casa::DiscreteUniform::setParameters | ( | const Vector< Double > & | parms | ) | [virtual] |
These function allow you to manipulate the parameters (low & high) described above through the base class.
The Vectors must always be of length two.
Implements casa::Random.
Double casa::DiscreteUniform::itsDelta [private] |
Int casa::DiscreteUniform::itsHigh [private] |
Int casa::DiscreteUniform::itsLow [private] |