IT++ Logo
Public Member Functions | List of all members
itpp::Gamma_RNG Class Reference

Gamma distribution. More...

#include <itpp/base/random.h>

Public Member Functions

 Gamma_RNG (double a=1.0, double b=1.0)
 Constructor, which sets alpha (a) and beta (b)
 
void setup (double a, double b)
 Set alpha and beta.
 
double operator() ()
 Get one sample.
 
vec operator() (int n)
 Get a sample vector.
 
mat operator() (int r, int c)
 Get a sample matrix.
 
double sample ()
 Get a sample.
 

Detailed Description

Gamma distribution.

Generate samples from Gamma(alpha,beta) density, according to the following equation:

\[ x \sim \Gamma(\alpha,\beta) =
\frac{\beta^\alpha}{\Gamma(\alpha)}x^{\alpha-1} \exp(-\beta x) \]

For $\alpha=1$ the Gamma distribution is equivalent to the Exponential distribution.

Note
The implementation of the sample() function was adapted from the R statistical language.
Author
Vasek Smidl

Definition at line 510 of file random.h.

Constructor & Destructor Documentation

◆ Gamma_RNG()

itpp::Gamma_RNG::Gamma_RNG ( double  a = 1.0,
double  b = 1.0 
)
inline

Constructor, which sets alpha (a) and beta (b)

Definition at line 514 of file random.h.

Member Function Documentation

◆ setup()

void itpp::Gamma_RNG::setup ( double  a,
double  b 
)
inline

Set alpha and beta.

Definition at line 516 of file random.h.

◆ operator()() [1/3]

double itpp::Gamma_RNG::operator() ( )
inline

Get one sample.

Definition at line 518 of file random.h.

◆ operator()() [2/3]

vec itpp::Gamma_RNG::operator() ( int  n)

Get a sample vector.

Definition at line 441 of file random.cpp.

References sample().

◆ operator()() [3/3]

mat itpp::Gamma_RNG::operator() ( int  r,
int  c 
)

Get a sample matrix.

Definition at line 449 of file random.cpp.

References sample().

◆ sample()

double itpp::Gamma_RNG::sample ( )

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

Generated on Mon Jun 10 2024 11:49:35 for IT++ by Doxygen 1.9.8