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