Gamma Class Reference

This class simulates a "gamma" distribution. More...

#include <Gamma.h>

Inheritance diagram for Gamma:
RandomVar< double >

List of all members.

Public Member Functions

 Gamma (double k=1, double theta=1)
 Creates a new instance of the gamma random number generator, initializes the shape and scale parameter.
 Gamma (double k, double theta, RNG &r)
 Creates a new gamma random generator instance by using the pseudo random number generator r nd initializes the range of the numbers and internal variables.
void seed (long s)
 Initializes the pseudo random number generator used by this class with value s.
double mean () const
 Returns the current mean value $k \theta$.
double variance () const
 Returns the current variance $ k\theta^2$.
void shape (double s)
 Sets the current shape parameter.
void scale (double s)
 Sets the current scale parameter of the distribution.
double operator() (double k, double theta)
 Returns gamma distributed random number.
double operator() ()
 Returns a gamma distributed random number.
double p (const double &x) const
 Returns the probability desity function evaluated at x.

Protected Member Functions

double U01 ()

Protected Attributes

double pK
 Shape parameter $k$ of the gamma distribution.
double pTheta
 Scale parameter $\theta$ of the distribution.

Detailed Description

This class simulates a "gamma" distribution.

The gamma distribution is a two-parameter family of continuous probability distributions having a scale parameter $\theta$ and a shape parameter $k$. Samples from the gamma distribution are positive.

The probability density function is $ f(x)=x^{k-1} \frac{\exp{\left(-x/\theta\right)}}{\Gamma(k)\,\theta^k} $ and the mean is $\theta k$ and the variance $\theta^2 k$.

Author:
C. Igel
Date:
2008-11-28
Changes:
none
Status:
stable

Definition at line 75 of file Gamma.h.


Constructor & Destructor Documentation

Gamma::Gamma ( double  k = 1,
double  theta = 1 
)

Creates a new instance of the gamma random number generator, initializes the shape and scale parameter.

Definition at line 44 of file Gamma.cpp.

References pK, and pTheta.

Gamma::Gamma ( double  k,
double  theta,
RNG r 
)

Creates a new gamma random generator instance by using the pseudo random number generator r nd initializes the range of the numbers and internal variables.

Definition at line 49 of file Gamma.cpp.

References pK, and pTheta.


Member Function Documentation

double Gamma::mean (  )  const

Returns the current mean value $k \theta$.

Returns:
the mean value
Author:
C. Igel
Date:
1995-01-01

Definition at line 59 of file Gamma.cpp.

References pK, and pTheta.

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

Returns a gamma distributed random number.

Implements RandomVar< double >.

Definition at line 105 of file Gamma.cpp.

References pK, and pTheta.

double Gamma::operator() ( double  k,
double  theta 
)

Returns gamma distributed random number.

Parameters:
k shape
theta scale
Returns:
none
Author:
C. Igel
Date:
2008-11-28

Definition at line 78 of file Gamma.cpp.

References U01().

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

Returns the probability desity function evaluated at x.

Implements RandomVar< double >.

Definition at line 109 of file Gamma.cpp.

References pK, and pTheta.

void Gamma::scale ( double  s  ) 

Sets the current scale parameter of the distribution.

Parameters:
s new scale
Returns:
none
Author:
C. Igel
Date:
2008-11-28

Definition at line 73 of file Gamma.cpp.

References pTheta.

void Gamma::seed ( long  s  )  [virtual]

Initializes the pseudo random number generator used by this class with value s.

The pseudo random number generator as defined in class RNG is initialized by using the seed value s.

Parameters:
s initialization value for the pseudo random number generator
Returns:
none
Author:
C. Igel
Date:
2008-11-28
See also:
RandomVar::seed

Reimplemented from RandomVar< double >.

Definition at line 54 of file Gamma.cpp.

Referenced by Rng::seed().

void Gamma::shape ( double  s  ) 

Sets the current shape parameter.

Parameters:
s new shape
Returns:
none
Author:
C. Igel
Date:
2008-11-28

Definition at line 69 of file Gamma.cpp.

References pK.

double Gamma::U01 (  )  [inline, protected]

Definition at line 191 of file Gamma.h.

References RandomVar< double >::rng.

Referenced by operator()().

double Gamma::variance (  )  const

Returns the current variance $ k\theta^2$.

Returns:
the variance
Author:
C. Igel
Date:
2008-11-28

Definition at line 64 of file Gamma.cpp.

References pK, and pTheta.


Member Data Documentation

double Gamma::pK [protected]

Shape parameter $k$ of the gamma distribution.

Definition at line 185 of file Gamma.h.

Referenced by Gamma(), mean(), operator()(), p(), shape(), and variance().

double Gamma::pTheta [protected]

Scale parameter $\theta$ of the distribution.

Definition at line 188 of file Gamma.h.

Referenced by Gamma(), mean(), operator()(), p(), scale(), and variance().


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