#include <statdist.h>
Inheritance diagram for matvec::GammaDist:

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 |
|
||||||||||||
|
Definition at line 266 of file statdist.h. References matvec::StatDistBase::distname, and reset().
|
|
|
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);} |
|
|
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;
|
|
|
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;}
|
|
|
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;
|
|
|
Implements matvec::StatDistBase. Definition at line 279 of file statdist.h. References alpha_value, and theta_value.
00279 {return alpha_value*theta_value;}
|
|
|
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;
|
|
|
Definition at line 45 of file statdistbase.h. References matvec::StatDistBase::distname.
00045 {return distname;}
|
|
||||||||||||
|
Definition at line 58 of file statdistbase.h.
00058 {std::cerr << "error\n"; return 0.0;}
|
|
||||||||||||
|
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;
|
|
|
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 }
|
|
|
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.
|
|
||||||||||||
|
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 }
|
|
||||||||||||
|
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 }
|
|
|
Implements matvec::StatDistBase. Definition at line 873 of file statdist.cpp. References alpha_value, and theta_value.
00878 {
|
|
|
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);}
|
|
|
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 {
|
|
|
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) {
|
|
|
Implements matvec::StatDistBase. Definition at line 280 of file statdist.h. References alpha_value, and theta_value.
00280 {return alpha_value*theta_value*theta_value;}
|
|
|
Definition at line 264 of file statdist.h. Referenced by cdf(), display(), mean(), matvec::ExponentialDist::parameter(), parameter(), pdf(), sample(), and variance(). |
|
|
|
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(). |
1.2.16