normal.qbk 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. [section:normal_dist Normal (Gaussian) Distribution]
  2. ``#include <boost/math/distributions/normal.hpp>``
  3. namespace boost{ namespace math{
  4. template <class RealType = double,
  5. class ``__Policy`` = ``__policy_class`` >
  6. class normal_distribution;
  7. typedef normal_distribution<> normal;
  8. template <class RealType, class ``__Policy``>
  9. class normal_distribution
  10. {
  11. public:
  12. typedef RealType value_type;
  13. typedef Policy policy_type;
  14. // Construct:
  15. normal_distribution(RealType mean = 0, RealType sd = 1);
  16. // Accessors:
  17. RealType mean()const; // location.
  18. RealType standard_deviation()const; // scale.
  19. // Synonyms, provided to allow generic use of find_location and find_scale.
  20. RealType location()const;
  21. RealType scale()const;
  22. };
  23. }} // namespaces
  24. The normal distribution is probably the most well known statistical
  25. distribution: it is also known as the Gaussian Distribution.
  26. A normal distribution with mean zero and standard deviation one
  27. is known as the ['Standard Normal Distribution].
  28. Given mean [mu] and standard deviation [sigma] it has the PDF:
  29. [equation normal_ref1]
  30. The variation the PDF with its parameters is illustrated
  31. in the following graph:
  32. [graph normal_pdf]
  33. The cumulative distribution function is given by
  34. [equation normal_cdf]
  35. and illustrated by this graph
  36. [graph normal_cdf]
  37. [h4 Member Functions]
  38. normal_distribution(RealType mean = 0, RealType sd = 1);
  39. Constructs a normal distribution with mean /mean/ and
  40. standard deviation /sd/.
  41. Requires /sd/ > 0, otherwise __domain_error is called.
  42. RealType mean()const;
  43. RealType location()const;
  44. both return the /mean/ of this distribution.
  45. RealType standard_deviation()const;
  46. RealType scale()const;
  47. both return the /standard deviation/ of this distribution.
  48. (Redundant location and scale function are provided to match other similar distributions,
  49. allowing the functions find_location and find_scale to be used generically).
  50. [h4 Non-member Accessors]
  51. All the [link math_toolkit.dist_ref.nmp usual non-member accessor functions] that are generic to all
  52. distributions are supported: __usual_accessors.
  53. The domain of the random variable is \[-[max_value], +[min_value]\].
  54. However, the pdf of +[infin] and -[infin] = 0 is also supported,
  55. and cdf at -[infin] = 0, cdf at +[infin] = 1,
  56. and complement cdf -[infin] = 1 and +[infin] = 0,
  57. if RealType permits.
  58. [h4 Accuracy]
  59. The normal distribution is implemented in terms of the
  60. [link math_toolkit.sf_erf.error_function error function],
  61. and as such should have very low error rates.
  62. [h4 Implementation]
  63. In the following table /m/ is the mean of the distribution,
  64. and /s/ is its standard deviation.
  65. [table
  66. [[Function][Implementation Notes]]
  67. [[pdf][Using the relation: pdf = e[super -(x-m)[super 2]\/(2s[super 2])] \/ (s * sqrt(2*pi)) ]]
  68. [[cdf][Using the relation: p = 0.5 * __erfc(-(x-m)/(s*sqrt(2))) ]]
  69. [[cdf complement][Using the relation: q = 0.5 * __erfc((x-m)/(s*sqrt(2))) ]]
  70. [[quantile][Using the relation: x = m - s * sqrt(2) * __erfc_inv(2*p)]]
  71. [[quantile from the complement][Using the relation: x = m + s * sqrt(2) * __erfc_inv(2*p)]]
  72. [[mean and standard deviation][The same as `dist.mean()` and `dist.standard_deviation()`]]
  73. [[mode][The same as the mean.]]
  74. [[median][The same as the mean.]]
  75. [[skewness][0]]
  76. [[kurtosis][3]]
  77. [[kurtosis excess][0]]
  78. ]
  79. [endsect] [/section:normal_dist Normal]
  80. [/ normal.qbk
  81. Copyright 2006, 2007, 2012 John Maddock and Paul A. Bristow.
  82. Distributed under the Boost Software License, Version 1.0.
  83. (See accompanying file LICENSE_1_0.txt or copy at
  84. http://www.boost.org/LICENSE_1_0.txt).
  85. ]