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

matvec::LogNormalDist Class Reference

#include <statdist.h>

Inheritance diagram for matvec::LogNormalDist:

matvec::StatDistBase List of all members.

Detailed Description

log normal statistical distribution.

For more information, see the following references:

  1. Norman L. Johnson, Samuel Kotz (1970) Distributions (volume 2)
  2. Evans, et al. (1993) Statistical Distributions (2nd Ed.) Wily pp102-105
See also:
NormalDist

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


Constructor & Destructor Documentation

matvec::LogNormalDist::LogNormalDist const double    mu = 0.0,
const double    sigma2 = 1.0,
const double    theta = 1.0
[inline]
 

Definition at line 123 of file statdist.h.

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

00125                    {distname="LogNormalDist"; reset(mu,sigma2,theta);}

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

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);}


Member Function Documentation

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

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 

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

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;}

double matvec::LogNormalDist::inv const double    p const [inline, virtual]
 

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;}

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

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;}

double matvec::LogNormalDist::mgf const double    t const [inline, virtual]
 

Implements matvec::StatDistBase.

Definition at line 145 of file statdist.h.

00146                  {std::cerr << "LogNormalDist::mgf(): not available yet"; return 0.0;}

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::LogNormalDist::parameter const int    k,
const double    x
[virtual]
 

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    }

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

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) {

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

The probability density function (pdf) is defined by

Implements matvec::StatDistBase.

Definition at line 241 of file statdist.cpp.

00243                                              {-1}
00244             \exp(-\frac{\log(x-\theta)-\mu)^2}{2\sigma^2}),
00245                 \quad x > \theta
00246    \f]
00247 */
00248 double LogNormalDist::pdf(const double x) const

void matvec::LogNormalDist::reset const double    mu,
const double    sigma2,
const double    theta
 

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");

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

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 }

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

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 }

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

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;}

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

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++) {

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

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();

double matvec::LogNormalDist::variance void    const [virtual]
 

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 }


Member Data Documentation

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(), matvec::GammaDist::display(), matvec::FDist::display(), matvec::tDist::display(), matvec::ChiSquareDist::display(), display(), matvec::NormalDist::display(), matvec::UniformDist::display(), matvec::ExponentialDist::ExponentialDist(), matvec::FDist::FDist(), matvec::GammaDist::GammaDist(), matvec::GeometricDist::GeometricDist(), 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::LogNormalDist::mu_value [protected]
 

Definition at line 118 of file statdist.h.

Referenced by cdf(), display(), inv(), mean(), sample(), and variance().

double matvec::LogNormalDist::sigma2_value [protected]
 

Definition at line 119 of file statdist.h.

Referenced by display(), mean(), and sample().

double matvec::LogNormalDist::sigma_value [protected]
 

Definition at line 120 of file statdist.h.

Referenced by cdf(), inv(), sample(), and variance().

double matvec::LogNormalDist::theta_value [protected]
 

Definition at line 121 of file statdist.h.

Referenced by cdf(), display(), inv(), mean(), sample(), and variance().


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