]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/doc/distributions/bernoulli.qbk
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / math / doc / distributions / bernoulli.qbk
1 [section:bernoulli_dist Bernoulli Distribution]
2
3 ``#include <boost/math/distributions/bernoulli.hpp>``
4
5 namespace boost{ namespace math{
6 template <class RealType = double,
7 class ``__Policy`` = ``__policy_class`` >
8 class bernoulli_distribution;
9
10 typedef bernoulli_distribution<> bernoulli;
11
12 template <class RealType, class ``__Policy``>
13 class bernoulli_distribution
14 {
15 public:
16 typedef RealType value_type;
17 typedef Policy policy_type;
18
19 bernoulli_distribution(RealType p); // Constructor.
20 // Accessor function.
21 RealType success_fraction() const
22 // Probability of success (as a fraction).
23 };
24 }} // namespaces
25
26 The Bernoulli distribution is a discrete distribution of the outcome
27 of a single trial with only two results, 0 (failure) or 1 (success),
28 with a probability of success p.
29
30 The Bernoulli distribution is the simplest building block
31 on which other discrete distributions of
32 sequences of independent Bernoulli trials can be based.
33
34 The Bernoulli is the binomial distribution (k = 1, p) with only one trial.
35
36 [@http://en.wikipedia.org/wiki/Probability_density_function probability density function pdf]
37 f(0) = 1 - p, f(1) = p.
38 [@http://en.wikipedia.org/wiki/Cumulative_Distribution_Function Cumulative distribution function]
39 D(k) = if (k == 0) 1 - p else 1.
40
41 The following graph illustrates how the
42 [@http://en.wikipedia.org/wiki/Probability_density_function probability density function pdf]
43 varies with the outcome of the single trial:
44
45 [graph bernoulli_pdf]
46
47 and the [@http://en.wikipedia.org/wiki/Cumulative_Distribution_Function Cumulative distribution function]
48
49 [graph bernoulli_cdf]
50
51 [h4 Member Functions]
52
53 bernoulli_distribution(RealType p);
54
55 Constructs a [@http://en.wikipedia.org/wiki/bernoulli_distribution
56 bernoulli distribution] with success_fraction /p/.
57
58 RealType success_fraction() const
59
60 Returns the /success_fraction/ parameter of this distribution.
61
62 [h4 Non-member Accessors]
63
64 All the [link math_toolkit.dist_ref.nmp usual non-member accessor functions]
65 that are generic to all distributions are supported: __usual_accessors.
66
67 The domain of the random variable is 0 and 1,
68 and the useful supported range is only 0 or 1.
69
70 Outside this range, functions are undefined, or may throw domain_error exception
71 and make an error message available.
72
73 [h4 Accuracy]
74
75 The Bernoulli distribution is implemented with simple arithmetic operators
76 and so should have errors within an epsilon or two.
77
78 [h4 Implementation]
79
80 In the following table /p/ is the probability of success and /q = 1-p/.
81 /k/ is the random variate, either 0 or 1.
82
83 [note The Bernoulli distribution is implemented here as a /strict discrete/ distribution.
84 If a generalised version, allowing k to be any real, is required then
85 the binomial distribution with a single trial should be used, for example:
86
87 `binomial_distribution(1, 0.25)`
88 ]
89
90 [table
91 [[Function][Implementation Notes]]
92 [[Supported range][{0, 1}]]
93 [[pdf][Using the relation: pdf = 1 - p for k = 0, else p ]]
94 [[cdf][Using the relation: cdf = 1 - p for k = 0, else 1]]
95 [[cdf complement][q = 1 - p]]
96 [[quantile][if x <= (1-p) 0 else 1]]
97 [[quantile from the complement][if x <= (1-p) 1 else 0]]
98 [[mean][p]]
99 [[variance][p * (1 - p)]]
100 [[mode][if (p < 0.5) 0 else 1]]
101 [[skewness][(1 - 2 * p) / sqrt(p * q)]]
102 [[kurtosis][6 * p * p - 6 * p +1/ p * q]]
103 [[kurtosis excess][kurtosis -3]]
104 ]
105
106 [h4 References]
107 * [@http://en.wikipedia.org/wiki/Bernoulli_distribution Wikpedia Bernoulli distribution]
108 * [@http://mathworld.wolfram.com/BernoulliDistribution.html Weisstein, Eric W. "Bernoulli Distribution." From MathWorld--A Wolfram Web Resource.]
109
110 [endsect] [/section:bernoulli_dist bernoulli]
111
112 [/
113 Copyright 2006 John Maddock and Paul A. Bristow.
114 Distributed under the Boost Software License, Version 1.0.
115 (See accompanying file LICENSE_1_0.txt or copy at
116 http://www.boost.org/LICENSE_1_0.txt).
117 ]
118