lognormal.qbk 4.0 KB

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