# HyperGeometric Class Reference

This class simulates a "Hyper %Geometric distribution". More...

#include <HyperGeometric.h>

Inheritance diagram for HyperGeometric:

List of all members.

## Public Member Functions

HyperGeometric (double mean=0, double variance=1)
Creates a new Hyper Geometric random generator instance and initializes the mean value and the variance of the distribution.
HyperGeometric (double mean, double variance, RNG &r)
Creates a new Hyper Geometric random generator instance by using the pseudo random number generator "r" for the determination of random values and initializes the mean value and the variance of the distribution.
double mean () const
Returns the current mean value of the distribution as stored in pMean.
double variance () const
Returns the current variance of the distribution as stored in pVariance.
void mean (double newMean)
Sets the current mean value of the distribution as stored in pMean to the new value "newMean".
void variance (double newVar)
Sets the current variance of the distribution as stored in pVariance to the new value "newVar".
double operator() ()
Returns a Hyper Geometric random number for the distribution with a probability that is calculated from the preset mean value pMean and variance pVariance.
double p (const double &) const
Just a dummy method to allow instantiation of the class.

## Protected Attributes

double pMean
The distribution's mean value , that is used to calculate the probability by , where is the distribution's variance as stored in pVariance.
double pVariance
The distribution's variance , that is used to calculate probability by , where is the distribution's mean value as stored in pMean.

## Detailed Description

This class simulates a "Hyper %Geometric distribution".

This class is derived from class RandomVar and the uniformally distributed pseudo random number values of the interval (0,1) are transformed to type "double" of the Hyper Geometric distribution.
The Hyper Geometric distribution is used, when you have two types of events. Guess, the number of events of type is and the number of events of type is , so we have a total number of events. Guess also, that we define the probability as the relation of the number of events of type to the total number of events (). Then the distribution is given by

with and being always integer values. calculates the probability, that you have events of type in a sample of size .
In contrast to the Binomial distribution, the Hyper Geometric distribution takes into account, that probability changes after each of the trials.
Taking the "urn model", the Hyper Geometric distribution simulates the drawing of balls from the urn without returning the drawn balls to the urn.

Date:
1995-01-01
Changes:
none
Status:
stable

Definition at line 90 of file HyperGeometric.h.

## Constructor & Destructor Documentation

 HyperGeometric::HyperGeometric ( double mean = 0, double variance = 1 )

Creates a new Hyper Geometric random generator instance and initializes the mean value and the variance of the distribution.

The distribution's mean value , that is stored in pMean is initialized by mean and the distribution's variance , that is stored in pVariance is initialized by variance.
Then the mean value and the variance are used to calculate the probability by .
will always be a value .
If you are calling this constructor with the default values mean = 0 and variance = 1, then the probability will be the default value .
For this instance, the default pseudo random number generator as member of class RandomVar is used.

Parameters:
 mean the initial value for the distribution's mean value from which the probability is calculated. The default mean value is zero. If you use a mean value less than or equal to zero, the probability will be set to "0." variance the initial value for the distribution's variance from which the probability is calculated. The default variance is "1"
Returns:
none
Date:
1995-01-01
Changes
none
Status
stable

Definition at line 91 of file HyperGeometric.cpp.

 HyperGeometric::HyperGeometric ( double mean, double variance, RNG & r )

Creates a new Hyper Geometric random generator instance by using the pseudo random number generator "r" for the determination of random values and initializes the mean value and the variance of the distribution.

Each instance of a Hyper Geometric random number generator is based on a generator, that is defined in class RNG and returns uniformally pseudo random numbers of the interval (0,1). By default, this is a global generator named RNG::globalRng and included as member in class RandomVar.
Here another pseudo random number generator r is used instead.
Additionally to defining the used pseudo random number generator, the distribution's mean value, that is stored in pMean is initialized by mean and the distribution's variance , that is stored in pVariance is initialized by variance.
Then the mean value and the variance are used to calculate the probability by .
will always be a value .

Parameters:
 mean the initial value for the distribution's mean value from which the probability is calculated. If you use a mean value less than or equal to zero, the probability will be set to "0." variance the initial value for the distribution's variance from which the probability is calculated. r the pseudo random number generator that is used
Returns:
none
Date:
1995-01-01
Changes
none
Status
stable

Definition at line 142 of file HyperGeometric.cpp.

## Member Function Documentation

 void HyperGeometric::mean ( double newMean )

Sets the current mean value of the distribution as stored in pMean to the new value "newMean".

The distribution's mean value is set to newMean and then the probability is recalculated by , where is the distribution's variance as stored in pVariance.

Parameters:
 newMean the new value for the distribution's mean value (pMean)
Returns:
none
Date:
1995-01-01
Changes
none
Status
stable

Definition at line 200 of file HyperGeometric.cpp.

References pMean.

 double HyperGeometric::mean ( ) const [inline]

Returns the current mean value of the distribution as stored in pMean.

Returns:
the current mean value (pMean)
Date:
1995-01-01
Changes
none
Status
stable

Definition at line 124 of file HyperGeometric.h.

References pMean.

 double HyperGeometric::operator() ( )  [virtual]

Returns a Hyper Geometric random number for the distribution with a probability that is calculated from the preset mean value pMean and variance pVariance.

The mean value as stored in pMean and the variance as stored in pVariance are used to calculate the probability by .
will always be a value .
If you are calling this operator with a preset mean value , then the probability will be the default value .

Returns:
a random number for the Hyper Geometric distribution with a probability based on pMean and pVariance
Date:
1995-01-01
Changes
none
Status
stable

Implements RandomVar< double >.

Definition at line 268 of file HyperGeometric.cpp.

References pMean, and RandomVar< double >::rng.

 double HyperGeometric::p ( const double & x ) const [virtual]

Just a dummy method to allow instantiation of the class.

This method, defined as purely virtual in class RandomVar has to be implemented to allow the instantiation of class HyperGeometric.

Parameters:
 x has no function here
Returns:
always "0."
Date:
1995-01-01
Changes
none
Status
stable

Implements RandomVar< double >.

Definition at line 296 of file HyperGeometric.cpp.

 void HyperGeometric::variance ( double newVariance )

Sets the current variance of the distribution as stored in pVariance to the new value "newVar".

The distribution's variance is set to newVar and then the probability is recalculated by , where is the distribution's mean value as stored in pMean.

Parameters:
 newVariance the new value for the distribution's variance (pVariance)
Returns:
none
Date:
1995-01-01
Changes
none
Status
stable

Definition at line 232 of file HyperGeometric.cpp.

References pVariance.

 double HyperGeometric::variance ( ) const [inline]

Returns the current variance of the distribution as stored in pVariance.

Returns:
the current variance (pVariance)
Date:
1995-01-01
Changes
none
Status
stable

Definition at line 147 of file HyperGeometric.h.

References pVariance.

## Member Data Documentation

 double HyperGeometric::pMean [protected]

The distribution's mean value , that is used to calculate the probability by , where is the distribution's variance as stored in pVariance.

Definition at line 176 of file HyperGeometric.h.

Referenced by mean(), and operator()().

 double HyperGeometric::pVariance [protected]

The distribution's variance , that is used to calculate probability by , where is the distribution's mean value as stored in pMean.

Definition at line 184 of file HyperGeometric.h.

Referenced by variance().

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