Loading...
Searching...
No Matches
casacore::DiscreteUniform Class Reference
casa package (libcasa_casa) » BasicMath_module

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
Public Member Functions inherited from casacore::Random
virtual | ~Random ()
| A virtual destructor is needed to ensure that the destructor of derived classes gets used.
RNG * | generator ()
| Functions that allow you to access and change the class that generates the random bits.
void | generator (RNG *p)

## Static Private Member Functions

static Double | calcDelta (Int low, Int high)

## Private Attributes

Int | itsLow
Int | itsHigh
Double | itsDelta

## Additional Inherited Members

Public Types inherited from casacore::Random
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...
Static Public Member Functions inherited from casacore::Random
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 inherited from casacore::Random
| Random (RNG *generator)
Protected Attributes inherited from casacore::Random
RNG * | itsRNG

## Detailed Description

Discrete uniform distribution.

### Synopsis

The DiscreteUniform class implements a quantized uniform random variable over the closed interval ranging from [low..high]. The low parameter is the lowest possible return value and the high parameter is the highest. The operator() 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.

### Example

### Thrown Exceptions

- AipsError: if bad values for the arguments are given, as specified above.

### To Do

- Nothing I hope!

Definition at line 660 of file Random.h.

## Constructor & Destructor Documentation

## DiscreteUniform()

casacore::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.

References high(), and low().

## ~DiscreteUniform()

virtual casacore::DiscreteUniform::~DiscreteUniform | ( |  | ) |

virtual

The destructor is trivial.

## Member Function Documentation

## asInt()

Int casacore::DiscreteUniform::asInt | ( |  | ) |

## calcDelta()

Double casacore::DiscreteUniform::calcDelta | ( | Int | low,
|  | Int | high )

static private

References high(), and low().

## checkParameters()

virtual Bool casacore::DiscreteUniform::checkParameters | ( | const Vector< Double > & | parms | ) | const

virtual

Implements casacore::Random.

## high() [1/2]

Int casacore::DiscreteUniform::high | ( |  | ) | const

inline

Definition at line 711 of file Random.h.

References itsHigh.

Referenced by calcDelta(), DiscreteUniform(), and range().

## high() [2/2]

void casacore::DiscreteUniform::high | ( | Int | x | ) |

## low() [1/2]

Int casacore::DiscreteUniform::low | ( |  | ) | const

inline

Functions that allow you to query and change the parameters of the discrete uniform distribution.

Definition at line 707 of file Random.h.

References itsLow.

Referenced by calcDelta(), DiscreteUniform(), and range().

## low() [2/2]

void casacore::DiscreteUniform::low | ( | Int | x | ) |

## operator()()

virtual Double casacore::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 casacore::Random.

## parameters()

virtual Vector< Double > casacore::DiscreteUniform::parameters | ( |  | ) | const

virtual

Implements casacore::Random.

## range()

void casacore::DiscreteUniform::range | ( | Int | low,
|  | Int | high )

References high(), and low().

## setParameters()

virtual void casacore::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 casacore::Random.

## Member Data Documentation

## itsDelta

Double casacore::DiscreteUniform::itsDelta

private

Definition at line 704 of file Random.h.

## itsHigh

Int casacore::DiscreteUniform::itsHigh

private

Definition at line 703 of file Random.h.

Referenced by high().

## itsLow

Int casacore::DiscreteUniform::itsLow

private

Definition at line 702 of file Random.h.

Referenced by low().

The documentation for this class was generated from the following file:

- casa/BasicMath/Random.h