Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

matvec::GammaDist Class Reference

#include <statdist.h>

Inheritance diagram for matvec::GammaDist:

matvec::StatDistBase matvec::ExponentialDist List of all members.

Detailed Description

gamma statistical distribution.

Definition at line 262 of file statdist.h.

Public Methods

 GammaDist (const double a, const double t)
 GammaDist (const GammaDist &u)
void display (void) const
void reset (const double a, const double t)
void sample (Vector< double > &x) const
void sample (doubleMatrix &x) const
double sample (void) const
Vector< double > sample (unsigned n) const
doubleMatrix sample (unsigned m, unsigned n) const
double mean (void) const
double variance (void) const
double pdf (const double x) const
double cdf (const double x) const
double mgf (const double t) const
double inv (const double p) const
double parameter (const int k) const
void parameter (const int k, const double x)
virtual const std::string name (void) const
virtual double nonct (const double cv, const double p)

Protected Attributes

double alpha_value
double theta_value
std::string distname


Constructor & Destructor Documentation

matvec::GammaDist::GammaDist const double    a,
const double    t
[inline]
 

Definition at line 266 of file statdist.h.

References matvec::StatDistBase::distname, and reset().

00267                                    {distname="GammaDist";reset(a,t);}

matvec::GammaDist::GammaDist const GammaDist &    u [inline]
 

Definition at line 268 of file statdist.h.

References matvec::StatDistBase::distname, and reset().

00268                                    :StatDistBase()
00269              {distname="GammaDist";reset(u.alpha_value,u.theta_value);}


Member Function Documentation

double matvec::GammaDist::cdf const double    x const [virtual]
 

Implements matvec::StatDistBase.

Definition at line 820 of file statdist.cpp.

References alpha_value, matvec::gammln(), and theta_value.

