1[section:lognormal_dist Log Normal Distribution] 2 3``#include <boost/math/distributions/lognormal.hpp>`` 4 5 namespace boost{ namespace math{ 6 7 template <class RealType = double, 8 class ``__Policy`` = ``__policy_class`` > 9 class lognormal_distribution; 10 11 typedef lognormal_distribution<> lognormal; 12 13 template <class RealType, class ``__Policy``> 14 class lognormal_distribution 15 { 16 public: 17 typedef RealType value_type; 18 typedef Policy policy_type; 19 // Construct: 20 lognormal_distribution(RealType location = 0, RealType scale = 1); 21 // Accessors: 22 RealType location()const; 23 RealType scale()const; 24 }; 25 26 }} // namespaces 27 28The lognormal distribution is the distribution that arises 29when the logarithm of the random variable is normally distributed. 30A lognormal distribution results when the variable is the product 31of a large number of independent, identically-distributed variables. 32 33For location and scale parameters /m/ and /s/ it is defined by the 34probability density function: 35 36[equation lognormal_ref] 37 38The location and scale parameters are equivalent to the mean and 39standard deviation of the logarithm of the random variable. 40 41The following graph illustrates the effect of the location 42parameter on the PDF, note that the range of the random 43variable remains \[0,+[infin]\] irrespective of the value of the 44location parameter: 45 46[graph lognormal_pdf1] 47 48The next graph illustrates the effect of the scale parameter on the PDF: 49 50[graph lognormal_pdf2] 51 52[h4 Member Functions] 53 54 lognormal_distribution(RealType location = 0, RealType scale = 1); 55 56Constructs a lognormal distribution with location /location/ and 57scale /scale/. 58 59The location parameter is the same as the mean of the logarithm of the 60random variate. 61 62The scale parameter is the same as the standard deviation of the 63logarithm of the random variate. 64 65Requires that the scale parameter is greater than zero, otherwise calls 66__domain_error. 67 68 RealType location()const; 69 70Returns the /location/ parameter of this distribution. 71 72 RealType scale()const; 73 74Returns the /scale/ parameter of this distribution. 75 76[h4 Non-member Accessors] 77 78All the [link math_toolkit.dist_ref.nmp usual non-member accessor functions] that are generic to all 79distributions are supported: __usual_accessors. 80 81The domain of the random variable is \[0,+[infin]\]. 82 83[h4 Accuracy] 84 85The lognormal distribution is implemented in terms of the 86standard library log and exp functions, plus the 87[link math_toolkit.sf_erf.error_function error function], 88and as such should have very low error rates. 89 90[h4 Implementation] 91 92In the following table /m/ is the location parameter of the distribution, 93/s/ is its scale parameter, /x/ is the random variate, /p/ is the probability 94and /q = 1-p/. 95 96[table 97[[Function][Implementation Notes]] 98[[pdf][Using the relation: pdf = e[super -(ln(x) - m)[super 2 ] \/ 2s[super 2 ] ] \/ (x * s * sqrt(2pi)) ]] 99[[cdf][Using the relation: p = cdf(normal_distribtion<RealType>(m, s), log(x)) ]] 100[[cdf complement][Using the relation: q = cdf(complement(normal_distribtion<RealType>(m, s), log(x))) ]] 101[[quantile][Using the relation: x = exp(quantile(normal_distribtion<RealType>(m, s), p))]] 102[[quantile from the complement][Using the relation: x = exp(quantile(complement(normal_distribtion<RealType>(m, s), q)))]] 103[[mean][e[super m + s[super 2 ] / 2 ] ]] 104[[variance][(e[super s[super 2] ] - 1) * e[super 2m + s[super 2 ] ] ]] 105[[mode][e[super m - s[super 2 ] ] ]] 106[[skewness][sqrt(e[super s[super 2] ] - 1) * (2 + e[super s[super 2] ]) ]] 107[[kurtosis][e[super 4s[super 2] ] + 2e[super 3s[super 2] ] + 3e[super 2s[super 2] ] - 3]] 108[[kurtosis excess][e[super 4s[super 2] ] + 2e[super 3s[super 2] ] + 3e[super 2s[super 2] ] - 6 ]] 109] 110 111[endsect] [/section:lognormal_dist Log Normal Distribution] 112 113[/ 114 Copyright 2006 John Maddock and Paul A. Bristow. 115 Distributed under the Boost Software License, Version 1.0. 116 (See accompanying file LICENSE_1_0.txt or copy at 117 http://www.boost.org/LICENSE_1_0.txt). 118] 119 120