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

Binomial distribution. More...

`#include <Random.h>`

## Public Member Functions

| Binomial (RNG *gen, uInt n=1, Double p=0.5)
| Construct a random number generator for a binomial distribution.
virtual | ~Binomial ()
| The destructor is trivial.
virtual Double | operator() ()
| Returns a value from the Binomial distribution.
uInt | asInt ()
uInt | n () const
| Functions that allow you to query and change the parameters of the binomial distribution.
void | n (uInt newN)
void | n (Double newN)
Double | p () const
void | p (Double newP)
virtual void | setParameters (const Vector< Double > &parms)
| These function allow you to manipulate the parameters (n & p) 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)

## Private Attributes

uInt | itsN
Double | itsP

## 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

Binomial distribution.

### Synopsis

The binomial distribution models successfully drawing items from a pool. n is the number of items in the pool, and p, is the probability of each item being successfully drawn. The operator() functions returns an integral value indicating the number of items actually drawn from the pool. It is possible to get this same value as an integer using the asInt function.

It is assumed that n > 0 and 0 <= p <= 1 an AipsError exception thrown if it 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 580 of file Random.h.

## Constructor & Destructor Documentation

## Binomial()

casacore::Binomial::Binomial | ( | RNG * | gen,
|  | uInt | n = 1,
|  | Double | p = 0.5 )

Construct a random number generator for a binomial 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 are the parameters are the Binomial distribution as described in the synopsis.

References n(), and p().

## ~Binomial()

virtual casacore::Binomial::~Binomial | ( |  | ) |

virtual

The destructor is trivial.

## Member Function Documentation

## asInt()

uInt casacore::Binomial::asInt | ( |  | ) |

## checkParameters()

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

virtual

Implements casacore::Random.

## n() [1/3]

uInt casacore::Binomial::n | ( |  | ) | const

inline

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

Definition at line 623 of file Random.h.

References itsN.

Referenced by Binomial().

## n() [2/3]

void casacore::Binomial::n | ( | Double | newN | ) |

## n() [3/3]

void casacore::Binomial::n | ( | uInt | newN | ) |

## operator()()

virtual Double casacore::Binomial::operator() | ( |  | ) |

virtual

Returns a value from the Binomial distribution.

The returned value is a non-negative integer and using the asInt function bypasses the conversion to a floating point number.

Implements casacore::Random.

## p() [1/2]

Double casacore::Binomial::p | ( |  | ) | const

inline

Definition at line 627 of file Random.h.

References itsP.

Referenced by Binomial().

## p() [2/2]

void casacore::Binomial::p | ( | Double | newP | ) |

## parameters()

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

virtual

Implements casacore::Random.

## setParameters()

virtual void casacore::Binomial::setParameters | ( | const Vector< Double > & | parms | ) |

virtual

These function allow you to manipulate the parameters (n & p) described above through the base class.

The Vectors must always be of length two.

Implements casacore::Random.

## Member Data Documentation

## itsN

uInt casacore::Binomial::itsN

private

Definition at line 619 of file Random.h.

Referenced by n().

## itsP

Double casacore::Binomial::itsP

private

Definition at line 620 of file Random.h.

Referenced by p().

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

- casa/BasicMath/Random.h