|
STK++ 0.9.13
|
Gamma distribution law. More...
#include <STK_Law_Gamma.h>

Public Types | |
| typedef IUnivLaw< Real > | Base |
Public Member Functions | |
| Gamma (Real const &shape=1., Real const &scale=1.) | |
| Default constructor. | |
| virtual | ~Gamma () |
| destructor | |
| Real const & | shape () const |
| Real const & | scale () const |
| void | setShape (Real const &shape) |
| void | setScale (Real const &scale) |
| virtual Real | rand () const |
| generate a gamma random variate using the G.S algorithm of Ahrens and Dieter (1974) for 0<a_<1 and Marsaglia fast Gamma generator with enhanced squeeze step for a>1. | |
| virtual Real | pdf (Real const &x) const |
| compute | |
| virtual Real | lpdf (Real const &x) const |
| Compute. | |
| virtual Real | cdf (Real const &t) const |
| virtual Real | icdf (Real const &p) const |
Public Member Functions inherited from STK::Law::IUnivLaw< Real > | |
| virtual | ~IUnivLaw () |
| Virtual destructor. | |
| virtual Real | lcdf (Real const &t) const |
| compute the lower tail log-cumulative distribution function Give the log-probability that a random variate is less or equal to t. | |
| virtual Real | cdfc (Real const &t) const |
| calculate the complement of cumulative distribution function, called in statistics the survival function. | |
| virtual Real | lcdfc (Real const &t) const |
| calculate the log-complement of cumulative distribution function Give the log-probability that a random variate is greater than t. | |
Public Member Functions inherited from STK::Law::ILawBase | |
| String const & | name () const |
Static Public Member Functions | |
| static Real | rand (Real const &shape, Real const &scale) |
| static Real | pdf (Real const &x, Real const &shape, Real const &scale) |
| static Real | lpdf (Real const &x, Real const &shape, Real const &scale) |
| static Real | cdf (Real const &t, Real const &shape, Real const &scale) |
| static Real | icdf (Real const &p, Real const &shape, Real const &scale) |
Protected Attributes | |
| Real | a_ |
| The shape parameter. | |
| Real | b_ |
| The scale parameter. | |
Protected Attributes inherited from STK::Law::ILawBase | |
| String | name_ |
| Name of the Law. | |
Private Member Functions | |
| void | computeCtes () const |
| compute c_ and d_ | |
Private Attributes | |
| Real | c_ |
| First and second constants for rand. | |
| Real | d_ |
Additional Inherited Members | |
Protected Member Functions inherited from STK::Law::IUnivLaw< Real > | |
| IUnivLaw (String const &name) | |
| Constructor. | |
| IUnivLaw (IUnivLaw const &law) | |
| copy Constructor. | |
Protected Member Functions inherited from STK::Law::ILawBase | |
| ILawBase (String const &name) | |
| Constructor. | |
| ~ILawBase () | |
| destructor. | |
Gamma distribution law.
In probability theory and statistics, the gamma distribution is a two-parameter family of continuous probability distributions. The common exponential distribution and chi-squared distribution are special cases of the gamma distribution.
The probability pdf function of the gamma distribution can be expressed in terms of the Funct::gamma function:
![\[
f(x;a,b) = \left(\frac{x}{b}\right)^{a-1}
\frac{e^{-x/b}}{b \, \Gamma(a)}
\ \mathrm{for}\ x>0,\ a>0,\ b>0
\]](form_233.png)
where a is the shape parameter and b is the scale parameter.
Definition at line 62 of file STK_Law_Gamma.h.
Definition at line 65 of file STK_Law_Gamma.h.
Default constructor.
| shape | shape (position) parameter |
| scale | scale (dispersion) parameter |
Definition at line 70 of file STK_Law_Gamma.h.
References a_, b_, computeCtes(), Gamma(), and STKDOMAIN_ERROR_2ARG.
Referenced by Gamma().
|
inlinevirtual |
| t | a positive real value |
Implements STK::Law::IUnivLaw< Real >.
Definition at line 149 of file STK_Law_Gamma.cpp.
References a_, b_, STK::Funct::gammaRatioP(), and STK::isNA().
| t | a positive real value |
| shape,scale | shape and scale parameters |
Definition at line 270 of file STK_Law_Gamma.cpp.
References STK::Funct::gammaRatioP(), and STK::isNA().
|
private |
compute c_ and d_
Definition at line 290 of file STK_Law_Gamma.cpp.
Referenced by Gamma(), and setShape().
| p | a probability number |
Implements STK::Law::IUnivLaw< Real >.
Definition at line 164 of file STK_Law_Gamma.cpp.
References icdf(), and STKRUNTIME_ERROR_1ARG.
Referenced by icdf().
| p | a probability number |
| shape,scale | shape and scale parameters |
Definition at line 285 of file STK_Law_Gamma.cpp.
Compute.
![\[
\ln(f(x;\alpha,\beta)) = - x/\beta + (\alpha-1) \ln(x)
- \alpha \ln(\beta) + \ln(\Gamma(\alpha))
\]](form_236.png)
| x | a positive real value |
Reimplemented from STK::Law::IUnivLaw< Real >.
Definition at line 127 of file STK_Law_Gamma.cpp.
References a_, b_, STK::isNA(), and STK::Funct::poisson_lpdf_raw().
Referenced by STK::JointGammaModel< Array, WColVector >::computeLnLikelihood(), STK::ModelGamma_aj_bj< Data_, WColVector_ >::computeLnLikelihood(), and STK::GammaBase< Derived >::lnComponentProbability().
| x | a positive real value |
| shape,scale | shape and scale parameters |
Definition at line 251 of file STK_Law_Gamma.cpp.
References STK::isNA(), and STK::Funct::poisson_lpdf_raw().
compute
![\[
f(x;\alpha,\beta) = \left(\frac{x}{\beta}\right)^{\alpha-1}
\frac{e^{-x/\beta}}{\beta \, \Gamma(\alpha)}
\ \mathrm{for}\ x > 0
\]](form_234.png)
where 
| x | a positive real value |
Implements STK::Law::IUnivLaw< Real >.
Definition at line 106 of file STK_Law_Gamma.cpp.
References a_, b_, STK::isNA(), and STK::Funct::poisson_pdf_raw().
| x | a positive real value |
| shape,scale | shape and scale parameters |
Definition at line 230 of file STK_Law_Gamma.cpp.
References STK::isNA(), and STK::Funct::poisson_pdf_raw().
|
virtual |
generate a gamma random variate using the G.S algorithm of Ahrens and Dieter (1974) for 0<a_<1 and Marsaglia fast Gamma generator with enhanced squeeze step for a>1.
Implements STK::Law::IUnivLaw< Real >.
Definition at line 52 of file STK_Law_Gamma.cpp.
References a_, b_, c_, and d_.
Referenced by STK::Law::Beta::rand(), STK::GammaBase< Derived >::rand(), STK::Law::Beta::rand(), and rand().
| shape,scale | shape and scale parameters |
Definition at line 170 of file STK_Law_Gamma.cpp.
References STK::Law::Exponential::rand(), rand(), and STKDOMAIN_ERROR_2ARG.
Definition at line 90 of file STK_Law_Gamma.h.
References b_.
Referenced by setScale().
| scale | the scale parameter |
Definition at line 101 of file STK_Law_Gamma.h.
References b_, scale(), setScale(), and STKDOMAIN_ERROR_1ARG.
Referenced by setScale().
| shape | the shape parameter |
Definition at line 92 of file STK_Law_Gamma.h.
References a_, computeCtes(), setShape(), shape(), and STKDOMAIN_ERROR_1ARG.
Referenced by setShape().
Definition at line 88 of file STK_Law_Gamma.h.
References a_.
Referenced by setShape().
|
protected |
The shape parameter.
Definition at line 178 of file STK_Law_Gamma.h.
Referenced by cdf(), computeCtes(), Gamma(), lpdf(), pdf(), rand(), setShape(), and shape().
|
protected |
The scale parameter.
Definition at line 180 of file STK_Law_Gamma.h.
Referenced by cdf(), Gamma(), lpdf(), pdf(), rand(), scale(), and setScale().
|
mutableprivate |
First and second constants for rand.
Definition at line 185 of file STK_Law_Gamma.h.
Referenced by computeCtes(), and rand().
|
private |
Definition at line 185 of file STK_Law_Gamma.h.
Referenced by computeCtes(), and rand().