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

For more information, see the following references:
Definition at line 116 of file statdist.h.
Public Methods | |
| LogNormalDist (const double mu=0.0, const double sigma2=1.0, const double theta=1.0) | |
| LogNormalDist (const LogNormalDist &u) | |
| void | display (void) const |
| void | reset (const double mu, const double sigma2, const double theta) |
| 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 | mu_value |
| double | sigma2_value |
| double | sigma_value |
| double | theta_value |
| std::string | distname |
|
||||||||||||||||
|
Definition at line 123 of file statdist.h. References matvec::StatDistBase::distname, and reset().
|
|
|
Definition at line 126 of file statdist.h. References matvec::StatDistBase::distname, and reset().
00126 :StatDistBase() 00127 {distname="LogNormalDist"; 00128 reset(u.mu_value,u.sigma2_value,u.theta_value);} |
|
|
Implements matvec::StatDistBase. Definition at line 250 of file statdist.cpp. References mu_value, sigma_value, and theta_value.
00250 : bad arg"); 00251 double tmp = (std::log(x-theta_value)-mu_value)/sigma_value; 00252 double retval = std::exp(-0.5*tmp*tmp); 00253 retval /= (x - theta_value)*std::sqrt(4.0*std::asin(1.0))*sigma_value; // pi = 2.0*std::asin(1.0) 00254 return retval; 00255 } 00256 |
|
|
Implements matvec::StatDistBase. Definition at line 130 of file statdist.h. References matvec::StatDistBase::distname, mu_value, sigma2_value, and theta_value.
00130 {std::cout << "\t" << distname << "(" << mu_value
00131 << "," << sigma2_value << "," << theta_value
00132 << ")\n"; return;}
|
|
|
Implements matvec::StatDistBase. Definition at line 147 of file statdist.h. References mu_value, matvec::Normal_inv(), sigma_value, and theta_value.
00148 {return std::exp(Normal_inv(p)*sigma_value+ mu_value)+ theta_value;}
|
|
|
Implements matvec::StatDistBase. Definition at line 140 of file statdist.h. References mu_value, sigma2_value, and theta_value.
00140 {
00141 return std::exp(mu_value + 0.5*sigma2_value) + theta_value;}
|
|
|
Implements matvec::StatDistBase. Definition at line 145 of file statdist.h.
00146 {std::cerr << "LogNormalDist::mgf(): not available yet"; return 0.0;}
|
|
|
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. Definition at line 330 of file statdist.cpp.
00331 {
00332 throw exception("LogNormalDist::parameter(): bad arg");
00333 }
00334 return par;
00335 }
00336
00337 void LogNormalDist::parameter(const int k,const double x)
00338 {
00339 if (k==1) {
00340 mu_value = x;
00341 }
00342 else if (k==2) {
00343 sigma2_value = x;
00344 }
|
|
|
Implements matvec::StatDistBase. Definition at line 312 of file statdist.cpp. References sample().
00313 {
00314 doubleMatrix x(m,n);
00315 sample(x);
00316 return x;
00317 }
00318
00319 double LogNormalDist::parameter(const int k) const
00320 {
00321 double par = 0.0;
00322 if (k==1) {
00323 par = mu_value;
00324 }
00325 else if (k==2) {
00326 par = sigma2_value;
00327 }
00328 else if (k==3) {
|
|
|
The probability density function (pdf) is defined by
Implements matvec::StatDistBase. Definition at line 241 of file statdist.cpp.
|
|
||||||||||||||||
|
Definition at line 229 of file statdist.cpp. Referenced by LogNormalDist().
00234 {
00235 if (sigma2 <= 0.0) throw exception("LogNormalDist::reset(): 2nd arg must be positive");
|
|
||||||||||||
|
Implements matvec::StatDistBase. Definition at line 305 of file statdist.cpp. References sample().
00306 {
00307 Vector<double> x(n);
00308 sample(x);
00309 return x;
00310 }
|
|
|
Implements matvec::StatDistBase. Definition at line 298 of file statdist.cpp. References mu_value, sigma_value, matvec::snorm(), and theta_value.
00298 {
00299 *bot++ = std::exp(mu_value + sigma_value*snorm()) + theta_value;
00300 }
00301 }
00302 }
00303 }
|
|
|
Implements matvec::StatDistBase. Definition at line 136 of file statdist.h. References mu_value, sigma_value, matvec::snorm(), and theta_value. Referenced by parameter(), and sample().
00137 {return std::exp(mu_value + sigma_value*snorm()) + theta_value;}
|
|
|
Implements matvec::StatDistBase. Definition at line 276 of file statdist.cpp. References mu_value, sigma_value, matvec::snorm(), and theta_value.
00276 {
00277 while (bot < top ) *bot++ = std::exp(snorm()) + theta_value;
00278 }
00279 else {
00280 while (bot<top) *bot++ = std::exp(mu_value+ sigma_value*snorm())+ theta_value;
00281 }
00282 }
00283 void LogNormalDist::sample(doubleMatrix& x) const
00284 {
00285 int nr = x.num_rows();
00286 int nc = x.num_cols();
00287 double *bot,*top;
00288 unsigned i;
00289 if (mu_value==0.0 && sigma2_value==1.0) {
00290 for (i=0; i<nr; i++) {
00291 bot = x[i]; top = &bot[nc];
00292 while (bot < top ) *bot++ = std::exp(snorm()) + theta_value;
00293 }
00294 }
00295 else {
00296 for (i=0; i<nr; i++) {
|
|
|
Implements matvec::StatDistBase. Definition at line 265 of file statdist.cpp. References mu_value, sigma2_value, and theta_value.
00266 {
00267 double mean_value = std::exp(mu_value + 0.5*sigma2_value) + theta_value;
00268 return std::exp(2*(mu_value + sigma2_value)) + 2*theta_value*mean_value
00269 + theta_value*theta_value - mean_value*mean_value;
00270 }
00271
00272 void LogNormalDist::sample(Vector<double>& x) const
00273 {
00274 double *bot = x.begin();
00275 double *top = x.end();
|
|
|
Implements matvec::StatDistBase. Definition at line 258 of file statdist.cpp. References mu_value, matvec::Normal_cdf(), sigma_value, and theta_value.
00258 {
00259 if (x <= theta_value) throw exception("LogNormalDist::pdf(arg): bad arg");
00260 double retval = (std::log(x - theta_value) - mu_value)/sigma_value;
00261 retval = Normal_cdf(retval);
00262 return retval;
00263 }
|
|
|
|
Definition at line 118 of file statdist.h. Referenced by cdf(), display(), inv(), mean(), sample(), and variance(). |
|
|
Definition at line 119 of file statdist.h. |
|
|
Definition at line 120 of file statdist.h. |
|
|
Definition at line 121 of file statdist.h. Referenced by cdf(), display(), inv(), mean(), sample(), and variance(). |
1.2.16