00822 {
00823    if (x < 0.0) throw exception("GammaDist::pdf(): bad arg");
00824    double pr = 0.0;

void matvec::GammaDist::display void    const [inline, virtual]
 

Implements matvec::StatDistBase.

Reimplemented in matvec::ExponentialDist.

Definition at line 271 of file statdist.h.

References alpha_value, matvec::StatDistBase::distname, and theta_value.

00271                                   {std::cout << "\t" << distname << "("
00272                       << alpha_value << "," << theta_value << ")\n"; return;}

double matvec::GammaDist::inv const double    p const [virtual]
 

Implements matvec::StatDistBase.

Definition at line 832 of file statdist.cpp.

00836 {
00837    if (x < 0.0) throw exception("GammaDist::cdf(): bad arg");
00838    return Gamma_cdf(x,alpha_value,theta_value);
00839 }
00840 
00841 double GammaDist::mgf(const double t) const
00842 {
00843    if (t >= 1.0/theta_value) throw exception("GammaDist:mgf(t): t must be < 1/theta");
00844    return 1.0/pow(1.0-theta_value*t,alpha_value);
00845 }
00846 
00847 double GammaDist::inv(const double p) const
00848 {
00849    if (p<0.0 || p>1.0) throw exception("GammaDist::inv(): bad arg, value between [0,1] expected");
00850    double eps = 1.0e-6;
00851    double bot = 0.0;
00852    double top = alpha_value*theta_value + 1200.0;
00853    double p2,ppt;

double matvec::GammaDist::mean void    const [inline, virtual]
 

Implements matvec::StatDistBase.

Definition at line 279 of file statdist.h.

References alpha_value, and theta_value.

00279 {return alpha_value*theta_value;}

double matvec::GammaDist::mgf const double    t const [virtual]
 

Implements matvec::StatDistBase.

Definition at line 826 of file statdist.cpp.

00826                  {
00827       pr = -a;
00828    }
00829    else {
00830       pr = (alpha_value-1.0)*std::log(x) - x/theta_value - a;

virtual const std::string matvec::StatDistBase::name void    const [inline, virtual, inherited]
 

Definition at line 45 of file statdistbase.h.

References matvec::StatDistBase::distname.

00045 {return distname;}

virtual double matvec::StatDistBase::nonct const double    cv,
const double    p
[inline, virtual, inherited]
 

Definition at line 58 of file statdistbase.h.

00058 {std::cerr << "error\n"; return 0.0;}

void matvec::GammaDist::parameter const int    k,
const double    x
[virtual]
 

Implements matvec::StatDistBase.

Reimplemented in matvec::ExponentialDist.

Definition at line 902 of file statdist.cpp.

References alpha_value, and theta_value.

00903 {
00904    double par =  0.0;
00905    if (k==1) {
00906       par = alpha_value;
00907    }
00908    else if (k==2) {
00909       par = theta_value;
00910    }
00911    else {
00912       throw exception("GammaDist::parameter(): bad arg value, 1 or 2 is expected");
00913    }
00914    return par;

double matvec::GammaDist::parameter const int    k const [virtual]
 

Implements matvec::StatDistBase.

Reimplemented in matvec::ExponentialDist.

Definition at line 887 of file statdist.cpp.

References sample().

00889 {
00890    Vector<double> x(n);
00891    sample(x);
00892    return x;
00893 }
00894 
00895 doubleMatrix GammaDist::sample(unsigned m,unsigned n) const
00896 {
00897    doubleMatrix x(m,n);
00898    sample(x);
00899    return x;
00900 }

double matvec::GammaDist::pdf const double    x const [virtual]
 

The random variable X has a gamma distribution if its probability density function is defined by

Implements matvec::StatDistBase.

Definition at line 806 of file statdist.cpp.

References alpha_value, and theta_value.

00809 {
00810    if (a <= 0.0 || t <= 0.0) throw exception("GammaDist::reset(): bad args, they mustbe > 0");
00811    alpha_value = a;
00812    theta_value = t;
00813 }
00814 
00815 /*!
00816 The random variable <EM>X</EM> has a gamma distribution if its probability density function is defined by
00817 \f[
00818 f(x) = \frac{1}{\Gamma(\alpha)\theta^\alpha} x^{\alpha-1} e^{-x/\theta}, \quad 0 \leq x < \infty.

void matvec::GammaDist::reset const double    a,
const double    t
 

Definition at line 795 of file statdist.cpp.

Referenced by GammaDist().

00795                                           : bad arg2, nonnegative expected");
00796       }
00797       else {
00798          nc_value = x;
00799       }
00800    }

doubleMatrix matvec::GammaDist::sample unsigned    m,
unsigned    n
const [virtual]
 

Implements matvec::StatDistBase.

Definition at line 880 of file statdist.cpp.

References alpha_value, and theta_value.

00882                                  {
00883       bot = x[i];  top = &bot[nc];
00884       while (bot < top ) *bot++ = theta_value*sgamma(alpha_value);
00885    }

Vector< double > matvec::GammaDist::sample unsigned    n const [virtual]
 

Implements matvec::StatDistBase.

Definition at line 873 of file statdist.cpp.

References alpha_value, and theta_value.

00878 {

double matvec::GammaDist::sample void    const [inline, virtual]
 

Implements matvec::StatDistBase.

Definition at line 276 of file statdist.h.

References alpha_value, matvec::sgamma(), and theta_value.

Referenced by parameter().

00276 {return theta_value*sgamma(alpha_value);}

void matvec::GammaDist::sample doubleMatrix   x const [virtual]
 

Implements matvec::StatDistBase.

Definition at line 862 of file statdist.cpp.

00863            {
00864          break;
00865       }
00866    }
00867    return ppt;
00868 }
00869 
00870 void GammaDist::sample(Vector<double>& x) const
00871 {

void matvec::GammaDist::sample Vector< double > &    x const [virtual]
 

Implements matvec::StatDistBase.

Definition at line 855 of file statdist.cpp.

References alpha_value, and theta_value.

00857                    {
00858          bot = ppt;
00859       }
00860       else if (p2 > p) {

double matvec::GammaDist::variance void    const [inline, virtual]
 

Implements matvec::StatDistBase.

Definition at line 280 of file statdist.h.

References alpha_value, and theta_value.


Member Data Documentation

double matvec::GammaDist::alpha_value [protected]
 

Definition at line 264 of file statdist.h.

Referenced by cdf(), display(), mean(), matvec::ExponentialDist::parameter(), parameter(), pdf(), sample(), and variance().

std::string matvec::StatDistBase::distname [protected, inherited]
 

Definition at line 39 of file statdistbase.h.

Referenced by matvec::BetaDist::BetaDist(), matvec::BinomialDist::BinomialDist(), matvec::ChiSquareDist::ChiSquareDist(), matvec::DiscreteUniformDist::DiscreteUniformDist(), matvec::NegativeBinomialDist::display(), matvec::GeometricDist::display(), matvec::PoissonDist::display(), matvec::BinomialDist::display(), matvec::DiscreteUniformDist::display(), matvec::BetaDist::display(), matvec::ExponentialDist::display(), display(), matvec::FDist::display(), matvec::tDist::display(), matvec::ChiSquareDist::display(), matvec::LogNormalDist::display(), matvec::NormalDist::display(), matvec::UniformDist::display(), matvec::ExponentialDist::ExponentialDist(), matvec::FDist::FDist(), GammaDist(), matvec::GeometricDist::GeometricDist(), matvec::LogNormalDist::LogNormalDist(), matvec::StatDistBase::name(), matvec::NegativeBinomialDist::NegativeBinomialDist(), matvec::NormalDist::NormalDist(), matvec::PoissonDist::PoissonDist(), matvec::StatDistBase::StatDistBase(), matvec::tDist::tDist(), and matvec::UniformDist::UniformDist().

double matvec::GammaDist::theta_value [protected]
 

Definition at line 264 of file statdist.h.

Referenced by cdf(), matvec::ExponentialDist::display(), display(), matvec::ExponentialDist::ExponentialDist(), mean(), matvec::ExponentialDist::parameter(), parameter(), pdf(), sample(), and variance().


The documentation for this class was generated from the following files:
Generated on Thu Jun 16 17:14:22 2005 for Matvec by doxygen1.2.16