Imported Upstream version 1.51.0
[platform/upstream/boost.git] / libs / math / doc / sf_and_dist / html / math_toolkit / dist / dist_ref / dists / beta_dist.html
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="../../../../../../../../../doc/src/boostbook.css" type="text/css">
6 <meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
7 <link rel="home" href="../../../../index.html" title="Math Toolkit">
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 math_toolkit_dist_dist_ref_dists_beta_dist">
26 <div class="titlepage"><div><div><h5 class="title">
27 <a name="math_toolkit.dist.dist_ref.dists.beta_dist"></a><a class="link" href="beta_dist.html" title="Beta Distribution">Beta
28           Distribution</a>
29 </h5></div></div></div>
30 <p>
31 </p>
32 <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>
33 <p>
34           </p>
35 <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>
36
37  <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>
38            <span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Policies">Policy</a>   <span class="special">=</span> <a class="link" href="../../../policy/pol_ref/pol_ref_ref.html" title="Policy Class Reference">policies::policy&lt;&gt;</a> <span class="special">&gt;</span>
39 <span class="keyword">class</span> <span class="identifier">beta_distribution</span><span class="special">;</span>
40
41 <span class="comment">// typedef beta_distribution&lt;double&gt; beta;</span>
42 <span class="comment">// Note that this is deliberately NOT provided,</span>
43 <span class="comment">// to avoid a clash with the function name beta.</span>
44
45 <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="Policies">Policy</a><span class="special">&gt;</span>
46 <span class="keyword">class</span> <span class="identifier">beta_distribution</span>
47 <span class="special">{</span>
48 <span class="keyword">public</span><span class="special">:</span>
49    <span class="keyword">typedef</span> <span class="identifier">RealType</span>  <span class="identifier">value_type</span><span class="special">;</span>
50    <span class="keyword">typedef</span> <span class="identifier">Policy</span>    <span class="identifier">policy_type</span><span class="special">;</span>
51    <span class="comment">// Constructor from two shape parameters, alpha &amp; beta:</span>
52    <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>
53
54    <span class="comment">// Parameter accessors:</span>
55    <span class="identifier">RealType</span> <span class="identifier">alpha</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
56    <span class="identifier">RealType</span> <span class="identifier">beta</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
57
58    <span class="comment">// Parameter estimators of alpha or beta from mean and variance.</span>
59    <span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_alpha</span><span class="special">(</span>
60      <span class="identifier">RealType</span> <span class="identifier">mean</span><span class="special">,</span> <span class="comment">// Expected value of mean.</span>
61      <span class="identifier">RealType</span> <span class="identifier">variance</span><span class="special">);</span> <span class="comment">// Expected value of variance.</span>
62
63    <span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_beta</span><span class="special">(</span>
64      <span class="identifier">RealType</span> <span class="identifier">mean</span><span class="special">,</span> <span class="comment">// Expected value of mean.</span>
65      <span class="identifier">RealType</span> <span class="identifier">variance</span><span class="special">);</span> <span class="comment">// Expected value of variance.</span>
66
67    <span class="comment">// Parameter estimators from from</span>
68    <span class="comment">// either alpha or beta, and x and probability.</span>
69
70    <span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_alpha</span><span class="special">(</span>
71      <span class="identifier">RealType</span> <span class="identifier">beta</span><span class="special">,</span> <span class="comment">// from beta.</span>
72      <span class="identifier">RealType</span> <span class="identifier">x</span><span class="special">,</span> <span class="comment">//  x.</span>
73      <span class="identifier">RealType</span> <span class="identifier">probability</span><span class="special">);</span> <span class="comment">// cdf</span>
74
75    <span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_beta</span><span class="special">(</span>
76      <span class="identifier">RealType</span> <span class="identifier">alpha</span><span class="special">,</span> <span class="comment">// alpha.</span>
77      <span class="identifier">RealType</span> <span class="identifier">x</span><span class="special">,</span> <span class="comment">// probability x.</span>
78      <span class="identifier">RealType</span> <span class="identifier">probability</span><span class="special">);</span> <span class="comment">// probability cdf.</span>
79 <span class="special">};</span>
80
81 <span class="special">}}</span> <span class="comment">// namespaces</span>
82 </pre>
83 <p>
84             The class type <code class="computeroutput"><span class="identifier">beta_distribution</span></code>
85             represents a <a href="http://en.wikipedia.org/wiki/Beta_distribution" target="_top">beta
86             </a> <a href="http://en.wikipedia.org/wiki/Probability_distribution" target="_top">probability
87             distribution function</a>.
88           </p>
89 <p>
90             The <a href="http://mathworld.wolfram.com/BetaDistribution.htm" target="_top">beta
91             distribution </a> is used as a <a href="http://en.wikipedia.org/wiki/Prior_distribution" target="_top">prior
92             distribution</a> for binomial proportions in <a href="http://mathworld.wolfram.com/BayesianAnalysis.html" target="_top">Bayesian
93             analysis</a>.
94           </p>
95 <p>
96             See also: <a href="http://documents.wolfram.com/calculationcenter/v2/Functions/ListsMatrices/Statistics/BetaDistribution.html" target="_top">beta
97             distribution</a> and <a href="http://en.wikipedia.org/wiki/Bayesian_statistics" target="_top">Bayesian
98             statistics</a>.
99           </p>
100 <p>
101             How the beta distribution is used for <a href="http://home.uchicago.edu/~grynav/bayes/ABSLec5.ppt" target="_top">Bayesian
102             analysis of one parameter models</a> is discussed by Jeff Grynaviski.
103           </p>
104 <p>
105             The <a href="http://en.wikipedia.org/wiki/Probability_density_function" target="_top">probability
106             density function PDF</a> for the <a href="http://en.wikipedia.org/wiki/Beta_distribution" target="_top">beta
107             distribution</a> defined on the interval [0,1] is given by:
108           </p>
109 <p>
110             f(x;&#945;,&#946;) = x<sup>&#945; - 1</sup> (1 - x)<sup>&#946; -1</sup> / B(&#945;, &#946;)
111           </p>
112 <p>
113             where B(&#945;, &#946;) is the <a href="http://en.wikipedia.org/wiki/Beta_function" target="_top">beta
114             function</a>, implemented in this library as <a class="link" href="../../../special/sf_beta/beta_function.html" title="Beta">beta</a>.
115             Division by the beta function ensures that the pdf is normalized to the
116             range zero to unity.
117           </p>
118 <p>
119             The following graph illustrates examples of the pdf for various values
120             of the shape parameters. Note the &#945; = &#946; = 2 (blue line) is dome-shaped, and
121             might be approximated by a symmetrical triangular distribution.
122           </p>
123 <p>
124             <span class="inlinemediaobject"><img src="../../../../../graphs/beta_pdf.png" align="middle"></span>
125           </p>
126 <p>
127             If &#945; = &#946; = 1, then it is a __space <a href="http://en.wikipedia.org/wiki/Uniform_distribution_%28continuous%29" target="_top">uniform
128             distribution</a>, equal to unity in the entire interval x = 0 to
129             1. If &#945; __space and &#946; __space are &lt; 1, then the pdf is U-shaped. If &#945; !=
130             &#946;, then the shape is asymmetric and could be approximated by a triangle
131             whose apex is away from the centre (where x = half).
132           </p>
133 <h5>
134 <a name="math_toolkit.dist.dist_ref.dists.beta_dist.h0"></a>
135             <span><a name="math_toolkit.dist.dist_ref.dists.beta_dist.member_functions"></a></span><a class="link" href="beta_dist.html#math_toolkit.dist.dist_ref.dists.beta_dist.member_functions">Member
136             Functions</a>
137           </h5>
138 <h6>
139 <a name="math_toolkit.dist.dist_ref.dists.beta_dist.h1"></a>
140             <span><a name="math_toolkit.dist.dist_ref.dists.beta_dist.constructor"></a></span><a class="link" href="beta_dist.html#math_toolkit.dist.dist_ref.dists.beta_dist.constructor">Constructor</a>
141           </h6>
142 <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>
143 </pre>
144 <p>
145             Constructs a beta distribution with shape parameters <span class="emphasis"><em>alpha</em></span>
146             and <span class="emphasis"><em>beta</em></span>.
147           </p>
148 <p>
149             Requires alpha,beta &gt; 0,otherwise <a class="link" href="../../../main_overview/error_handling.html#domain_error">domain_error</a>
150             is called. Note that technically the beta distribution is defined for
151             alpha,beta &gt;= 0, but it's not clear whether any program can actually
152             make use of that latitude or how many of the non-member functions can
153             be usefully defined in that case. Therefore for now, we regard it as
154             an error if alpha or beta is zero.
155           </p>
156 <p>
157             For example:
158           </p>
159 <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>
160 </pre>
161 <p>
162             Constructs a the beta distribution with alpha=2 and beta=5 (shown in
163             yellow in the graph above).
164           </p>
165 <h6>
166 <a name="math_toolkit.dist.dist_ref.dists.beta_dist.h2"></a>
167             <span><a name="math_toolkit.dist.dist_ref.dists.beta_dist.parameter_accessors"></a></span><a class="link" href="beta_dist.html#math_toolkit.dist.dist_ref.dists.beta_dist.parameter_accessors">Parameter
168             Accessors</a>
169           </h6>
170 <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>
171 </pre>
172 <p>
173             Returns the parameter <span class="emphasis"><em>alpha</em></span> from which this distribution
174             was constructed.
175           </p>
176 <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>
177 </pre>
178 <p>
179             Returns the parameter <span class="emphasis"><em>beta</em></span> from which this distribution
180             was constructed.
181           </p>
182 <p>
183             So for example:
184           </p>
185 <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>
186 <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>
187 <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>
188 </pre>
189 <h5>
190 <a name="math_toolkit.dist.dist_ref.dists.beta_dist.h3"></a>
191             <span><a name="math_toolkit.dist.dist_ref.dists.beta_dist.parameter_estimators"></a></span><a class="link" href="beta_dist.html#math_toolkit.dist.dist_ref.dists.beta_dist.parameter_estimators">Parameter
192             Estimators</a>
193           </h5>
194 <p>
195             Two pairs of parameter estimators are provided.
196           </p>
197 <p>
198             One estimates either &#945; __space or &#946; __space from presumed-known mean and
199             variance.
200           </p>
201 <p>
202             The other pair estimates either &#945; __space or &#946; __space from the cdf and x.
203           </p>
204 <p>
205             It is also possible to estimate &#945; __space and &#946; __space from 'known' mode
206             &amp; quantile. For example, calculators are provided by the <a href="http://www.ausvet.com.au/pprev/content.php?page=PPscript" target="_top">Pooled
207             Prevalence Calculator</a> and <a href="http://www.epi.ucdavis.edu/diagnostictests/betabuster.html" target="_top">Beta
208             Buster</a> but this is not yet implemented here.
209           </p>
210 <pre class="programlisting"><span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_alpha</span><span class="special">(</span>
211   <span class="identifier">RealType</span> <span class="identifier">mean</span><span class="special">,</span> <span class="comment">// Expected value of mean.</span>
212   <span class="identifier">RealType</span> <span class="identifier">variance</span><span class="special">);</span> <span class="comment">// Expected value of variance.</span>
213 </pre>
214 <p>
215             Returns the unique value of &#945; &#160; that corresponds to a beta distribution with
216             mean <span class="emphasis"><em>mean</em></span> and variance <span class="emphasis"><em>variance</em></span>.
217           </p>
218 <pre class="programlisting"><span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_beta</span><span class="special">(</span>
219   <span class="identifier">RealType</span> <span class="identifier">mean</span><span class="special">,</span> <span class="comment">// Expected value of mean.</span>
220   <span class="identifier">RealType</span> <span class="identifier">variance</span><span class="special">);</span> <span class="comment">// Expected value of variance.</span>
221 </pre>
222 <p>
223             Returns the unique value of &#946; &#160; that corresponds to a beta distribution with
224             mean <span class="emphasis"><em>mean</em></span> and variance <span class="emphasis"><em>variance</em></span>.
225           </p>
226 <pre class="programlisting"><span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_alpha</span><span class="special">(</span>
227   <span class="identifier">RealType</span> <span class="identifier">beta</span><span class="special">,</span> <span class="comment">// from beta.</span>
228   <span class="identifier">RealType</span> <span class="identifier">x</span><span class="special">,</span> <span class="comment">//  x.</span>
229   <span class="identifier">RealType</span> <span class="identifier">probability</span><span class="special">);</span> <span class="comment">// probability cdf</span>
230 </pre>
231 <p>
232             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>.
233           </p>
234 <pre class="programlisting"><span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_beta</span><span class="special">(</span>
235   <span class="identifier">RealType</span> <span class="identifier">alpha</span><span class="special">,</span> <span class="comment">// alpha.</span>
236   <span class="identifier">RealType</span> <span class="identifier">x</span><span class="special">,</span> <span class="comment">// probability x.</span>
237   <span class="identifier">RealType</span> <span class="identifier">probability</span><span class="special">);</span> <span class="comment">// probability cdf.</span>
238 </pre>
239 <p>
240             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>.
241           </p>
242 <h5>
243 <a name="math_toolkit.dist.dist_ref.dists.beta_dist.h4"></a>
244             <span><a name="math_toolkit.dist.dist_ref.dists.beta_dist.non_member_accessor_functions"></a></span><a class="link" href="beta_dist.html#math_toolkit.dist.dist_ref.dists.beta_dist.non_member_accessor_functions">Non-member
245             Accessor Functions</a>
246           </h5>
247 <p>
248             All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member
249             accessor functions</a> that are generic to all distributions are supported:
250             <a class="link" href="../nmp.html#math.dist.cdf">Cumulative Distribution Function</a>,
251             <a class="link" href="../nmp.html#math.dist.pdf">Probability Density Function</a>, <a class="link" href="../nmp.html#math.dist.quantile">Quantile</a>, <a class="link" href="../nmp.html#math.dist.hazard">Hazard
252             Function</a>, <a class="link" href="../nmp.html#math.dist.chf">Cumulative Hazard Function</a>,
253             <a class="link" href="../nmp.html#math.dist.mean">mean</a>, <a class="link" href="../nmp.html#math.dist.median">median</a>,
254             <a class="link" href="../nmp.html#math.dist.mode">mode</a>, <a class="link" href="../nmp.html#math.dist.variance">variance</a>,
255             <a class="link" href="../nmp.html#math.dist.sd">standard deviation</a>, <a class="link" href="../nmp.html#math.dist.skewness">skewness</a>,
256             <a class="link" href="../nmp.html#math.dist.kurtosis">kurtosis</a>, <a class="link" href="../nmp.html#math.dist.kurtosis_excess">kurtosis_excess</a>,
257             <a class="link" href="../nmp.html#math.dist.range">range</a> and <a class="link" href="../nmp.html#math.dist.support">support</a>.
258           </p>
259 <p>
260             The formulae for calculating these are shown in the table below, and
261             at <a href="http://mathworld.wolfram.com/BetaDistribution.html" target="_top">Wolfram
262             Mathworld</a>.
263           </p>
264 <h5>
265 <a name="math_toolkit.dist.dist_ref.dists.beta_dist.h5"></a>
266             <span><a name="math_toolkit.dist.dist_ref.dists.beta_dist.applications"></a></span><a class="link" href="beta_dist.html#math_toolkit.dist.dist_ref.dists.beta_dist.applications">Applications</a>
267           </h5>
268 <p>
269             The beta distribution can be used to model events constrained to take
270             place within an interval defined by a minimum and maximum value: so it
271             is used in project management systems.
272           </p>
273 <p>
274             It is also widely used in <a href="http://en.wikipedia.org/wiki/Bayesian_inference" target="_top">Bayesian
275             statistical inference</a>.
276           </p>
277 <h5>
278 <a name="math_toolkit.dist.dist_ref.dists.beta_dist.h6"></a>
279             <span><a name="math_toolkit.dist.dist_ref.dists.beta_dist.related_distributions"></a></span><a class="link" href="beta_dist.html#math_toolkit.dist.dist_ref.dists.beta_dist.related_distributions">Related
280             distributions</a>
281           </h5>
282 <p>
283             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
284             distribution</a>.
285           </p>
286 <p>
287             The <a href="http://en.wikipedia.org/wiki/Triangular_distribution" target="_top">triangular</a>
288             is used when less precise information is available.
289           </p>
290 <p>
291             The <a href="http://en.wikipedia.org/wiki/Binomial_distribution" target="_top">binomial
292             distribution</a> is closely related when &#945;  __space and &#946;  __space are
293             integers.
294           </p>
295 <p>
296             With integer values of &#945;  __space and &#946;  __space the distribution B(i, j) is
297             that of the j-th highest of a sample of i + j + 1 independent random
298             variables uniformly distributed between 0 and 1. The cumulative probability
299             from 0 to x is thus the probability that the j-th highest value is less
300             than x. Or it is the probability that that at least i of the random variables
301             are less than x, a probability given by summing over the <a class="link" href="binomial_dist.html" title="Binomial Distribution">Binomial
302             Distribution</a> with its p parameter set to x.
303           </p>
304 <h5>
305 <a name="math_toolkit.dist.dist_ref.dists.beta_dist.h7"></a>
306             <span><a name="math_toolkit.dist.dist_ref.dists.beta_dist.accuracy"></a></span><a class="link" href="beta_dist.html#math_toolkit.dist.dist_ref.dists.beta_dist.accuracy">Accuracy</a>
307           </h5>
308 <p>
309             This distribution is implemented using the <a class="link" href="../../../special/sf_beta/beta_function.html" title="Beta">beta
310             functions</a> <a class="link" href="../../../special/sf_beta/beta_function.html" title="Beta">beta</a>
311             and <a class="link" href="../../../special/sf_beta/ibeta_function.html" title="Incomplete Beta Functions">incomplete
312             beta functions</a> <a class="link" href="../../../special/sf_beta/ibeta_function.html" title="Incomplete Beta Functions">ibeta</a>
313             and <a class="link" href="../../../special/sf_beta/ibeta_function.html" title="Incomplete Beta Functions">ibetac</a>;
314             please refer to these functions for information on accuracy.
315           </p>
316 <h5>
317 <a name="math_toolkit.dist.dist_ref.dists.beta_dist.h8"></a>
318             <span><a name="math_toolkit.dist.dist_ref.dists.beta_dist.implementation"></a></span><a class="link" href="beta_dist.html#math_toolkit.dist.dist_ref.dists.beta_dist.implementation">Implementation</a>
319           </h5>
320 <p>
321             In the following table <span class="emphasis"><em>a</em></span> and <span class="emphasis"><em>b</em></span>
322             are the parameters &#945; &#160; and &#946;, <span class="emphasis"><em>x</em></span> is the random variable,
323             <span class="emphasis"><em>p</em></span> is the probability and <span class="emphasis"><em>q = 1-p</em></span>.
324           </p>
325 <div class="informaltable"><table class="table">
326 <colgroup>
327 <col>
328 <col>
329 </colgroup>
330 <thead><tr>
331 <th>
332                     <p>
333                       Function
334                     </p>
335                   </th>
336 <th>
337                     <p>
338                       Implementation Notes
339                     </p>
340                   </th>
341 </tr></thead>
342 <tbody>
343 <tr>
344 <td>
345                     <p>
346                       pdf
347                     </p>
348                   </td>
349 <td>
350                     <p>
351                       f(x;&#945;,&#946;) = x<sup>&#945; - 1</sup> (1 - x)<sup>&#946; -1</sup> / B(&#945;, &#946;)
352                     </p>
353                     <p>
354                       Implemented using <a class="link" href="../../../special/sf_beta/beta_derivative.html" title="Derivative of the Incomplete Beta Function">ibeta_derivative</a>(a,
355                       b, x).
356                     </p>
357                   </td>
358 </tr>
359 <tr>
360 <td>
361                     <p>
362                       cdf
363                     </p>
364                   </td>
365 <td>
366                     <p>
367                       Using the incomplete beta function <a class="link" href="../../../special/sf_beta/ibeta_function.html" title="Incomplete Beta Functions">ibeta</a>(a,
368                       b, x)
369                     </p>
370                   </td>
371 </tr>
372 <tr>
373 <td>
374                     <p>
375                       cdf complement
376                     </p>
377                   </td>
378 <td>
379                     <p>
380                       <a class="link" href="../../../special/sf_beta/ibeta_function.html" title="Incomplete Beta Functions">ibetac</a>(a,
381                       b, x)
382                     </p>
383                   </td>
384 </tr>
385 <tr>
386 <td>
387                     <p>
388                       quantile
389                     </p>
390                   </td>
391 <td>
392                     <p>
393                       Using the inverse incomplete beta function <a class="link" href="../../../special/sf_beta/ibeta_inv_function.html" title="The Incomplete Beta Function Inverses">ibeta_inv</a>(a,
394                       b, p)
395                     </p>
396                   </td>
397 </tr>
398 <tr>
399 <td>
400                     <p>
401                       quantile from the complement
402                     </p>
403                   </td>
404 <td>
405                     <p>
406                       <a class="link" href="../../../special/sf_beta/ibeta_inv_function.html" title="The Incomplete Beta Function Inverses">ibetac_inv</a>(a,
407                       b, q)
408                     </p>
409                   </td>
410 </tr>
411 <tr>
412 <td>
413                     <p>
414                       mean
415                     </p>
416                   </td>
417 <td>
418                     <p>
419                       <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>
420                     </p>
421                   </td>
422 </tr>
423 <tr>
424 <td>
425                     <p>
426                       variance
427                     </p>
428                   </td>
429 <td>
430                     <p>
431                       <code class="computeroutput"><span class="identifier">a</span> <span class="special">*</span>
432                       <span class="identifier">b</span> <span class="special">/</span>
433                       <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>
434                       <span class="special">*</span> <span class="special">(</span><span class="identifier">a</span> <span class="special">+</span>
435                       <span class="identifier">b</span> <span class="special">+</span>
436                       <span class="number">1</span><span class="special">)</span></code>
437                     </p>
438                   </td>
439 </tr>
440 <tr>
441 <td>
442                     <p>
443                       mode
444                     </p>
445                   </td>
446 <td>
447                     <p>
448                       <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>
449                       <span class="special">(</span><span class="identifier">a</span>
450                       <span class="special">+</span> <span class="identifier">b</span>
451                       <span class="special">-</span> <span class="number">2</span><span class="special">)</span></code>
452                     </p>
453                   </td>
454 </tr>
455 <tr>
456 <td>
457                     <p>
458                       skewness
459                     </p>
460                   </td>
461 <td>
462                     <p>
463                       <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>
464                       <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>
465                       <span class="special">*</span> <span class="identifier">sqrt</span><span class="special">(</span><span class="identifier">a</span>
466                       <span class="special">*</span> <span class="identifier">b</span><span class="special">)</span></code>
467                     </p>
468                   </td>
469 </tr>
470 <tr>
471 <td>
472                     <p>
473                       kurtosis excess
474                     </p>
475                   </td>
476 <td>
477                     <p>
478                       <span class="inlinemediaobject"><img src="../../../../../equations/beta_dist_kurtosis.png"></span>
479                     </p>
480                   </td>
481 </tr>
482 <tr>
483 <td>
484                     <p>
485                       kurtosis
486                     </p>
487                   </td>
488 <td>
489                     <p>
490                       <code class="computeroutput"><span class="identifier">kurtosis</span> <span class="special">+</span>
491                       <span class="number">3</span></code>
492                     </p>
493                   </td>
494 </tr>
495 <tr>
496 <td>
497                     <p>
498                       parameter estimation
499                     </p>
500                   </td>
501 <td>
502                   </td>
503 </tr>
504 <tr>
505 <td>
506                     <p>
507                       alpha
508                     </p>
509                     <p>
510                       from mean and variance
511                     </p>
512                   </td>
513 <td>
514                     <p>
515                       <code class="computeroutput"><span class="identifier">mean</span> <span class="special">*</span>
516                       <span class="special">((</span> <span class="special">(</span><span class="identifier">mean</span> <span class="special">*</span>
517                       <span class="special">(</span><span class="number">1</span>
518                       <span class="special">-</span> <span class="identifier">mean</span><span class="special">))</span> <span class="special">/</span>
519                       <span class="identifier">variance</span><span class="special">)-</span>
520                       <span class="number">1</span><span class="special">)</span></code>
521                     </p>
522                   </td>
523 </tr>
524 <tr>
525 <td>
526                     <p>
527                       beta
528                     </p>
529                     <p>
530                       from mean and variance
531                     </p>
532                   </td>
533 <td>
534                     <p>
535                       <code class="computeroutput"><span class="special">(</span><span class="number">1</span>
536                       <span class="special">-</span> <span class="identifier">mean</span><span class="special">)</span> <span class="special">*</span>
537                       <span class="special">(((</span><span class="identifier">mean</span>
538                       <span class="special">*</span> <span class="special">(</span><span class="number">1</span> <span class="special">-</span>
539                       <span class="identifier">mean</span><span class="special">))</span>
540                       <span class="special">/</span><span class="identifier">variance</span><span class="special">)-</span><span class="number">1</span><span class="special">)</span></code>
541                     </p>
542                   </td>
543 </tr>
544 <tr>
545 <td>
546                     <p>
547                       The member functions <code class="computeroutput"><span class="identifier">find_alpha</span></code>
548                       and <code class="computeroutput"><span class="identifier">find_beta</span></code>
549                     </p>
550                     <p>
551                       from cdf and probability x
552                     </p>
553                     <p>
554                       and <span class="bold"><strong>either</strong></span> <code class="computeroutput"><span class="identifier">alpha</span></code>
555                       or <code class="computeroutput"><span class="identifier">beta</span></code>
556                     </p>
557                   </td>
558 <td>
559                     <p>
560                       Implemented in terms of the inverse incomplete beta functions
561                     </p>
562                     <p>
563                       <a class="link" href="../../../special/sf_beta/ibeta_inv_function.html" title="The Incomplete Beta Function Inverses">ibeta_inva</a>,
564                       and <a class="link" href="../../../special/sf_beta/ibeta_inv_function.html" title="The Incomplete Beta Function Inverses">ibeta_invb</a>
565                       respectively.
566                     </p>
567                   </td>
568 </tr>
569 <tr>
570 <td>
571                     <p>
572                       <code class="computeroutput"><span class="identifier">find_alpha</span></code>
573                     </p>
574                   </td>
575 <td>
576                     <p>
577                       <code class="computeroutput"><span class="identifier">ibeta_inva</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="identifier">probability</span><span class="special">)</span></code>
578                     </p>
579                   </td>
580 </tr>
581 <tr>
582 <td>
583                     <p>
584                       <code class="computeroutput"><span class="identifier">find_beta</span></code>
585                     </p>
586                   </td>
587 <td>
588                     <p>
589                       <code class="computeroutput"><span class="identifier">ibeta_invb</span><span class="special">(</span><span class="identifier">alpha</span><span class="special">,</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">probability</span><span class="special">)</span></code>
590                     </p>
591                   </td>
592 </tr>
593 </tbody>
594 </table></div>
595 <h5>
596 <a name="math_toolkit.dist.dist_ref.dists.beta_dist.h9"></a>
597             <span><a name="math_toolkit.dist.dist_ref.dists.beta_dist.references"></a></span><a class="link" href="beta_dist.html#math_toolkit.dist.dist_ref.dists.beta_dist.references">References</a>
598           </h5>
599 <p>
600             <a href="http://en.wikipedia.org/wiki/Beta_distribution" target="_top">Wikipedia
601             Beta distribution</a>
602           </p>
603 <p>
604             <a href="http://www.itl.nist.gov/div898/handbook/eda/section3/eda366h.htm" target="_top">NIST
605             Exploratory Data Analysis</a>
606           </p>
607 <p>
608             <a href="http://mathworld.wolfram.com/BetaDistribution.html" target="_top">Wolfram
609             MathWorld</a>
610           </p>
611 </div>
612 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
613 <td align="left"></td>
614 <td align="right"><div class="copyright-footer">Copyright &#169; 2006-2010 John Maddock, Paul A. Bristow, Hubert Holin, Xiaogang Zhang, Bruno
615       Lalande, Johan R&#229;de, Gautam Sewani, Thijs van den Berg and Benjamin Sobotta<p>
616         Distributed under the Boost Software License, Version 1.0. (See accompanying
617         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       </p>
619 </div></td>
620 </tr></table>
621 <hr>
622 <div class="spirit-nav">
623 <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>
624 </div>
625 </body>
626 </html>