]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/math/doc/html/math_toolkit/dist_ref/dists/beta_dist.html
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / math / doc / html / math_toolkit / dist_ref / dists / beta_dist.html
CommitLineData
7c673cae
FG
1<html>
2<head>
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">
11</head>
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>
20</tr></table>
21<hr>
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>
24</div>
25<div class="section">
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">&lt;</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">&gt;</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>
31
32 <span class="keyword">template</span> <span class="special">&lt;</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&#160;15.&#160;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&lt;&gt;</a> <span class="special">&gt;</span>
34<span class="keyword">class</span> <span class="identifier">beta_distribution</span><span class="special">;</span>
35
36<span class="comment">// typedef beta_distribution&lt;double&gt; 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>
39
40<span class="keyword">template</span> <span class="special">&lt;</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&#160;15.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</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 &amp; 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>
48
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>
52
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>
57
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>
61
62 <span class="comment">// Parameter estimators from</span>
63 <span class="comment">// either alpha or beta, and x and probability.</span>
64
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>
69
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>
75
76<span class="special">}}</span> <span class="comment">// namespaces</span>
77</pre>
78<p>
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>.
83 </p>
84<p>
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
88 analysis</a>.
89 </p>
90<p>
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
93 statistics</a>.
94 </p>
95<p>
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.
98 </p>
99<p>
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:
103 </p>
104<p>
105 f(x;&#945;,&#946;) = x<sup>&#945; - 1</sup> (1 - x)<sup>&#946; -1</sup> / B(&#945;, &#946;)
106 </p>
107<p>
108 where B(&#945;, &#946;) 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
111 range zero to unity.
112 </p>
113<p>
114 The following graph illustrates examples of the pdf for various values
115 of the shape parameters. Note the &#945; = &#946; = 2 (blue line) is dome-shaped, and
116 might be approximated by a symmetrical triangular distribution.
117 </p>
118<p>
119 <span class="inlinemediaobject"><img src="../../../../graphs/beta_pdf.svg" align="middle"></span>
120 </p>
121<p>
122 If &#945; = &#946; = 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 &#945; __space and &#946; __space are &lt; 1, then the pdf is U-shaped. If &#945; != &#946;, then
125 the shape is asymmetric and could be approximated by a triangle whose apex
126 is away from the centre (where x = half).
127 </p>
128<h5>
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
131 Functions</a>
132 </h5>
133<h6>
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>
136 </h6>
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>
138</pre>
139<p>
140 Constructs a beta distribution with shape parameters <span class="emphasis"><em>alpha</em></span>
141 and <span class="emphasis"><em>beta</em></span>.
142 </p>
143<p>
144 Requires alpha,beta &gt; 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 &gt;= 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
149 is zero.
150 </p>
151<p>
152 For example:
153 </p>
154<pre class="programlisting"><span class="identifier">beta_distribution</span><span class="special">&lt;&gt;</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>
155</pre>
156<p>
157 Constructs a the beta distribution with alpha=2 and beta=5 (shown in yellow
158 in the graph above).
159 </p>
160<h6>
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
163 Accessors</a>
164 </h6>
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>
166</pre>
167<p>
168 Returns the parameter <span class="emphasis"><em>alpha</em></span> from which this distribution
169 was constructed.
170 </p>
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>
172</pre>
173<p>
174 Returns the parameter <span class="emphasis"><em>beta</em></span> from which this distribution
175 was constructed.
176 </p>
177<p>
178 So for example:
179 </p>
180<pre class="programlisting"><span class="identifier">beta_distribution</span><span class="special">&lt;&gt;</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>
183</pre>
184<h5>
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
187 Estimators</a>
188 </h5>
189<p>
190 Two pairs of parameter estimators are provided.
191 </p>
192<p>
193 One estimates either &#945; __space or &#946; __space from presumed-known mean and variance.
194 </p>
195<p>
196 The other pair estimates either &#945; __space or &#946; __space from the cdf and x.
197 </p>
198<p>
199 It is also possible to estimate &#945; __space and &#946; __space from 'known' mode &amp;
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.
203 </p>
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>
207</pre>
208<p>
209 Returns the unique value of &#945; &#160; 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>.
211 </p>
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>
215</pre>
216<p>
217 Returns the unique value of &#946; &#160; 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>.
219 </p>
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>
224</pre>
225<p>
226 Returns the value of &#945; &#160; that gives: <code class="computeroutput"><span class="identifier">cdf</span><span class="special">(</span><span class="identifier">beta_distribution</span><span class="special">&lt;</span><span class="identifier">RealType</span><span class="special">&gt;(</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>.
227 </p>
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>
232</pre>
233<p>
234 Returns the value of &#946; &#160; that gives: <code class="computeroutput"><span class="identifier">cdf</span><span class="special">(</span><span class="identifier">beta_distribution</span><span class="special">&lt;</span><span class="identifier">RealType</span><span class="special">&gt;(</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>.
235 </p>
236<h5>
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>
240 </h5>
241<p>
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>.
252 </p>
253<p>
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
256 Mathworld</a>.
257 </p>
258<h5>
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>
261 </h5>
262<p>
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.
266 </p>
267<p>
268 It is also widely used in <a href="http://en.wikipedia.org/wiki/Bayesian_inference" target="_top">Bayesian
269 statistical inference</a>.
270 </p>
271<h5>
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
274 distributions</a>
275 </h5>
276<p>
277 The beta distribution with both &#945; __space and &#946; = 1 follows a <a href="http://en.wikipedia.org/wiki/Uniform_distribution_%28continuous%29" target="_top">uniform
278 distribution</a>.
279 </p>
280<p>
281 The <a href="http://en.wikipedia.org/wiki/Triangular_distribution" target="_top">triangular</a>
282 is used when less precise information is available.
283 </p>
284<p>
285 The <a href="http://en.wikipedia.org/wiki/Binomial_distribution" target="_top">binomial
286 distribution</a> is closely related when &#945; __space and &#946; __space are integers.
287 </p>
288<p>
289 With integer values of &#945; __space and &#946; __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.
296 </p>
297<h5>
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>
300 </h5>
301<p>
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.
308 </p>
309<h5>
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>
312 </h5>
313<p>
314 In the following table <span class="emphasis"><em>a</em></span> and <span class="emphasis"><em>b</em></span>
315 are the parameters &#945; &#160; and &#946;, <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>.
317 </p>
318<div class="informaltable"><table class="table">
319<colgroup>
320<col>
321<col>
322</colgroup>
323<thead><tr>
324<th>
325 <p>
326 Function
327 </p>
328 </th>
329<th>
330 <p>
331 Implementation Notes
332 </p>
333 </th>
334</tr></thead>
335<tbody>
336<tr>
337<td>
338 <p>
339 pdf
340 </p>
341 </td>
342<td>
343 <p>
344 f(x;&#945;,&#946;) = x<sup>&#945; - 1</sup> (1 - x)<sup>&#946; -1</sup> / B(&#945;, &#946;)
345 </p>
346 <p>
347 Implemented using <a class="link" href="../../sf_beta/beta_derivative.html" title="Derivative of the Incomplete Beta Function">ibeta_derivative</a>(a,
348 b, x).
349 </p>
350 </td>
351</tr>
352<tr>
353<td>
354 <p>
355 cdf
356 </p>
357 </td>
358<td>
359 <p>
360 Using the incomplete beta function <a class="link" href="../../sf_beta/ibeta_function.html" title="Incomplete Beta Functions">ibeta</a>(a,
361 b, x)
362 </p>
363 </td>
364</tr>
365<tr>
366<td>
367 <p>
368 cdf complement
369 </p>
370 </td>
371<td>
372 <p>
373 <a class="link" href="../../sf_beta/ibeta_function.html" title="Incomplete Beta Functions">ibetac</a>(a,
374 b, x)
375 </p>
376 </td>
377</tr>
378<tr>
379<td>
380 <p>
381 quantile
382 </p>
383 </td>
384<td>
385 <p>
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,
387 b, p)
388 </p>
389 </td>
390</tr>
391<tr>
392<td>
393 <p>
394 quantile from the complement
395 </p>
396 </td>
397<td>
398 <p>
399 <a class="link" href="../../sf_beta/ibeta_inv_function.html" title="The Incomplete Beta Function Inverses">ibetac_inv</a>(a,
400 b, q)
401 </p>
402 </td>
403</tr>
404<tr>
405<td>
406 <p>
407 mean
408 </p>
409 </td>
410<td>
411 <p>
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>
413 </p>
414 </td>
415</tr>
416<tr>
417<td>
418 <p>
419 variance
420 </p>
421 </td>
422<td>
423 <p>
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>
429 </p>
430 </td>
431</tr>
432<tr>
433<td>
434 <p>
435 mode
436 </p>
437 </td>
438<td>
439 <p>
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>
444 </p>
445 </td>
446</tr>
447<tr>
448<td>
449 <p>
450 skewness
451 </p>
452 </td>
453<td>
454 <p>
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>
458 </p>
459 </td>
460</tr>
461<tr>
462<td>
463 <p>
464 kurtosis excess
465 </p>
466 </td>
467<td>
468 <p>
469 <span class="inlinemediaobject"><img src="../../../../equations/beta_dist_kurtosis.svg"></span>
470 </p>
471 </td>
472</tr>
473<tr>
474<td>
475 <p>
476 kurtosis
477 </p>
478 </td>
479<td>
480 <p>
481 <code class="computeroutput"><span class="identifier">kurtosis</span> <span class="special">+</span>
482 <span class="number">3</span></code>
483 </p>
484 </td>
485</tr>
486<tr>
487<td>
488 <p>
489 parameter estimation
490 </p>
491 </td>
492<td>
493 </td>
494</tr>
495<tr>
496<td>
497 <p>
498 alpha
499 </p>
500 <p>
501 from mean and variance
502 </p>
503 </td>
504<td>
505 <p>
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>
512 </p>
513 </td>
514</tr>
515<tr>
516<td>
517 <p>
518 beta
519 </p>
520 <p>
521 from mean and variance
522 </p>
523 </td>
524<td>
525 <p>
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>
531 </p>
532 </td>
533</tr>
534<tr>
535<td>
536 <p>
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>
539 </p>
540 <p>
541 from cdf and probability x
542 </p>
543 <p>
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>
546 </p>
547 </td>
548<td>
549 <p>
550 Implemented in terms of the inverse incomplete beta functions
551 </p>
552 <p>
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>
555 respectively.
556 </p>
557 </td>
558</tr>
559<tr>
560<td>
561 <p>
562 <code class="computeroutput"><span class="identifier">find_alpha</span></code>
563 </p>
564 </td>
565<td>
566 <p>
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>
570 </p>
571 </td>
572</tr>
573<tr>
574<td>
575 <p>
576 <code class="computeroutput"><span class="identifier">find_beta</span></code>
577 </p>
578 </td>
579<td>
580 <p>
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>
584 </p>
585 </td>
586</tr>
587</tbody>
588</table></div>
589<h5>
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>
592 </h5>
593<p>
594 <a href="http://en.wikipedia.org/wiki/Beta_distribution" target="_top">Wikipedia Beta
595 distribution</a>
596 </p>
597<p>
598 <a href="http://www.itl.nist.gov/div898/handbook/eda/section3/eda366h.htm" target="_top">NIST
599 Exploratory Data Analysis</a>
600 </p>
601<p>
602 <a href="http://mathworld.wolfram.com/BetaDistribution.html" target="_top">Wolfram
603 MathWorld</a>
604 </p>
605</div>
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 &#169; 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&#229;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>)
614 </p>
615</div></td>
616</tr></table>
617<hr>
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>
620</div>
621</body>
622</html>