3 <meta http-equiv=
"Content-Type" content=
"text/html; charset=US-ASCII">
4 <title>Beta Distribution
</title>
5 <link rel=
"stylesheet" href=
"../../../math.css" type=
"text/css">
6 <meta name=
"generator" content=
"DocBook XSL Stylesheets V1.77.1">
7 <link rel=
"home" href=
"../../../index.html" title=
"Math Toolkit 2.5.1">
8 <link rel=
"up" href=
"../dists.html" title=
"Distributions">
9 <link rel=
"prev" href=
"bernoulli_dist.html" title=
"Bernoulli Distribution">
10 <link rel=
"next" href=
"binomial_dist.html" title=
"Binomial Distribution">
12 <body bgcolor=
"white" text=
"black" link=
"#0000FF" vlink=
"#840084" alink=
"#0000FF">
13 <table cellpadding=
"2" width=
"100%"><tr>
14 <td valign=
"top"><img alt=
"Boost C++ Libraries" width=
"277" height=
"86" src=
"../../../../../../../boost.png"></td>
15 <td align=
"center"><a href=
"../../../../../../../index.html">Home
</a></td>
16 <td align=
"center"><a href=
"../../../../../../../libs/libraries.htm">Libraries
</a></td>
17 <td align=
"center"><a href=
"http://www.boost.org/users/people.html">People
</a></td>
18 <td align=
"center"><a href=
"http://www.boost.org/users/faq.html">FAQ
</a></td>
19 <td align=
"center"><a href=
"../../../../../../../more/index.htm">More
</a></td>
22 <div class=
"spirit-nav">
23 <a accesskey=
"p" href=
"bernoulli_dist.html"><img src=
"../../../../../../../doc/src/images/prev.png" alt=
"Prev"></a><a accesskey=
"u" href=
"../dists.html"><img src=
"../../../../../../../doc/src/images/up.png" alt=
"Up"></a><a accesskey=
"h" href=
"../../../index.html"><img src=
"../../../../../../../doc/src/images/home.png" alt=
"Home"></a><a accesskey=
"n" href=
"binomial_dist.html"><img src=
"../../../../../../../doc/src/images/next.png" alt=
"Next"></a>
26 <div class=
"titlepage"><div><div><h4 class=
"title">
27 <a name=
"math_toolkit.dist_ref.dists.beta_dist"></a><a class=
"link" href=
"beta_dist.html" title=
"Beta Distribution">Beta Distribution
</a>
28 </h4></div></div></div>
29 <pre class=
"programlisting"><span class=
"preprocessor">#include
</span> <span class=
"special"><</span><span class=
"identifier">boost
</span><span class=
"special">/
</span><span class=
"identifier">math
</span><span class=
"special">/
</span><span class=
"identifier">distributions
</span><span class=
"special">/
</span><span class=
"identifier">beta
</span><span class=
"special">.
</span><span class=
"identifier">hpp
</span><span class=
"special">></span></pre>
30 <pre class=
"programlisting"><span class=
"keyword">namespace
</span> <span class=
"identifier">boost
</span><span class=
"special">{
</span> <span class=
"keyword">namespace
</span> <span class=
"identifier">math
</span><span class=
"special">{
</span>
32 <span class=
"keyword">template
</span> <span class=
"special"><</span><span class=
"keyword">class
</span> <span class=
"identifier">RealType
</span> <span class=
"special">=
</span> <span class=
"keyword">double
</span><span class=
"special">,
</span>
33 <span class=
"keyword">class
</span> <a class=
"link" href=
"../../../policy.html" title=
"Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy
</a> <span class=
"special">=
</span> <a class=
"link" href=
"../../pol_ref/pol_ref_ref.html" title=
"Policy Class Reference">policies::policy
<></a> <span class=
"special">></span>
34 <span class=
"keyword">class
</span> <span class=
"identifier">beta_distribution
</span><span class=
"special">;
</span>
36 <span class=
"comment">// typedef beta_distribution
<double
> beta;
</span>
37 <span class=
"comment">// Note that this is deliberately NOT provided,
</span>
38 <span class=
"comment">// to avoid a clash with the function name beta.
</span>
40 <span class=
"keyword">template
</span> <span class=
"special"><</span><span class=
"keyword">class
</span> <span class=
"identifier">RealType
</span><span class=
"special">,
</span> <span class=
"keyword">class
</span> <a class=
"link" href=
"../../../policy.html" title=
"Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy
</a><span class=
"special">></span>
41 <span class=
"keyword">class
</span> <span class=
"identifier">beta_distribution
</span>
42 <span class=
"special">{
</span>
43 <span class=
"keyword">public
</span><span class=
"special">:
</span>
44 <span class=
"keyword">typedef
</span> <span class=
"identifier">RealType
</span> <span class=
"identifier">value_type
</span><span class=
"special">;
</span>
45 <span class=
"keyword">typedef
</span> <span class=
"identifier">Policy
</span> <span class=
"identifier">policy_type
</span><span class=
"special">;
</span>
46 <span class=
"comment">// Constructor from two shape parameters, alpha
& beta:
</span>
47 <span class=
"identifier">beta_distribution
</span><span class=
"special">(
</span><span class=
"identifier">RealType
</span> <span class=
"identifier">a
</span><span class=
"special">,
</span> <span class=
"identifier">RealType
</span> <span class=
"identifier">b
</span><span class=
"special">);
</span>
49 <span class=
"comment">// Parameter accessors:
</span>
50 <span class=
"identifier">RealType
</span> <span class=
"identifier">alpha
</span><span class=
"special">()
</span> <span class=
"keyword">const
</span><span class=
"special">;
</span>
51 <span class=
"identifier">RealType
</span> <span class=
"identifier">beta
</span><span class=
"special">()
</span> <span class=
"keyword">const
</span><span class=
"special">;
</span>
53 <span class=
"comment">// Parameter estimators of alpha or beta from mean and variance.
</span>
54 <span class=
"keyword">static
</span> <span class=
"identifier">RealType
</span> <span class=
"identifier">find_alpha
</span><span class=
"special">(
</span>
55 <span class=
"identifier">RealType
</span> <span class=
"identifier">mean
</span><span class=
"special">,
</span> <span class=
"comment">// Expected value of mean.
</span>
56 <span class=
"identifier">RealType
</span> <span class=
"identifier">variance
</span><span class=
"special">);
</span> <span class=
"comment">// Expected value of variance.
</span>
58 <span class=
"keyword">static
</span> <span class=
"identifier">RealType
</span> <span class=
"identifier">find_beta
</span><span class=
"special">(
</span>
59 <span class=
"identifier">RealType
</span> <span class=
"identifier">mean
</span><span class=
"special">,
</span> <span class=
"comment">// Expected value of mean.
</span>
60 <span class=
"identifier">RealType
</span> <span class=
"identifier">variance
</span><span class=
"special">);
</span> <span class=
"comment">// Expected value of variance.
</span>
62 <span class=
"comment">// Parameter estimators from
</span>
63 <span class=
"comment">// either alpha or beta, and x and probability.
</span>
65 <span class=
"keyword">static
</span> <span class=
"identifier">RealType
</span> <span class=
"identifier">find_alpha
</span><span class=
"special">(
</span>
66 <span class=
"identifier">RealType
</span> <span class=
"identifier">beta
</span><span class=
"special">,
</span> <span class=
"comment">// from beta.
</span>
67 <span class=
"identifier">RealType
</span> <span class=
"identifier">x
</span><span class=
"special">,
</span> <span class=
"comment">// x.
</span>
68 <span class=
"identifier">RealType
</span> <span class=
"identifier">probability
</span><span class=
"special">);
</span> <span class=
"comment">// cdf
</span>
70 <span class=
"keyword">static
</span> <span class=
"identifier">RealType
</span> <span class=
"identifier">find_beta
</span><span class=
"special">(
</span>
71 <span class=
"identifier">RealType
</span> <span class=
"identifier">alpha
</span><span class=
"special">,
</span> <span class=
"comment">// alpha.
</span>
72 <span class=
"identifier">RealType
</span> <span class=
"identifier">x
</span><span class=
"special">,
</span> <span class=
"comment">// probability x.
</span>
73 <span class=
"identifier">RealType
</span> <span class=
"identifier">probability
</span><span class=
"special">);
</span> <span class=
"comment">// probability cdf.
</span>
74 <span class=
"special">};
</span>
76 <span class=
"special">}}
</span> <span class=
"comment">// namespaces
</span>
79 The class type
<code class=
"computeroutput"><span class=
"identifier">beta_distribution
</span></code>
80 represents a
<a href=
"http://en.wikipedia.org/wiki/Beta_distribution" target=
"_top">beta
81 </a> <a href=
"http://en.wikipedia.org/wiki/Probability_distribution" target=
"_top">probability
82 distribution function
</a>.
85 The
<a href=
"http://mathworld.wolfram.com/BetaDistribution.htm" target=
"_top">beta
86 distribution
</a> is used as a
<a href=
"http://en.wikipedia.org/wiki/Prior_distribution" target=
"_top">prior
87 distribution
</a> for binomial proportions in
<a href=
"http://mathworld.wolfram.com/BayesianAnalysis.html" target=
"_top">Bayesian
91 See also:
<a href=
"http://documents.wolfram.com/calculationcenter/v2/Functions/ListsMatrices/Statistics/BetaDistribution.html" target=
"_top">beta
92 distribution
</a> and
<a href=
"http://en.wikipedia.org/wiki/Bayesian_statistics" target=
"_top">Bayesian
96 How the beta distribution is used for
<a href=
"http://home.uchicago.edu/~grynav/bayes/ABSLec5.ppt" target=
"_top">Bayesian
97 analysis of one parameter models
</a> is discussed by Jeff Grynaviski.
100 The
<a href=
"http://en.wikipedia.org/wiki/Probability_density_function" target=
"_top">probability
101 density function PDF
</a> for the
<a href=
"http://en.wikipedia.org/wiki/Beta_distribution" target=
"_top">beta
102 distribution
</a> defined on the interval [
0,
1] is given by:
105 f(x;
α,
β) = x
<sup>α -
1</sup> (
1 - x)
<sup>β -
1</sup> / B(
α,
β)
108 where B(
α,
β) is the
<a href=
"http://en.wikipedia.org/wiki/Beta_function" target=
"_top">beta
109 function
</a>, implemented in this library as
<a class=
"link" href=
"../../sf_beta/beta_function.html" title=
"Beta">beta
</a>.
110 Division by the beta function ensures that the pdf is normalized to the
114 The following graph illustrates examples of the pdf for various values
115 of the shape parameters. Note the
α =
β =
2 (blue line) is dome-shaped, and
116 might be approximated by a symmetrical triangular distribution.
119 <span class=
"inlinemediaobject"><img src=
"../../../../graphs/beta_pdf.svg" align=
"middle"></span>
122 If
α =
β =
1, then it is a __space
<a href=
"http://en.wikipedia.org/wiki/Uniform_distribution_%28continuous%29" target=
"_top">uniform
123 distribution
</a>, equal to unity in the entire interval x =
0 to
1.
124 If
α __space and
β __space are
< 1, then the pdf is U-shaped. If
α !=
β, then
125 the shape is asymmetric and could be approximated by a triangle whose apex
126 is away from the centre (where x = half).
129 <a name=
"math_toolkit.dist_ref.dists.beta_dist.h0"></a>
130 <span class=
"phrase"><a name=
"math_toolkit.dist_ref.dists.beta_dist.member_functions"></a></span><a class=
"link" href=
"beta_dist.html#math_toolkit.dist_ref.dists.beta_dist.member_functions">Member
134 <a name=
"math_toolkit.dist_ref.dists.beta_dist.h1"></a>
135 <span class=
"phrase"><a name=
"math_toolkit.dist_ref.dists.beta_dist.constructor"></a></span><a class=
"link" href=
"beta_dist.html#math_toolkit.dist_ref.dists.beta_dist.constructor">Constructor
</a>
137 <pre class=
"programlisting"><span class=
"identifier">beta_distribution
</span><span class=
"special">(
</span><span class=
"identifier">RealType
</span> <span class=
"identifier">alpha
</span><span class=
"special">,
</span> <span class=
"identifier">RealType
</span> <span class=
"identifier">beta
</span><span class=
"special">);
</span>
140 Constructs a beta distribution with shape parameters
<span class=
"emphasis"><em>alpha
</em></span>
141 and
<span class=
"emphasis"><em>beta
</em></span>.
144 Requires alpha,beta
> 0,otherwise
<a class=
"link" href=
"../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error
</a>
145 is called. Note that technically the beta distribution is defined for alpha,beta
146 >=
0, but it's not clear whether any program can actually make use of
147 that latitude or how many of the non-member functions can be usefully defined
148 in that case. Therefore for now, we regard it as an error if alpha or beta
154 <pre class=
"programlisting"><span class=
"identifier">beta_distribution
</span><span class=
"special"><></span> <span class=
"identifier">mybeta
</span><span class=
"special">(
</span><span class=
"number">2</span><span class=
"special">,
</span> <span class=
"number">5</span><span class=
"special">);
</span>
157 Constructs a the beta distribution with alpha=
2 and beta=
5 (shown in yellow
161 <a name=
"math_toolkit.dist_ref.dists.beta_dist.h2"></a>
162 <span class=
"phrase"><a name=
"math_toolkit.dist_ref.dists.beta_dist.parameter_accessors"></a></span><a class=
"link" href=
"beta_dist.html#math_toolkit.dist_ref.dists.beta_dist.parameter_accessors">Parameter
165 <pre class=
"programlisting"><span class=
"identifier">RealType
</span> <span class=
"identifier">alpha
</span><span class=
"special">()
</span> <span class=
"keyword">const
</span><span class=
"special">;
</span>
168 Returns the parameter
<span class=
"emphasis"><em>alpha
</em></span> from which this distribution
171 <pre class=
"programlisting"><span class=
"identifier">RealType
</span> <span class=
"identifier">beta
</span><span class=
"special">()
</span> <span class=
"keyword">const
</span><span class=
"special">;
</span>
174 Returns the parameter
<span class=
"emphasis"><em>beta
</em></span> from which this distribution
180 <pre class=
"programlisting"><span class=
"identifier">beta_distribution
</span><span class=
"special"><></span> <span class=
"identifier">mybeta
</span><span class=
"special">(
</span><span class=
"number">2</span><span class=
"special">,
</span> <span class=
"number">5</span><span class=
"special">);
</span>
181 <span class=
"identifier">assert
</span><span class=
"special">(
</span><span class=
"identifier">mybeta
</span><span class=
"special">.
</span><span class=
"identifier">alpha
</span><span class=
"special">()
</span> <span class=
"special">==
</span> <span class=
"number">2.
</span><span class=
"special">);
</span> <span class=
"comment">// mybeta.alpha() returns
2</span>
182 <span class=
"identifier">assert
</span><span class=
"special">(
</span><span class=
"identifier">mybeta
</span><span class=
"special">.
</span><span class=
"identifier">beta
</span><span class=
"special">()
</span> <span class=
"special">==
</span> <span class=
"number">5.
</span><span class=
"special">);
</span> <span class=
"comment">// mybeta.beta() returns
5</span>
185 <a name=
"math_toolkit.dist_ref.dists.beta_dist.h3"></a>
186 <span class=
"phrase"><a name=
"math_toolkit.dist_ref.dists.beta_dist.parameter_estimators"></a></span><a class=
"link" href=
"beta_dist.html#math_toolkit.dist_ref.dists.beta_dist.parameter_estimators">Parameter
190 Two pairs of parameter estimators are provided.
193 One estimates either
α __space or
β __space from presumed-known mean and variance.
196 The other pair estimates either
α __space or
β __space from the cdf and x.
199 It is also possible to estimate
α __space and
β __space from 'known' mode
&
200 quantile. For example, calculators are provided by the
<a href=
"http://www.ausvet.com.au/pprev/content.php?page=PPscript" target=
"_top">Pooled
201 Prevalence Calculator
</a> and
<a href=
"http://www.epi.ucdavis.edu/diagnostictests/betabuster.html" target=
"_top">Beta
202 Buster
</a> but this is not yet implemented here.
204 <pre class=
"programlisting"><span class=
"keyword">static
</span> <span class=
"identifier">RealType
</span> <span class=
"identifier">find_alpha
</span><span class=
"special">(
</span>
205 <span class=
"identifier">RealType
</span> <span class=
"identifier">mean
</span><span class=
"special">,
</span> <span class=
"comment">// Expected value of mean.
</span>
206 <span class=
"identifier">RealType
</span> <span class=
"identifier">variance
</span><span class=
"special">);
</span> <span class=
"comment">// Expected value of variance.
</span>
209 Returns the unique value of
α   that corresponds to a beta distribution with
210 mean
<span class=
"emphasis"><em>mean
</em></span> and variance
<span class=
"emphasis"><em>variance
</em></span>.
212 <pre class=
"programlisting"><span class=
"keyword">static
</span> <span class=
"identifier">RealType
</span> <span class=
"identifier">find_beta
</span><span class=
"special">(
</span>
213 <span class=
"identifier">RealType
</span> <span class=
"identifier">mean
</span><span class=
"special">,
</span> <span class=
"comment">// Expected value of mean.
</span>
214 <span class=
"identifier">RealType
</span> <span class=
"identifier">variance
</span><span class=
"special">);
</span> <span class=
"comment">// Expected value of variance.
</span>
217 Returns the unique value of
β   that corresponds to a beta distribution with
218 mean
<span class=
"emphasis"><em>mean
</em></span> and variance
<span class=
"emphasis"><em>variance
</em></span>.
220 <pre class=
"programlisting"><span class=
"keyword">static
</span> <span class=
"identifier">RealType
</span> <span class=
"identifier">find_alpha
</span><span class=
"special">(
</span>
221 <span class=
"identifier">RealType
</span> <span class=
"identifier">beta
</span><span class=
"special">,
</span> <span class=
"comment">// from beta.
</span>
222 <span class=
"identifier">RealType
</span> <span class=
"identifier">x
</span><span class=
"special">,
</span> <span class=
"comment">// x.
</span>
223 <span class=
"identifier">RealType
</span> <span class=
"identifier">probability
</span><span class=
"special">);
</span> <span class=
"comment">// probability cdf
</span>
226 Returns the value of
α   that gives:
<code class=
"computeroutput"><span class=
"identifier">cdf
</span><span class=
"special">(
</span><span class=
"identifier">beta_distribution
</span><span class=
"special"><</span><span class=
"identifier">RealType
</span><span class=
"special">>(
</span><span class=
"identifier">alpha
</span><span class=
"special">,
</span> <span class=
"identifier">beta
</span><span class=
"special">),
</span> <span class=
"identifier">x
</span><span class=
"special">)
</span> <span class=
"special">==
</span> <span class=
"identifier">probability
</span></code>.
228 <pre class=
"programlisting"><span class=
"keyword">static
</span> <span class=
"identifier">RealType
</span> <span class=
"identifier">find_beta
</span><span class=
"special">(
</span>
229 <span class=
"identifier">RealType
</span> <span class=
"identifier">alpha
</span><span class=
"special">,
</span> <span class=
"comment">// alpha.
</span>
230 <span class=
"identifier">RealType
</span> <span class=
"identifier">x
</span><span class=
"special">,
</span> <span class=
"comment">// probability x.
</span>
231 <span class=
"identifier">RealType
</span> <span class=
"identifier">probability
</span><span class=
"special">);
</span> <span class=
"comment">// probability cdf.
</span>
234 Returns the value of
β   that gives:
<code class=
"computeroutput"><span class=
"identifier">cdf
</span><span class=
"special">(
</span><span class=
"identifier">beta_distribution
</span><span class=
"special"><</span><span class=
"identifier">RealType
</span><span class=
"special">>(
</span><span class=
"identifier">alpha
</span><span class=
"special">,
</span> <span class=
"identifier">beta
</span><span class=
"special">),
</span> <span class=
"identifier">x
</span><span class=
"special">)
</span> <span class=
"special">==
</span> <span class=
"identifier">probability
</span></code>.
237 <a name=
"math_toolkit.dist_ref.dists.beta_dist.h4"></a>
238 <span class=
"phrase"><a name=
"math_toolkit.dist_ref.dists.beta_dist.non_member_accessor_functions"></a></span><a class=
"link" href=
"beta_dist.html#math_toolkit.dist_ref.dists.beta_dist.non_member_accessor_functions">Non-member
239 Accessor Functions
</a>
242 All the
<a class=
"link" href=
"../nmp.html" title=
"Non-Member Properties">usual non-member accessor
243 functions
</a> that are generic to all distributions are supported:
244 <a class=
"link" href=
"../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function
</a>,
245 <a class=
"link" href=
"../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function
</a>,
246 <a class=
"link" href=
"../nmp.html#math_toolkit.dist_ref.nmp.quantile">Quantile
</a>,
<a class=
"link" href=
"../nmp.html#math_toolkit.dist_ref.nmp.hazard">Hazard Function
</a>,
<a class=
"link" href=
"../nmp.html#math_toolkit.dist_ref.nmp.chf">Cumulative Hazard Function
</a>,
247 <a class=
"link" href=
"../nmp.html#math_toolkit.dist_ref.nmp.mean">mean
</a>,
<a class=
"link" href=
"../nmp.html#math_toolkit.dist_ref.nmp.median">median
</a>,
248 <a class=
"link" href=
"../nmp.html#math_toolkit.dist_ref.nmp.mode">mode
</a>,
<a class=
"link" href=
"../nmp.html#math_toolkit.dist_ref.nmp.variance">variance
</a>,
249 <a class=
"link" href=
"../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation
</a>,
250 <a class=
"link" href=
"../nmp.html#math_toolkit.dist_ref.nmp.skewness">skewness
</a>,
<a class=
"link" href=
"../nmp.html#math_toolkit.dist_ref.nmp.kurtosis">kurtosis
</a>,
<a class=
"link" href=
"../nmp.html#math_toolkit.dist_ref.nmp.kurtosis_excess">kurtosis_excess
</a>,
251 <a class=
"link" href=
"../nmp.html#math_toolkit.dist_ref.nmp.range">range
</a> and
<a class=
"link" href=
"../nmp.html#math_toolkit.dist_ref.nmp.support">support
</a>.
254 The formulae for calculating these are shown in the table below, and at
255 <a href=
"http://mathworld.wolfram.com/BetaDistribution.html" target=
"_top">Wolfram
259 <a name=
"math_toolkit.dist_ref.dists.beta_dist.h5"></a>
260 <span class=
"phrase"><a name=
"math_toolkit.dist_ref.dists.beta_dist.applications"></a></span><a class=
"link" href=
"beta_dist.html#math_toolkit.dist_ref.dists.beta_dist.applications">Applications
</a>
263 The beta distribution can be used to model events constrained to take place
264 within an interval defined by a minimum and maximum value: so it is used
265 in project management systems.
268 It is also widely used in
<a href=
"http://en.wikipedia.org/wiki/Bayesian_inference" target=
"_top">Bayesian
269 statistical inference
</a>.
272 <a name=
"math_toolkit.dist_ref.dists.beta_dist.h6"></a>
273 <span class=
"phrase"><a name=
"math_toolkit.dist_ref.dists.beta_dist.related_distributions"></a></span><a class=
"link" href=
"beta_dist.html#math_toolkit.dist_ref.dists.beta_dist.related_distributions">Related
277 The beta distribution with both
α __space and
β =
1 follows a
<a href=
"http://en.wikipedia.org/wiki/Uniform_distribution_%28continuous%29" target=
"_top">uniform
281 The
<a href=
"http://en.wikipedia.org/wiki/Triangular_distribution" target=
"_top">triangular
</a>
282 is used when less precise information is available.
285 The
<a href=
"http://en.wikipedia.org/wiki/Binomial_distribution" target=
"_top">binomial
286 distribution
</a> is closely related when
α __space and
β __space are integers.
289 With integer values of
α __space and
β __space the distribution B(i, j) is
290 that of the j-th highest of a sample of i + j +
1 independent random variables
291 uniformly distributed between
0 and
1. The cumulative probability from
292 0 to x is thus the probability that the j-th highest value is less than
293 x. Or it is the probability that at least i of the random variables are
294 less than x, a probability given by summing over the
<a class=
"link" href=
"binomial_dist.html" title=
"Binomial Distribution">Binomial
295 Distribution
</a> with its p parameter set to x.
298 <a name=
"math_toolkit.dist_ref.dists.beta_dist.h7"></a>
299 <span class=
"phrase"><a name=
"math_toolkit.dist_ref.dists.beta_dist.accuracy"></a></span><a class=
"link" href=
"beta_dist.html#math_toolkit.dist_ref.dists.beta_dist.accuracy">Accuracy
</a>
302 This distribution is implemented using the
<a class=
"link" href=
"../../sf_beta/beta_function.html" title=
"Beta">beta
303 functions
</a> <a class=
"link" href=
"../../sf_beta/beta_function.html" title=
"Beta">beta
</a>
304 and
<a class=
"link" href=
"../../sf_beta/ibeta_function.html" title=
"Incomplete Beta Functions">incomplete beta
305 functions
</a> <a class=
"link" href=
"../../sf_beta/ibeta_function.html" title=
"Incomplete Beta Functions">ibeta
</a>
306 and
<a class=
"link" href=
"../../sf_beta/ibeta_function.html" title=
"Incomplete Beta Functions">ibetac
</a>;
307 please refer to these functions for information on accuracy.
310 <a name=
"math_toolkit.dist_ref.dists.beta_dist.h8"></a>
311 <span class=
"phrase"><a name=
"math_toolkit.dist_ref.dists.beta_dist.implementation"></a></span><a class=
"link" href=
"beta_dist.html#math_toolkit.dist_ref.dists.beta_dist.implementation">Implementation
</a>
314 In the following table
<span class=
"emphasis"><em>a
</em></span> and
<span class=
"emphasis"><em>b
</em></span>
315 are the parameters
α   and
β,
<span class=
"emphasis"><em>x
</em></span> is the random variable,
316 <span class=
"emphasis"><em>p
</em></span> is the probability and
<span class=
"emphasis"><em>q =
1-p
</em></span>.
318 <div class=
"informaltable"><table class=
"table">
344 f(x;
α,
β) = x
<sup>α -
1</sup> (
1 - x)
<sup>β -
1</sup> / B(
α,
β)
347 Implemented using
<a class=
"link" href=
"../../sf_beta/beta_derivative.html" title=
"Derivative of the Incomplete Beta Function">ibeta_derivative
</a>(a,
360 Using the incomplete beta function
<a class=
"link" href=
"../../sf_beta/ibeta_function.html" title=
"Incomplete Beta Functions">ibeta
</a>(a,
373 <a class=
"link" href=
"../../sf_beta/ibeta_function.html" title=
"Incomplete Beta Functions">ibetac
</a>(a,
386 Using the inverse incomplete beta function
<a class=
"link" href=
"../../sf_beta/ibeta_inv_function.html" title=
"The Incomplete Beta Function Inverses">ibeta_inv
</a>(a,
394 quantile from the complement
399 <a class=
"link" href=
"../../sf_beta/ibeta_inv_function.html" title=
"The Incomplete Beta Function Inverses">ibetac_inv
</a>(a,
412 <code class=
"computeroutput"><span class=
"identifier">a
</span><span class=
"special">/(
</span><span class=
"identifier">a
</span><span class=
"special">+
</span><span class=
"identifier">b
</span><span class=
"special">)
</span></code>
424 <code class=
"computeroutput"><span class=
"identifier">a
</span> <span class=
"special">*
</span>
425 <span class=
"identifier">b
</span> <span class=
"special">/
</span>
426 <span class=
"special">(
</span><span class=
"identifier">a
</span><span class=
"special">+
</span><span class=
"identifier">b
</span><span class=
"special">)^
</span><span class=
"number">2</span> <span class=
"special">*
</span> <span class=
"special">(
</span><span class=
"identifier">a
</span> <span class=
"special">+
</span>
427 <span class=
"identifier">b
</span> <span class=
"special">+
</span>
428 <span class=
"number">1</span><span class=
"special">)
</span></code>
440 <code class=
"computeroutput"><span class=
"special">(
</span><span class=
"identifier">a
</span><span class=
"special">-
</span><span class=
"number">1</span><span class=
"special">)
</span> <span class=
"special">/
</span>
441 <span class=
"special">(
</span><span class=
"identifier">a
</span>
442 <span class=
"special">+
</span> <span class=
"identifier">b
</span>
443 <span class=
"special">-
</span> <span class=
"number">2</span><span class=
"special">)
</span></code>
455 <code class=
"computeroutput"><span class=
"number">2</span> <span class=
"special">(
</span><span class=
"identifier">b
</span><span class=
"special">-
</span><span class=
"identifier">a
</span><span class=
"special">)
</span>
456 <span class=
"identifier">sqrt
</span><span class=
"special">(
</span><span class=
"identifier">a
</span><span class=
"special">+
</span><span class=
"identifier">b
</span><span class=
"special">+
</span><span class=
"number">1</span><span class=
"special">)/(
</span><span class=
"identifier">a
</span><span class=
"special">+
</span><span class=
"identifier">b
</span><span class=
"special">+
</span><span class=
"number">2</span><span class=
"special">)
</span> <span class=
"special">*
</span> <span class=
"identifier">sqrt
</span><span class=
"special">(
</span><span class=
"identifier">a
</span>
457 <span class=
"special">*
</span> <span class=
"identifier">b
</span><span class=
"special">)
</span></code>
469 <span class=
"inlinemediaobject"><img src=
"../../../../equations/beta_dist_kurtosis.svg"></span>
481 <code class=
"computeroutput"><span class=
"identifier">kurtosis
</span> <span class=
"special">+
</span>
482 <span class=
"number">3</span></code>
501 from mean and variance
506 <code class=
"computeroutput"><span class=
"identifier">mean
</span> <span class=
"special">*
</span>
507 <span class=
"special">((
</span> <span class=
"special">(
</span><span class=
"identifier">mean
</span> <span class=
"special">*
</span>
508 <span class=
"special">(
</span><span class=
"number">1</span>
509 <span class=
"special">-
</span> <span class=
"identifier">mean
</span><span class=
"special">))
</span> <span class=
"special">/
</span>
510 <span class=
"identifier">variance
</span><span class=
"special">)-
</span>
511 <span class=
"number">1</span><span class=
"special">)
</span></code>
521 from mean and variance
526 <code class=
"computeroutput"><span class=
"special">(
</span><span class=
"number">1</span>
527 <span class=
"special">-
</span> <span class=
"identifier">mean
</span><span class=
"special">)
</span> <span class=
"special">*
</span>
528 <span class=
"special">(((
</span><span class=
"identifier">mean
</span>
529 <span class=
"special">*
</span> <span class=
"special">(
</span><span class=
"number">1</span> <span class=
"special">-
</span> <span class=
"identifier">mean
</span><span class=
"special">))
</span>
530 <span class=
"special">/
</span><span class=
"identifier">variance
</span><span class=
"special">)-
</span><span class=
"number">1</span><span class=
"special">)
</span></code>
537 The member functions
<code class=
"computeroutput"><span class=
"identifier">find_alpha
</span></code>
538 and
<code class=
"computeroutput"><span class=
"identifier">find_beta
</span></code>
541 from cdf and probability x
544 and
<span class=
"bold"><strong>either
</strong></span> <code class=
"computeroutput"><span class=
"identifier">alpha
</span></code>
545 or
<code class=
"computeroutput"><span class=
"identifier">beta
</span></code>
550 Implemented in terms of the inverse incomplete beta functions
553 <a class=
"link" href=
"../../sf_beta/ibeta_inv_function.html" title=
"The Incomplete Beta Function Inverses">ibeta_inva
</a>,
554 and
<a class=
"link" href=
"../../sf_beta/ibeta_inv_function.html" title=
"The Incomplete Beta Function Inverses">ibeta_invb
</a>
562 <code class=
"computeroutput"><span class=
"identifier">find_alpha
</span></code>
567 <code class=
"computeroutput"><span class=
"identifier">ibeta_inva
</span><span class=
"special">(
</span><span class=
"identifier">beta
</span><span class=
"special">,
</span>
568 <span class=
"identifier">x
</span><span class=
"special">,
</span>
569 <span class=
"identifier">probability
</span><span class=
"special">)
</span></code>
576 <code class=
"computeroutput"><span class=
"identifier">find_beta
</span></code>
581 <code class=
"computeroutput"><span class=
"identifier">ibeta_invb
</span><span class=
"special">(
</span><span class=
"identifier">alpha
</span><span class=
"special">,
</span>
582 <span class=
"identifier">x
</span><span class=
"special">,
</span>
583 <span class=
"identifier">probability
</span><span class=
"special">)
</span></code>
590 <a name=
"math_toolkit.dist_ref.dists.beta_dist.h9"></a>
591 <span class=
"phrase"><a name=
"math_toolkit.dist_ref.dists.beta_dist.references"></a></span><a class=
"link" href=
"beta_dist.html#math_toolkit.dist_ref.dists.beta_dist.references">References
</a>
594 <a href=
"http://en.wikipedia.org/wiki/Beta_distribution" target=
"_top">Wikipedia Beta
598 <a href=
"http://www.itl.nist.gov/div898/handbook/eda/section3/eda366h.htm" target=
"_top">NIST
599 Exploratory Data Analysis
</a>
602 <a href=
"http://mathworld.wolfram.com/BetaDistribution.html" target=
"_top">Wolfram
606 <table xmlns:
rev=
"http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width=
"100%"><tr>
607 <td align=
"left"></td>
608 <td align=
"right"><div class=
"copyright-footer">Copyright
© 2006-
2010,
2012-
2014 Nikhar Agrawal,
609 Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
610 Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan R
åde, Gautam Sewani,
611 Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang
<p>
612 Distributed under the Boost Software License, Version
1.0. (See accompanying
613 file LICENSE_1_0.txt or copy at
<a href=
"http://www.boost.org/LICENSE_1_0.txt" target=
"_top">http://www.boost.org/LICENSE_1_0.txt
</a>)
618 <div class=
"spirit-nav">
619 <a accesskey=
"p" href=
"bernoulli_dist.html"><img src=
"../../../../../../../doc/src/images/prev.png" alt=
"Prev"></a><a accesskey=
"u" href=
"../dists.html"><img src=
"../../../../../../../doc/src/images/up.png" alt=
"Up"></a><a accesskey=
"h" href=
"../../../index.html"><img src=
"../../../../../../../doc/src/images/home.png" alt=
"Home"></a><a accesskey=
"n" href=
"binomial_dist.html"><img src=
"../../../../../../../doc/src/images/next.png" alt=
"Next"></a>