laplace.qbk 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. [section:laplace_dist Laplace Distribution]
  2. ``#include <boost/math/distributions/laplace.hpp>``
  3. namespace boost{ namespace math{
  4. template <class RealType = double,
  5. class ``__Policy`` = ``__policy_class`` >
  6. class laplace_distribution;
  7. typedef laplace_distribution<> laplace;
  8. template <class RealType, class ``__Policy``>
  9. class laplace_distribution
  10. {
  11. public:
  12. typedef RealType value_type;
  13. typedef Policy policy_type;
  14. // Construct:
  15. laplace_distribution(RealType location = 0, RealType scale = 1);
  16. // Accessors:
  17. RealType location()const;
  18. RealType scale()const;
  19. };
  20. }} // namespaces
  21. Laplace distribution is the distribution of differences between two independent variates
  22. with identical exponential distributions (Abramowitz and Stegun 1972, p. 930).
  23. It is also called the double exponential distribution.
  24. [/ Wikipedia definition is The difference between two independent identically distributed
  25. exponential random variables is governed by a Laplace distribution.]
  26. For location parameter ['[mu]] and scale parameter ['[sigma]], it is defined by the
  27. probability density function:
  28. [equation laplace_pdf]
  29. The location and scale parameters are equivalent to the mean and
  30. standard deviation of the normal or Gaussian distribution.
  31. The following graph illustrates the effect of the
  32. parameters [mu] and [sigma] on the PDF.
  33. Note that the domain of the random variable remains
  34. \[-[infin],+[infin]\] irrespective of the value of the location parameter:
  35. [graph laplace_pdf]
  36. [h4 Member Functions]
  37. laplace_distribution(RealType location = 0, RealType scale = 1);
  38. Constructs a laplace distribution with location /location/ and
  39. scale /scale/.
  40. The location parameter is the same as the mean of the random variate.
  41. The scale parameter is proportional to the standard deviation of the random variate.
  42. Requires that the scale parameter is greater than zero, otherwise calls
  43. __domain_error.
  44. RealType location()const;
  45. Returns the /location/ parameter of this distribution.
  46. RealType scale()const;
  47. Returns the /scale/ parameter of this distribution.
  48. [h4 Non-member Accessors]
  49. All the [link math_toolkit.dist_ref.nmp usual non-member accessor functions] that are generic to all
  50. distributions are supported: __usual_accessors.
  51. The domain of the random variable is \[-[infin],+[infin]\].
  52. [h4 Accuracy]
  53. The laplace distribution is implemented in terms of the
  54. standard library log and exp functions and as such should have very small errors.
  55. [h4 Implementation]
  56. In the following table [mu] is the location parameter of the distribution,
  57. [sigma] is its scale parameter, /x/ is the random variate, /p/ is the probability
  58. and its complement /q = 1-p/.
  59. [table
  60. [[Function][Implementation Notes]]
  61. [[pdf][Using the relation: pdf = e[super -abs(x-[mu]) \/ [sigma]] \/ (2 * [sigma]) ]]
  62. [[cdf][Using the relations:
  63. x < [mu] : p = e[super (x-[mu])/[sigma] ] \/ [sigma]
  64. x >= [mu] : p = 1 - e[super ([mu]-x)/[sigma] ] \/ [sigma]
  65. ]]
  66. [[cdf complement][Using the relation:
  67. -x < [mu] : q = e[super (-x-[mu])/[sigma] ] \/ [sigma]
  68. -x >= [mu] : q = 1 - e[super ([mu]+x)/[sigma] ] \/ [sigma]
  69. ]]
  70. [[quantile][Using the relations:
  71. p < 0.5 : x = [mu] + [sigma] * log(2*p)
  72. p >= 0.5 : x = [mu] - [sigma] * log(2-2*p)
  73. ]]
  74. [[quantile from the complement][Using the relation:
  75. q > 0.5: x = [mu] + [sigma]*log(2-2*q)
  76. q <=0.5: x = [mu] - [sigma]*log( 2*q )
  77. ]]
  78. [[mean][[mu]]]
  79. [[variance][2 * [sigma][super 2] ]]
  80. [[mode][[mu]]]
  81. [[skewness][0]]
  82. [[kurtosis][6]]
  83. [[kurtosis excess][3]]
  84. ]
  85. [h4 References]
  86. * [@http://mathworld.wolfram.com/LaplaceDistribution.html Weisstein, Eric W. "Laplace Distribution."] From MathWorld--A Wolfram Web Resource.
  87. * [@http://en.wikipedia.org/wiki/Laplace_distribution Laplace Distribution]
  88. * M. Abramowitz and I. A. Stegun, Handbook of Mathematical Functions, 1972, p. 930.
  89. [endsect] [/section:laplace_dist laplace]
  90. [/
  91. Copyright 2008, 2009 John Maddock, Paul A. Bristow and M.A. (Thijs) van den Berg.
  92. Distributed under the Boost Software License, Version 1.0.
  93. (See accompanying file LICENSE_1_0.txt or copy at
  94. http://www.boost.org/LICENSE_1_0.txt).
  95. ]