File: normal.qbk

package info (click to toggle)
boost1.88 1.88.0-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 576,932 kB
  • sloc: cpp: 4,149,234; xml: 136,789; ansic: 35,092; python: 33,910; asm: 5,698; sh: 4,604; ada: 1,681; makefile: 1,633; pascal: 1,139; perl: 1,124; sql: 640; yacc: 478; ruby: 271; java: 77; lisp: 24; csh: 6
file content (123 lines) | stat: -rw-r--r-- 4,122 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
[section:normal_dist Normal (Gaussian) Distribution]

``#include <boost/math/distributions/normal.hpp>``

   namespace boost{ namespace math{

   template <class RealType = double,
             class ``__Policy``   = ``__policy_class`` >
   class normal_distribution;

   typedef normal_distribution<> normal;

   template <class RealType, class ``__Policy``>
   class normal_distribution
   {
   public:
      typedef RealType value_type;
      typedef Policy   policy_type;
      // Construct:
      BOOST_MATH_GPU_ENABLED normal_distribution(RealType mean = 0, RealType sd = 1);
      // Accessors:
      BOOST_MATH_GPU_ENABLED RealType mean()const; // location.
      BOOST_MATH_GPU_ENABLED RealType standard_deviation()const; // scale.
      // Synonyms, provided to allow generic use of find_location and find_scale.
      BOOST_MATH_GPU_ENABLED RealType location()const;
      BOOST_MATH_GPU_ENABLED RealType scale()const;
   };

   }} // namespaces

The normal distribution is probably the most well known statistical
distribution: it is also known as the Gaussian Distribution.
A normal distribution with mean zero and standard deviation one
is known as the ['Standard Normal Distribution].

Given mean [mu] and standard deviation [sigma] it has the PDF:

[equation normal_ref1]

The variation the PDF with its parameters is illustrated
in the following graph:

[graph normal_pdf]

The cumulative distribution function is given by

[equation normal_cdf]

and illustrated by this graph

[graph normal_cdf]


[h4 Member Functions]

   BOOST_MATH_GPU_ENABLED normal_distribution(RealType mean = 0, RealType sd = 1);

Constructs a normal distribution with mean /mean/ and
standard deviation /sd/.

Requires /sd/ > 0, otherwise __domain_error is called.

   BOOST_MATH_GPU_ENABLED RealType mean()const;
   BOOST_MATH_GPU_ENABLED RealType location()const;

both return the /mean/ of this distribution.

   BOOST_MATH_GPU_ENABLED RealType standard_deviation()const;
   BOOST_MATH_GPU_ENABLED RealType scale()const;

both return the /standard deviation/ of this distribution.
(Redundant location and scale function are provided to match other similar distributions,
allowing the functions find_location and find_scale to be used generically).

[h4 Non-member Accessors]

All the [link math_toolkit.dist_ref.nmp usual non-member accessor functions] that are generic to all
distributions are supported: __usual_accessors.
For this distribution all non-member accessor functions are marked with `BOOST_MATH_GPU_ENABLED` and can
be run on both host and device.

The domain of the random variable is \[-[max_value], +[min_value]\].
However, the pdf of +[infin] and -[infin] = 0 is also supported,
and cdf at -[infin] = 0, cdf at +[infin] = 1,
and complement cdf -[infin] = 1 and +[infin] = 0,
if RealType permits.

[h4 Accuracy]

The normal distribution is implemented in terms of the
[link math_toolkit.sf_erf.error_function error function],
and as such should have very low error rates.

[h4 Implementation]

In the following table /m/ is the mean of the distribution,
and /s/ is its standard deviation.

[table
[[Function][Implementation Notes]]
[[pdf][Using the relation: pdf = e[super -(x-m)[super 2]\/(2s[super 2])] \/ (s * sqrt(2*pi)) ]]
[[logpdf][log(pdf) = -log(s) - log(2*[pi])/2 - (x-mean)[super 2]/(2*s[super 2]) ]]
[[cdf][Using the relation: p = 0.5 * __erfc(-(x-m)/(s*sqrt(2))) ]]
[[cdf complement][Using the relation: q = 0.5 * __erfc((x-m)/(s*sqrt(2))) ]]
[[quantile][Using the relation: x = m - s * sqrt(2) * __erfc_inv(2*p)]]
[[quantile from the complement][Using the relation: x = m + s * sqrt(2) * __erfc_inv(2*p)]]
[[mean and standard deviation][The same as `dist.mean()` and `dist.standard_deviation()`]]
[[mode][The same as the mean.]]
[[median][The same as the mean.]]
[[skewness][0]]
[[kurtosis][3]]
[[kurtosis excess][0]]
]

[endsect] [/section:normal_dist Normal]

[/ normal.qbk
  Copyright 2006, 2007, 2012 John Maddock and Paul A. Bristow.
  Distributed under the Boost Software License, Version 1.0.
  (See accompanying file LICENSE_1_0.txt or copy at
  http://www.boost.org/LICENSE_1_0.txt).
]