• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>Incomplete Beta Functions</title>
5<link rel="stylesheet" href="../../math.css" type="text/css">
6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7<link rel="home" href="../../index.html" title="Math Toolkit 2.12.0">
8<link rel="up" href="../sf_beta.html" title="Beta Functions">
9<link rel="prev" href="beta_function.html" title="Beta">
10<link rel="next" href="ibeta_inv_function.html" title="The Incomplete Beta Function Inverses">
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="beta_function.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../sf_beta.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="ibeta_inv_function.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="section">
26<div class="titlepage"><div><div><h3 class="title">
27<a name="math_toolkit.sf_beta.ibeta_function"></a><a class="link" href="ibeta_function.html" title="Incomplete Beta Functions">Incomplete Beta
28      Functions</a>
29</h3></div></div></div>
30<h5>
31<a name="math_toolkit.sf_beta.ibeta_function.h0"></a>
32        <span class="phrase"><a name="math_toolkit.sf_beta.ibeta_function.synopsis"></a></span><a class="link" href="ibeta_function.html#math_toolkit.sf_beta.ibeta_function.synopsis">Synopsis</a>
33      </h5>
34<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">special_functions</span><span class="special">/</span><span class="identifier">beta</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
35</pre>
36<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>
37
38<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T3</span><span class="special">&gt;</span>
39<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">ibeta</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">b</span><span class="special">,</span> <span class="identifier">T3</span> <span class="identifier">x</span><span class="special">);</span>
40
41<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T3</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
42<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">ibeta</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">b</span><span class="special">,</span> <span class="identifier">T3</span> <span class="identifier">x</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
43
44<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T3</span><span class="special">&gt;</span>
45<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">ibetac</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">b</span><span class="special">,</span> <span class="identifier">T3</span> <span class="identifier">x</span><span class="special">);</span>
46
47<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T3</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
48<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">ibetac</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">b</span><span class="special">,</span> <span class="identifier">T3</span> <span class="identifier">x</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
49
50<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T3</span><span class="special">&gt;</span>
51<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">beta</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">b</span><span class="special">,</span> <span class="identifier">T3</span> <span class="identifier">x</span><span class="special">);</span>
52
53<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T3</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
54<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">beta</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">b</span><span class="special">,</span> <span class="identifier">T3</span> <span class="identifier">x</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
55
56<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T3</span><span class="special">&gt;</span>
57<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">betac</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">b</span><span class="special">,</span> <span class="identifier">T3</span> <span class="identifier">x</span><span class="special">);</span>
58
59<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T3</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
60<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">betac</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">b</span><span class="special">,</span> <span class="identifier">T3</span> <span class="identifier">x</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
61
62<span class="special">}}</span> <span class="comment">// namespaces</span>
63</pre>
64<h5>
65<a name="math_toolkit.sf_beta.ibeta_function.h1"></a>
66        <span class="phrase"><a name="math_toolkit.sf_beta.ibeta_function.description"></a></span><a class="link" href="ibeta_function.html#math_toolkit.sf_beta.ibeta_function.description">Description</a>
67      </h5>
68<p>
69        There are four <a href="http://en.wikipedia.org/wiki/Incomplete_beta_function" target="_top">incomplete
70        beta functions</a> : two are normalised versions (also known as <span class="emphasis"><em>regularized</em></span>
71        beta functions) that return values in the range [0, 1], and two are non-normalised
72        and return values in the range [0, <a class="link" href="beta_function.html" title="Beta">beta</a>(a,
73        b)]. Users interested in statistical applications should use the normalised
74        (or <a href="http://mathworld.wolfram.com/RegularizedBetaFunction.html" target="_top">regularized</a>
75        ) versions (ibeta and ibetac).
76      </p>
77<p>
78        All of these functions require <span class="emphasis"><em>0 &lt;= x &lt;= 1</em></span>.
79      </p>
80<p>
81        The normalized functions <a class="link" href="ibeta_function.html" title="Incomplete Beta Functions">ibeta</a>
82        and <a class="link" href="ibeta_function.html" title="Incomplete Beta Functions">ibetac</a> require
83        <span class="emphasis"><em>a,b &gt;= 0</em></span>, and in addition that not both <span class="emphasis"><em>a</em></span>
84        and <span class="emphasis"><em>b</em></span> are zero.
85      </p>
86<p>
87        The functions <a class="link" href="beta_function.html" title="Beta">beta</a>
88        and <a class="link" href="ibeta_function.html" title="Incomplete Beta Functions">betac</a> require
89        <span class="emphasis"><em>a,b &gt; 0</em></span>.
90      </p>
91<p>
92        The return type of these functions is computed using the <a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>result
93        type calculation rules</em></span></a> when T1, T2 and T3 are different
94        types.
95      </p>
96<p>
97        The final <a class="link" href="../../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">Policy</a> argument is optional and can
98        be used to control the behaviour of the function: how it handles errors,
99        what level of precision to use etc. Refer to the <a class="link" href="../../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">policy
100        documentation for more details</a>.
101      </p>
102<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T3</span><span class="special">&gt;</span>
103<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">ibeta</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">b</span><span class="special">,</span> <span class="identifier">T3</span> <span class="identifier">x</span><span class="special">);</span>
104
105<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T3</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
106<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">ibeta</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">b</span><span class="special">,</span> <span class="identifier">T3</span> <span class="identifier">x</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
107</pre>
108<p>
109        Returns the normalised incomplete beta function of a, b and x:
110      </p>
111<div class="blockquote"><blockquote class="blockquote"><p>
112          <span class="inlinemediaobject"><img src="../../../equations/ibeta3.svg"></span>
113
114        </p></blockquote></div>
115<div class="blockquote"><blockquote class="blockquote"><p>
116          <span class="inlinemediaobject"><img src="../../../graphs/ibeta.svg" align="middle"></span>
117
118        </p></blockquote></div>
119<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T3</span><span class="special">&gt;</span>
120<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">ibetac</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">b</span><span class="special">,</span> <span class="identifier">T3</span> <span class="identifier">x</span><span class="special">);</span>
121
122<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T3</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
123<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">ibetac</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">b</span><span class="special">,</span> <span class="identifier">T3</span> <span class="identifier">x</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
124</pre>
125<p>
126        Returns the normalised complement of the incomplete beta function of a, b
127        and x:
128      </p>
129<div class="blockquote"><blockquote class="blockquote"><p>
130          <span class="inlinemediaobject"><img src="../../../equations/ibeta4.svg"></span>
131
132        </p></blockquote></div>
133<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T3</span><span class="special">&gt;</span>
134<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">beta</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">b</span><span class="special">,</span> <span class="identifier">T3</span> <span class="identifier">x</span><span class="special">);</span>
135
136<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T3</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
137<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">beta</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">b</span><span class="special">,</span> <span class="identifier">T3</span> <span class="identifier">x</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
138</pre>
139<p>
140        Returns the full (non-normalised) incomplete beta function of a, b and x:
141      </p>
142<div class="blockquote"><blockquote class="blockquote"><p>
143          <span class="inlinemediaobject"><img src="../../../equations/ibeta1.svg"></span>
144
145        </p></blockquote></div>
146<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T3</span><span class="special">&gt;</span>
147<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">betac</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">b</span><span class="special">,</span> <span class="identifier">T3</span> <span class="identifier">x</span><span class="special">);</span>
148
149<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T3</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
150<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">betac</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">b</span><span class="special">,</span> <span class="identifier">T3</span> <span class="identifier">x</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
151</pre>
152<p>
153        Returns the full (non-normalised) complement of the incomplete beta function
154        of a, b and x:
155      </p>
156<div class="blockquote"><blockquote class="blockquote"><p>
157          <span class="inlinemediaobject"><img src="../../../equations/ibeta2.svg"></span>
158
159        </p></blockquote></div>
160<h5>
161<a name="math_toolkit.sf_beta.ibeta_function.h2"></a>
162        <span class="phrase"><a name="math_toolkit.sf_beta.ibeta_function.accuracy"></a></span><a class="link" href="ibeta_function.html#math_toolkit.sf_beta.ibeta_function.accuracy">Accuracy</a>
163      </h5>
164<p>
165        The following tables give peak and mean relative errors in over various domains
166        of a, b and x, along with comparisons to the <a href="http://www.gnu.org/software/gsl/" target="_top">GSL-1.9</a>
167        and <a href="http://www.netlib.org/cephes/" target="_top">Cephes</a> libraries.
168        Note that only results for the widest floating-point type on the system are
169        given as narrower types have <a class="link" href="../relative_error.html#math_toolkit.relative_error.zero_error">effectively
170        zero error</a>.
171      </p>
172<p>
173        Note that the results for 80 and 128-bit long doubles are noticeably higher
174        than for doubles: this is because the wider exponent range of these types
175        allow more extreme test cases to be tested. For example expected results
176        that are zero at double precision, may be finite but exceptionally small
177        with the wider exponent range of the long double types.
178      </p>
179<div class="table">
180<a name="math_toolkit.sf_beta.ibeta_function.table_ibeta"></a><p class="title"><b>Table 8.18. Error rates for ibeta</b></p>
181<div class="table-contents"><table class="table" summary="Error rates for ibeta">
182<colgroup>
183<col>
184<col>
185<col>
186<col>
187<col>
188</colgroup>
189<thead><tr>
190<th>
191              </th>
192<th>
193                <p>
194                  GNU C++ version 7.1.0<br> linux<br> double
195                </p>
196              </th>
197<th>
198                <p>
199                  GNU C++ version 7.1.0<br> linux<br> long double
200                </p>
201              </th>
202<th>
203                <p>
204                  Sun compiler version 0x5150<br> Sun Solaris<br> long double
205                </p>
206              </th>
207<th>
208                <p>
209                  Microsoft Visual C++ version 14.1<br> Win32<br> double
210                </p>
211              </th>
212</tr></thead>
213<tbody>
214<tr>
215<td>
216                <p>
217                  Incomplete Beta Function: Small Values
218                </p>
219              </td>
220<td>
221                <p>
222                  <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>GSL
223                  2.1:</em></span> Max = 682ε (Mean = 32.6ε))<br> (<span class="emphasis"><em>Rmath
224                  3.2.3:</em></span> Max = 22.9ε (Mean = 3.35ε))
225                </p>
226              </td>
227<td>
228                <p>
229                  <span class="blue">Max = 8.97ε (Mean = 2.09ε)</span>
230                </p>
231              </td>
232<td>
233                <p>
234                  <span class="blue">Max = 21.3ε (Mean = 2.75ε)</span>
235                </p>
236              </td>
237<td>
238                <p>
239                  <span class="blue">Max = 8.4ε (Mean = 1.93ε)</span>
240                </p>
241              </td>
242</tr>
243<tr>
244<td>
245                <p>
246                  Incomplete Beta Function: Medium Values
247                </p>
248              </td>
249<td>
250                <p>
251                  <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>GSL
252                  2.1:</em></span> Max = 690ε (Mean = 151ε))<br> (<span class="emphasis"><em>Rmath 3.2.3:</em></span>
253                  Max = 232ε (Mean = 27.9ε))
254                </p>
255              </td>
256<td>
257                <p>
258                  <span class="blue">Max = 50ε (Mean = 12.1ε)</span>
259                </p>
260              </td>
261<td>
262                <p>
263                  <span class="blue">Max = 124ε (Mean = 18.4ε)</span>
264                </p>
265              </td>
266<td>
267                <p>
268                  <span class="blue">Max = 106ε (Mean = 16.3ε)</span>
269                </p>
270              </td>
271</tr>
272<tr>
273<td>
274                <p>
275                  Incomplete Beta Function: Large and Diverse Values
276                </p>
277              </td>
278<td>
279                <p>
280                  <span class="blue">Max = 1.26ε (Mean = 0.063ε)</span><br> <br>
281                  (<span class="emphasis"><em>GSL 2.1:</em></span> Max = 3.9e+05ε (Mean = 1.82e+04ε)
282                  <a class="link" href="../logs_and_tables/logs.html#errors_GNU_C_version_7_1_0_linux_double_ibeta_GSL_2_1_Incomplete_Beta_Function_Large_and_Diverse_Values">And
283                  other failures.</a>)<br> (<span class="emphasis"><em>Rmath 3.2.3:</em></span>
284                  Max = 574ε (Mean = 49.4ε))
285                </p>
286              </td>
287<td>
288                <p>
289                  <span class="blue">Max = 1.96e+04ε (Mean = 997ε)</span>
290                </p>
291              </td>
292<td>
293                <p>
294                  <span class="blue">Max = 4.98e+04ε (Mean = 2.07e+03ε)</span>
295                </p>
296              </td>
297<td>
298                <p>
299                  <span class="blue">Max = 1.32e+03ε (Mean = 68.5ε)</span>
300                </p>
301              </td>
302</tr>
303<tr>
304<td>
305                <p>
306                  Incomplete Beta Function: Small Integer Values
307                </p>
308              </td>
309<td>
310                <p>
311                  <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>GSL
312                  2.1:</em></span> Max = 254ε (Mean = 50.9ε))<br> (<span class="emphasis"><em>Rmath
313                  3.2.3:</em></span> Max = 62.2ε (Mean = 8.95ε))
314                </p>
315              </td>
316<td>
317                <p>
318                  <span class="blue">Max = 4.45ε (Mean = 0.814ε)</span>
319                </p>
320              </td>
321<td>
322                <p>
323                  <span class="blue">Max = 44.5ε (Mean = 10.1ε)</span>
324                </p>
325              </td>
326<td>
327                <p>
328                  <span class="blue">Max = 3.85ε (Mean = 0.791ε)</span>
329                </p>
330              </td>
331</tr>
332</tbody>
333</table></div>
334</div>
335<br class="table-break"><div class="table">
336<a name="math_toolkit.sf_beta.ibeta_function.table_ibetac"></a><p class="title"><b>Table 8.19. Error rates for ibetac</b></p>
337<div class="table-contents"><table class="table" summary="Error rates for ibetac">
338<colgroup>
339<col>
340<col>
341<col>
342<col>
343<col>
344</colgroup>
345<thead><tr>
346<th>
347              </th>
348<th>
349                <p>
350                  GNU C++ version 7.1.0<br> linux<br> double
351                </p>
352              </th>
353<th>
354                <p>
355                  GNU C++ version 7.1.0<br> linux<br> long double
356                </p>
357              </th>
358<th>
359                <p>
360                  Sun compiler version 0x5150<br> Sun Solaris<br> long double
361                </p>
362              </th>
363<th>
364                <p>
365                  Microsoft Visual C++ version 14.1<br> Win32<br> double
366                </p>
367              </th>
368</tr></thead>
369<tbody>
370<tr>
371<td>
372                <p>
373                  Incomplete Beta Function: Small Values
374                </p>
375              </td>
376<td>
377                <p>
378                  <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>Rmath
379                  3.2.3:</em></span> Max = 22.4ε (Mean = 3.67ε))
380                </p>
381              </td>
382<td>
383                <p>
384                  <span class="blue">Max = 10.6ε (Mean = 2.22ε)</span>
385                </p>
386              </td>
387<td>
388                <p>
389                  <span class="blue">Max = 13.8ε (Mean = 2.68ε)</span>
390                </p>
391              </td>
392<td>
393                <p>
394                  <span class="blue">Max = 6.94ε (Mean = 1.71ε)</span>
395                </p>
396              </td>
397</tr>
398<tr>
399<td>
400                <p>
401                  Incomplete Beta Function: Medium Values
402                </p>
403              </td>
404<td>
405                <p>
406                  <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>Rmath
407                  3.2.3:</em></span> Max = 204ε (Mean = 25.8ε))
408                </p>
409              </td>
410<td>
411                <p>
412                  <span class="blue">Max = 73.9ε (Mean = 11.2ε)</span>
413                </p>
414              </td>
415<td>
416                <p>
417                  <span class="blue">Max = 132ε (Mean = 19.8ε)</span>
418                </p>
419              </td>
420<td>
421                <p>
422                  <span class="blue">Max = 56.7ε (Mean = 14.3ε)</span>
423                </p>
424              </td>
425</tr>
426<tr>
427<td>
428                <p>
429                  Incomplete Beta Function: Large and Diverse Values
430                </p>
431              </td>
432<td>
433                <p>
434                  <span class="blue">Max = 0.981ε (Mean = 0.0573ε)</span><br>
435                  <br> (<span class="emphasis"><em>Rmath 3.2.3:</em></span> Max = 889ε (Mean = 68.4ε))
436                </p>
437              </td>
438<td>
439                <p>
440                  <span class="blue">Max = 3.45e+04ε (Mean = 1.32e+03ε)</span>
441                </p>
442              </td>
443<td>
444                <p>
445                  <span class="blue">Max = 6.31e+04ε (Mean = 2.04e+03ε)</span>
446                </p>
447              </td>
448<td>
449                <p>
450                  <span class="blue">Max = 1.88e+03ε (Mean = 82.7ε)</span>
451                </p>
452              </td>
453</tr>
454<tr>
455<td>
456                <p>
457                  Incomplete Beta Function: Small Integer Values
458                </p>
459              </td>
460<td>
461                <p>
462                  <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>Rmath
463                  3.2.3:</em></span> Max = 84.6ε (Mean = 18ε))
464                </p>
465              </td>
466<td>
467                <p>
468                  <span class="blue">Max = 5.34ε (Mean = 1.11ε)</span>
469                </p>
470              </td>
471<td>
472                <p>
473                  <span class="blue">Max = 107ε (Mean = 17.1ε)</span>
474                </p>
475              </td>
476<td>
477                <p>
478                  <span class="blue">Max = 6.37ε (Mean = 1.03ε)</span>
479                </p>
480              </td>
481</tr>
482</tbody>
483</table></div>
484</div>
485<br class="table-break"><div class="table">
486<a name="math_toolkit.sf_beta.ibeta_function.table_beta_incomplete_"></a><p class="title"><b>Table 8.20. Error rates for beta (incomplete)</b></p>
487<div class="table-contents"><table class="table" summary="Error rates for beta (incomplete)">
488<colgroup>
489<col>
490<col>
491<col>
492<col>
493<col>
494</colgroup>
495<thead><tr>
496<th>
497              </th>
498<th>
499                <p>
500                  GNU C++ version 7.1.0<br> linux<br> double
501                </p>
502              </th>
503<th>
504                <p>
505                  GNU C++ version 7.1.0<br> linux<br> long double
506                </p>
507              </th>
508<th>
509                <p>
510                  Sun compiler version 0x5150<br> Sun Solaris<br> long double
511                </p>
512              </th>
513<th>
514                <p>
515                  Microsoft Visual C++ version 14.1<br> Win32<br> double
516                </p>
517              </th>
518</tr></thead>
519<tbody>
520<tr>
521<td>
522                <p>
523                  Incomplete Beta Function: Small Values
524                </p>
525              </td>
526<td>
527                <p>
528                  <span class="blue">Max = 0ε (Mean = 0ε)</span>
529                </p>
530              </td>
531<td>
532                <p>
533                  <span class="blue">Max = 11.1ε (Mean = 2.32ε)</span>
534                </p>
535              </td>
536<td>
537                <p>
538                  <span class="blue">Max = 18.7ε (Mean = 3.19ε)</span>
539                </p>
540              </td>
541<td>
542                <p>
543                  <span class="blue">Max = 9.94ε (Mean = 2.17ε)</span>
544                </p>
545              </td>
546</tr>
547<tr>
548<td>
549                <p>
550                  Incomplete Beta Function: Medium Values
551                </p>
552              </td>
553<td>
554                <p>
555                  <span class="blue">Max = 0.568ε (Mean = 0.0254ε)</span>
556                </p>
557              </td>
558<td>
559                <p>
560                  <span class="blue">Max = 69.2ε (Mean = 13.4ε)</span>
561                </p>
562              </td>
563<td>
564                <p>
565                  <span class="blue">Max = 174ε (Mean = 25ε)</span>
566                </p>
567              </td>
568<td>
569                <p>
570                  <span class="blue">Max = 90ε (Mean = 12.7ε)</span>
571                </p>
572              </td>
573</tr>
574<tr>
575<td>
576                <p>
577                  Incomplete Beta Function: Large and Diverse Values
578                </p>
579              </td>
580<td>
581                <p>
582                  <span class="blue">Max = 0.999ε (Mean = 0.0325ε)</span>
583                </p>
584              </td>
585<td>
586                <p>
587                  <span class="blue">Max = 6.84e+04ε (Mean = 2.76e+03ε)</span>
588                </p>
589              </td>
590<td>
591                <p>
592                  <span class="blue">Max = 6.86e+04ε (Mean = 2.79e+03ε)</span>
593                </p>
594              </td>
595<td>
596                <p>
597                  <span class="blue">Max = 633ε (Mean = 29.7ε)</span>
598                </p>
599              </td>
600</tr>
601<tr>
602<td>
603                <p>
604                  Incomplete Beta Function: Small Integer Values
605                </p>
606              </td>
607<td>
608                <p>
609                  <span class="blue">Max = 0.786ε (Mean = 0.0323ε)</span>
610                </p>
611              </td>
612<td>
613                <p>
614                  <span class="blue">Max = 11.6ε (Mean = 3.6ε)</span>
615                </p>
616              </td>
617<td>
618                <p>
619                  <span class="blue">Max = 51.8ε (Mean = 11ε)</span>
620                </p>
621              </td>
622<td>
623                <p>
624                  <span class="blue">Max = 26ε (Mean = 6.28ε)</span>
625                </p>
626              </td>
627</tr>
628</tbody>
629</table></div>
630</div>
631<br class="table-break"><div class="table">
632<a name="math_toolkit.sf_beta.ibeta_function.table_betac"></a><p class="title"><b>Table 8.21. Error rates for betac</b></p>
633<div class="table-contents"><table class="table" summary="Error rates for betac">
634<colgroup>
635<col>
636<col>
637<col>
638<col>
639<col>
640</colgroup>
641<thead><tr>
642<th>
643              </th>
644<th>
645                <p>
646                  GNU C++ version 7.1.0<br> linux<br> double
647                </p>
648              </th>
649<th>
650                <p>
651                  GNU C++ version 7.1.0<br> linux<br> long double
652                </p>
653              </th>
654<th>
655                <p>
656                  Sun compiler version 0x5150<br> Sun Solaris<br> long double
657                </p>
658              </th>
659<th>
660                <p>
661                  Microsoft Visual C++ version 14.1<br> Win32<br> double
662                </p>
663              </th>
664</tr></thead>
665<tbody>
666<tr>
667<td>
668                <p>
669                  Incomplete Beta Function: Small Values
670                </p>
671              </td>
672<td>
673                <p>
674                  <span class="blue">Max = 0.676ε (Mean = 0.0302ε)</span>
675                </p>
676              </td>
677<td>
678                <p>
679                  <span class="blue">Max = 9.92ε (Mean = 2.3ε)</span>
680                </p>
681              </td>
682<td>
683                <p>
684                  <span class="blue">Max = 11.2ε (Mean = 2.94ε)</span>
685                </p>
686              </td>
687<td>
688                <p>
689                  <span class="blue">Max = 8.94ε (Mean = 2.06ε)</span>
690                </p>
691              </td>
692</tr>
693<tr>
694<td>
695                <p>
696                  Incomplete Beta Function: Medium Values
697                </p>
698              </td>
699<td>
700                <p>
701                  <span class="blue">Max = 0.949ε (Mean = 0.098ε)</span>
702                </p>
703              </td>
704<td>
705                <p>
706                  <span class="blue">Max = 63.5ε (Mean = 13.5ε)</span>
707                </p>
708              </td>
709<td>
710                <p>
711                  <span class="blue">Max = 97.6ε (Mean = 24.3ε)</span>
712                </p>
713              </td>
714<td>
715                <p>
716                  <span class="blue">Max = 90.6ε (Mean = 14.8ε)</span>
717                </p>
718              </td>
719</tr>
720<tr>
721<td>
722                <p>
723                  Incomplete Beta Function: Large and Diverse Values
724                </p>
725              </td>
726<td>
727                <p>
728                  <span class="blue">Max = 1.12ε (Mean = 0.0458ε)</span>
729                </p>
730              </td>
731<td>
732                <p>
733                  <span class="blue">Max = 1.05e+05ε (Mean = 5.45e+03ε)</span>
734                </p>
735              </td>
736<td>
737                <p>
738                  <span class="blue">Max = 1.04e+05ε (Mean = 5.46e+03ε)</span>
739                </p>
740              </td>
741<td>
742                <p>
743                  <span class="blue">Max = 3.72e+03ε (Mean = 113ε)</span>
744                </p>
745              </td>
746</tr>
747<tr>
748<td>
749                <p>
750                  Incomplete Beta Function: Small Integer Values
751                </p>
752              </td>
753<td>
754                <p>
755                  <span class="blue">Max = 0.586ε (Mean = 0.0314ε)</span>
756                </p>
757              </td>
758<td>
759                <p>
760                  <span class="blue">Max = 11.1ε (Mean = 3.65ε)</span>
761                </p>
762              </td>
763<td>
764                <p>
765                  <span class="blue">Max = 103ε (Mean = 17.4ε)</span>
766                </p>
767              </td>
768<td>
769                <p>
770                  <span class="blue">Max = 26.2ε (Mean = 6.36ε)</span>
771                </p>
772              </td>
773</tr>
774</tbody>
775</table></div>
776</div>
777<br class="table-break"><h5>
778<a name="math_toolkit.sf_beta.ibeta_function.h3"></a>
779        <span class="phrase"><a name="math_toolkit.sf_beta.ibeta_function.testing"></a></span><a class="link" href="ibeta_function.html#math_toolkit.sf_beta.ibeta_function.testing">Testing</a>
780      </h5>
781<p>
782        There are two sets of tests: spot tests compare values taken from <a href="http://functions.wolfram.com/webMathematica/FunctionEvaluation.jsp?name=BetaRegularized" target="_top">Mathworld's
783        online function evaluator</a> with this implementation: they provide
784        a basic "sanity check" for the implementation, with one spot-test
785        in each implementation-domain (see implementation notes below).
786      </p>
787<p>
788        Accuracy tests use data generated at very high precision (with <a href="http://shoup.net/ntl/doc/RR.txt" target="_top">NTL
789        RR class</a> set at 1000-bit precision), using the "textbook"
790        continued fraction representation (refer to the first continued fraction
791        in the implementation discussion below). Note that this continued fraction
792        is <span class="emphasis"><em>not</em></span> used in the implementation, and therefore we
793        have test data that is fully independent of the code.
794      </p>
795<h5>
796<a name="math_toolkit.sf_beta.ibeta_function.h4"></a>
797        <span class="phrase"><a name="math_toolkit.sf_beta.ibeta_function.implementation"></a></span><a class="link" href="ibeta_function.html#math_toolkit.sf_beta.ibeta_function.implementation">Implementation</a>
798      </h5>
799<p>
800        This implementation is closely based upon <a href="http://portal.acm.org/citation.cfm?doid=131766.131776" target="_top">"Algorithm
801        708; Significant digit computation of the incomplete beta function ratios",
802        DiDonato and Morris, ACM, 1992.</a>
803      </p>
804<p>
805        All four of these functions share a common implementation: this is passed
806        both x and y, and can return either p or q where these are related by:
807      </p>
808<div class="blockquote"><blockquote class="blockquote"><p>
809          <span class="inlinemediaobject"><img src="../../../equations/ibeta_inv5.svg"></span>
810
811        </p></blockquote></div>
812<p>
813        so at any point we can swap a for b, x for y and p for q if this results
814        in a more favourable position. Generally such swaps are performed so that
815        we always compute a value less than 0.9: when required this can then be subtracted
816        from 1 without undue cancellation error.
817      </p>
818<p>
819        The following continued fraction representation is found in many textbooks
820        but is not used in this implementation - it's both slower and less accurate
821        than the alternatives - however it is used to generate test data:
822      </p>
823<div class="blockquote"><blockquote class="blockquote"><p>
824          <span class="inlinemediaobject"><img src="../../../equations/ibeta5.svg"></span>
825
826        </p></blockquote></div>
827<p>
828        The following continued fraction is due to <a href="http://portal.acm.org/citation.cfm?doid=131766.131776" target="_top">Didonato
829        and Morris</a>, and is used in this implementation when a and b are both
830        greater than 1:
831      </p>
832<div class="blockquote"><blockquote class="blockquote"><p>
833          <span class="inlinemediaobject"><img src="../../../equations/ibeta6.svg"></span>
834
835        </p></blockquote></div>
836<p>
837        For smallish b and x then a series representation can be used:
838      </p>
839<div class="blockquote"><blockquote class="blockquote"><p>
840          <span class="inlinemediaobject"><img src="../../../equations/ibeta7.svg"></span>
841
842        </p></blockquote></div>
843<p>
844        When b &lt;&lt; a then the transition from 0 to 1 occurs very close to x
845        = 1 and some care has to be taken over the method of computation, in that
846        case the following series representation is used:
847      </p>
848<div class="blockquote"><blockquote class="blockquote"><p>
849          <span class="inlinemediaobject"><img src="../../../equations/ibeta8.svg"></span>
850
851        </p></blockquote></div>
852<p>
853        Where Q(a,x) is an <a href="http://functions.wolfram.com/GammaBetaErf/Gamma2/" target="_top">incomplete
854        gamma function</a>. Note that this method relies on keeping a table of
855        all the p<sub>n </sub> previously computed, which does limit the precision of the method,
856        depending upon the size of the table used.
857      </p>
858<p>
859        When <span class="emphasis"><em>a</em></span> and <span class="emphasis"><em>b</em></span> are both small integers,
860        then we can relate the incomplete beta to the binomial distribution and use
861        the following finite sum:
862      </p>
863<div class="blockquote"><blockquote class="blockquote"><p>
864          <span class="inlinemediaobject"><img src="../../../equations/ibeta12.svg"></span>
865
866        </p></blockquote></div>
867<p>
868        Finally we can sidestep difficult areas, or move to an area with a more efficient
869        means of computation, by using the duplication formulae:
870      </p>
871<div class="blockquote"><blockquote class="blockquote"><p>
872          <span class="inlinemediaobject"><img src="../../../equations/ibeta10.svg"></span>
873
874        </p></blockquote></div>
875<div class="blockquote"><blockquote class="blockquote"><p>
876          <span class="inlinemediaobject"><img src="../../../equations/ibeta11.svg"></span>
877
878        </p></blockquote></div>
879<p>
880        The domains of a, b and x for which the various methods are used are identical
881        to those described in the <a href="http://portal.acm.org/citation.cfm?doid=131766.131776" target="_top">Didonato
882        and Morris TOMS 708 paper</a>.
883      </p>
884</div>
885<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
886<td align="left"></td>
887<td align="right"><div class="copyright-footer">Copyright © 2006-2019 Nikhar
888      Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
889      Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Matthew Pulver, Johan
890      Råde, Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg,
891      Daryle Walker and Xiaogang Zhang<p>
892        Distributed under the Boost Software License, Version 1.0. (See accompanying
893        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>)
894      </p>
895</div></td>
896</tr></table>
897<hr>
898<div class="spirit-nav">
899<a accesskey="p" href="beta_function.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../sf_beta.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="ibeta_inv_function.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
900</div>
901</body>
902</html>
903