[DEV] add v1.66.0

This commit is contained in:
2018-01-12 21:47:58 +01:00
parent 87059bb1af
commit a97e9ae7d4
49032 changed files with 7668950 additions and 0 deletions

View File

@@ -0,0 +1,103 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Derivative of the Incomplete Beta Function</title>
<link rel="stylesheet" href="../../math.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../index.html" title="Math Toolkit 2.6.0">
<link rel="up" href="../sf_beta.html" title="Beta Functions">
<link rel="prev" href="ibeta_inv_function.html" title="The Incomplete Beta Function Inverses">
<link rel="next" href="../sf_erf.html" title="Error Functions">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="ibeta_inv_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="../sf_erf.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="math_toolkit.sf_beta.beta_derivative"></a><a class="link" href="beta_derivative.html" title="Derivative of the Incomplete Beta Function">Derivative of the
Incomplete Beta Function</a>
</h3></div></div></div>
<h5>
<a name="math_toolkit.sf_beta.beta_derivative.h0"></a>
<span class="phrase"><a name="math_toolkit.sf_beta.beta_derivative.synopsis"></a></span><a class="link" href="beta_derivative.html#math_toolkit.sf_beta.beta_derivative.synopsis">Synopsis</a>
</h5>
<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>
</pre>
<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>
<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>
<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_derivative</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">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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
<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_derivative</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
<span class="special">}}</span> <span class="comment">// namespaces</span>
</pre>
<h5>
<a name="math_toolkit.sf_beta.beta_derivative.h1"></a>
<span class="phrase"><a name="math_toolkit.sf_beta.beta_derivative.description"></a></span><a class="link" href="beta_derivative.html#math_toolkit.sf_beta.beta_derivative.description">Description</a>
</h5>
<p>
This function finds some uses in statistical distributions: it computes the
partial derivative with respect to <span class="emphasis"><em>x</em></span> of the incomplete
beta function <a class="link" href="ibeta_function.html" title="Incomplete Beta Functions">ibeta</a>.
</p>
<p>
<span class="inlinemediaobject"><img src="../../../equations/derivative2.svg"></span>
</p>
<p>
The return type of this function is computed using the <a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>result
type calculation rules</em></span></a> when T1, T2 and T3 are different
types.
</p>
<p>
The final <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a> argument is optional and can
be used to control the behaviour of the function: how it handles errors,
what level of precision to use etc. Refer to the <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">policy
documentation for more details</a>.
</p>
<h5>
<a name="math_toolkit.sf_beta.beta_derivative.h2"></a>
<span class="phrase"><a name="math_toolkit.sf_beta.beta_derivative.accuracy"></a></span><a class="link" href="beta_derivative.html#math_toolkit.sf_beta.beta_derivative.accuracy">Accuracy</a>
</h5>
<p>
Almost identical to the incomplete beta function <a class="link" href="ibeta_function.html" title="Incomplete Beta Functions">ibeta</a>.
</p>
<h5>
<a name="math_toolkit.sf_beta.beta_derivative.h3"></a>
<span class="phrase"><a name="math_toolkit.sf_beta.beta_derivative.implementation"></a></span><a class="link" href="beta_derivative.html#math_toolkit.sf_beta.beta_derivative.implementation">Implementation</a>
</h5>
<p>
This function just expose some of the internals of the incomplete beta function
<a class="link" href="ibeta_function.html" title="Incomplete Beta Functions">ibeta</a>: refer to
the documentation for that function for more information.
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2006-2010, 2012-2014, 2017 Nikhar
Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan R&#229;de, Gautam
Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg, Daryle Walker
and Xiaogang Zhang<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
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>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="ibeta_inv_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="../sf_erf.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,319 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Beta</title>
<link rel="stylesheet" href="../../math.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../index.html" title="Math Toolkit 2.6.0">
<link rel="up" href="../sf_beta.html" title="Beta Functions">
<link rel="prev" href="../sf_beta.html" title="Beta Functions">
<link rel="next" href="ibeta_function.html" title="Incomplete Beta Functions">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../sf_beta.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_function.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="math_toolkit.sf_beta.beta_function"></a><a class="link" href="beta_function.html" title="Beta">Beta</a>
</h3></div></div></div>
<h5>
<a name="math_toolkit.sf_beta.beta_function.h0"></a>
<span class="phrase"><a name="math_toolkit.sf_beta.beta_function.synopsis"></a></span><a class="link" href="beta_function.html#math_toolkit.sf_beta.beta_function.synopsis">Synopsis</a>
</h5>
<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>
</pre>
<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>
<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">&gt;</span>
<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="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> <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
<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="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
<span class="special">}}</span> <span class="comment">// namespaces</span>
</pre>
<h5>
<a name="math_toolkit.sf_beta.beta_function.h1"></a>
<span class="phrase"><a name="math_toolkit.sf_beta.beta_function.description"></a></span><a class="link" href="beta_function.html#math_toolkit.sf_beta.beta_function.description">Description</a>
</h5>
<p>
The beta function is defined by:
</p>
<p>
<span class="inlinemediaobject"><img src="../../../equations/beta1.svg"></span>
</p>
<p>
<span class="inlinemediaobject"><img src="../../../graphs/beta.svg" align="middle"></span>
</p>
<p>
The final <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a> argument is optional and can
be used to control the behaviour of the function: how it handles errors,
what level of precision to use etc. Refer to the <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">policy
documentation for more details</a>.
</p>
<p>
There are effectively two versions of this function internally: a fully generic
version that is slow, but reasonably accurate, and a much more efficient
approximation that is used where the number of digits in the significand
of T correspond to a certain <a class="link" href="../lanczos.html" title="The Lanczos Approximation">Lanczos
approximation</a>. In practice any built-in floating-point type you will
encounter has an appropriate <a class="link" href="../lanczos.html" title="The Lanczos Approximation">Lanczos
approximation</a> defined for it. It is also possible, given enough machine
time, to generate further <a class="link" href="../lanczos.html" title="The Lanczos Approximation">Lanczos approximation</a>'s
using the program libs/math/tools/lanczos_generator.cpp.
</p>
<p>
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
type calculation rules</em></span></a> when T1 and T2 are different types.
</p>
<h5>
<a name="math_toolkit.sf_beta.beta_function.h2"></a>
<span class="phrase"><a name="math_toolkit.sf_beta.beta_function.accuracy"></a></span><a class="link" href="beta_function.html#math_toolkit.sf_beta.beta_function.accuracy">Accuracy</a>
</h5>
<p>
The following table shows peak errors for various domains of input arguments,
along with comparisons to the <a href="http://www.gnu.org/software/gsl/" target="_top">GSL-1.9</a>
and <a href="http://www.netlib.org/cephes/" target="_top">Cephes</a> libraries.
Note that only results for the widest floating point type on the system are
given as narrower types have <a class="link" href="../relative_error.html#math_toolkit.relative_error.zero_error">effectively
zero error</a>.
</p>
<div class="table">
<a name="math_toolkit.sf_beta.beta_function.table_beta"></a><p class="title"><b>Table&#160;6.17.&#160;Error rates for beta</b></p>
<div class="table-contents"><table class="table" summary="Error rates for beta">
<colgroup>
<col>
<col>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
</th>
<th>
<p>
Microsoft Visual C++ version 12.0<br> Win32<br> double
</p>
</th>
<th>
<p>
GNU C++ version 5.1.0<br> linux<br> long double
</p>
</th>
<th>
<p>
GNU C++ version 5.1.0<br> linux<br> double
</p>
</th>
<th>
<p>
Sun compiler version 0x5130<br> Sun Solaris<br> long double
</p>
</th>
</tr></thead>
<tbody>
<tr>
<td>
<p>
Beta Function: Small Values
</p>
</td>
<td>
<p>
<span class="blue">Max = 1.75&#949; (Mean = 0.828&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 2.65&#949; (Mean = 1.22&#949;)</span><br> <br>
(<span class="emphasis"><em>&lt;tr1/cmath&gt;:</em></span> Max = 11.9&#949; (Mean = 7.03&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
1.16:</em></span> Max = 3.94&#949; (Mean = 1.44&#949;))<br> (<span class="emphasis"><em>Rmath
3.0.2:</em></span> Max = 1.14&#949; (Mean = 0.601&#949;))<br> (<span class="emphasis"><em>Cephes:</em></span>
Max = 1.97&#949; (Mean = 0.934&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 2.86&#949; (Mean = 1.31&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
Beta Function: Medium Values
</p>
</td>
<td>
<p>
<span class="blue">Max = 99.1&#949; (Mean = 22.4&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 60.4&#949; (Mean = 19.4&#949;)</span><br> <br>
(<span class="emphasis"><em>&lt;tr1/cmath&gt;:</em></span> Max = 1.07e+03&#949; (Mean =
264&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.978&#949; (Mean = 0.0578&#949;)</span><br>
<br> (<span class="emphasis"><em>GSL 1.16:</em></span> Max = 1.18e+03&#949; (Mean = 238&#949;))<br>
(<span class="emphasis"><em>Rmath 3.0.2:</em></span> Max = 1.09e+03&#949; (Mean = 265&#949;))<br>
(<span class="emphasis"><em>Cephes:</em></span> Max = 1.5e+03&#949; (Mean = 329&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 107&#949; (Mean = 24.5&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
Beta Function: Divergent Values
</p>
</td>
<td>
<p>
<span class="blue">Max = 10.7&#949; (Mean = 2.22&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 10.3&#949; (Mean = 2.41&#949;)</span><br> <br>
(<span class="emphasis"><em>&lt;tr1/cmath&gt;:</em></span> Max = 128&#949; (Mean = 23.8&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
1.16:</em></span> Max = 12.1&#949; (Mean = 1.99&#949;))<br> (<span class="emphasis"><em>Rmath
3.0.2:</em></span> Max = 176&#949; (Mean = 28&#949;))<br> (<span class="emphasis"><em>Cephes:</em></span>
Max = 175&#949; (Mean = 22&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 19.7&#949; (Mean = 2.75&#949;)</span>
</p>
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><p>
Note that the worst errors occur when a or b are large, and that when this
is the case the result is very close to zero, so absolute errors will be
very small.
</p>
<h5>
<a name="math_toolkit.sf_beta.beta_function.h3"></a>
<span class="phrase"><a name="math_toolkit.sf_beta.beta_function.testing"></a></span><a class="link" href="beta_function.html#math_toolkit.sf_beta.beta_function.testing">Testing</a>
</h5>
<p>
A mixture of spot tests of exact values, and randomly generated test data
are used: the test data was computed using <a href="http://shoup.net/ntl/doc/RR.txt" target="_top">NTL::RR</a>
at 1000-bit precision.
</p>
<h5>
<a name="math_toolkit.sf_beta.beta_function.h4"></a>
<span class="phrase"><a name="math_toolkit.sf_beta.beta_function.implementation"></a></span><a class="link" href="beta_function.html#math_toolkit.sf_beta.beta_function.implementation">Implementation</a>
</h5>
<p>
Traditional methods of evaluating the beta function either involve evaluating
the gamma functions directly, or taking logarithms and then exponentiating
the result. However, the former is prone to overflows for even very modest
arguments, while the latter is prone to cancellation errors. As an alternative,
if we regard the gamma function as a white-box containing the <a class="link" href="../lanczos.html" title="The Lanczos Approximation">Lanczos
approximation</a>, then we can combine the power terms:
</p>
<p>
<span class="inlinemediaobject"><img src="../../../equations/beta2.svg"></span>
</p>
<p>
which is almost the ideal solution, however almost all of the error occurs
in evaluating the power terms when <span class="emphasis"><em>a</em></span> or <span class="emphasis"><em>b</em></span>
are large. If we assume that <span class="emphasis"><em>a &gt; b</em></span> then the larger
of the two power terms can be reduced by a factor of <span class="emphasis"><em>b</em></span>,
which immediately cuts the maximum error in half:
</p>
<p>
<span class="inlinemediaobject"><img src="../../../equations/beta3.svg"></span>
</p>
<p>
This may not be the final solution, but it is very competitive compared to
other implementation methods.
</p>
<p>
The generic implementation - where no <a class="link" href="../lanczos.html" title="The Lanczos Approximation">Lanczos
approximation</a> approximation is available - is implemented in a very
similar way to the generic version of the gamma function. Again in order
to avoid numerical overflow the power terms that prefix the series and continued
fraction parts are collected together into:
</p>
<p>
<span class="inlinemediaobject"><img src="../../../equations/beta8.svg"></span>
</p>
<p>
where la, lb and lc are the integration limits used for a, b, and a+b.
</p>
<p>
There are a few special cases worth mentioning:
</p>
<p>
When <span class="emphasis"><em>a</em></span> or <span class="emphasis"><em>b</em></span> are less than one,
we can use the recurrence relations:
</p>
<p>
<span class="inlinemediaobject"><img src="../../../equations/beta4.svg"></span>
</p>
<p>
<span class="inlinemediaobject"><img src="../../../equations/beta5.svg"></span>
</p>
<p>
to move to a more favorable region where they are both greater than 1.
</p>
<p>
In addition:
</p>
<p>
<span class="inlinemediaobject"><img src="../../../equations/beta7.svg"></span>
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2006-2010, 2012-2014, 2017 Nikhar
Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan R&#229;de, Gautam
Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg, Daryle Walker
and Xiaogang Zhang<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
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>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../sf_beta.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_function.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,894 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Incomplete Beta Functions</title>
<link rel="stylesheet" href="../../math.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../index.html" title="Math Toolkit 2.6.0">
<link rel="up" href="../sf_beta.html" title="Beta Functions">
<link rel="prev" href="beta_function.html" title="Beta">
<link rel="next" href="ibeta_inv_function.html" title="The Incomplete Beta Function Inverses">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<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>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="math_toolkit.sf_beta.ibeta_function"></a><a class="link" href="ibeta_function.html" title="Incomplete Beta Functions">Incomplete Beta
Functions</a>
</h3></div></div></div>
<h5>
<a name="math_toolkit.sf_beta.ibeta_function.h0"></a>
<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>
</h5>
<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>
</pre>
<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>
<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>
<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">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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
<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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
<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>
<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">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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
<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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
<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>
<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">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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
<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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
<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>
<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">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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
<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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
<span class="special">}}</span> <span class="comment">// namespaces</span>
</pre>
<h5>
<a name="math_toolkit.sf_beta.ibeta_function.h1"></a>
<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>
</h5>
<p>
There are four <a href="http://en.wikipedia.org/wiki/Incomplete_beta_function" target="_top">incomplete
beta functions</a> : two are normalised versions (also known as <span class="emphasis"><em>regularized</em></span>
beta functions) that return values in the range [0, 1], and two are non-normalised
and return values in the range [0, <a class="link" href="beta_function.html" title="Beta">beta</a>(a,
b)]. Users interested in statistical applications should use the normalised
(or <a href="http://mathworld.wolfram.com/RegularizedBetaFunction.html" target="_top">regularized</a>
) versions (ibeta and ibetac).
</p>
<p>
All of these functions require <span class="emphasis"><em>0 &lt;= x &lt;= 1</em></span>.
</p>
<p>
The normalized functions <a class="link" href="ibeta_function.html" title="Incomplete Beta Functions">ibeta</a>
and <a class="link" href="ibeta_function.html" title="Incomplete Beta Functions">ibetac</a> require
<span class="emphasis"><em>a,b &gt;= 0</em></span>, and in addition that not both <span class="emphasis"><em>a</em></span>
and <span class="emphasis"><em>b</em></span> are zero.
</p>
<p>
The functions <a class="link" href="beta_function.html" title="Beta">beta</a>
and <a class="link" href="ibeta_function.html" title="Incomplete Beta Functions">betac</a> require
<span class="emphasis"><em>a,b &gt; 0</em></span>.
</p>
<p>
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
type calculation rules</em></span></a> when T1, T2 and T3 are different
types.
</p>
<p>
The final <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a> argument is optional and can
be used to control the behaviour of the function: how it handles errors,
what level of precision to use etc. Refer to the <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">policy
documentation for more details</a>.
</p>
<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>
<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">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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
<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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
</pre>
<p>
Returns the normalised incomplete beta function of a, b and x:
</p>
<p>
<span class="inlinemediaobject"><img src="../../../equations/ibeta3.svg"></span>
</p>
<p>
<span class="inlinemediaobject"><img src="../../../graphs/ibeta.svg" align="middle"></span>
</p>
<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>
<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">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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
<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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
</pre>
<p>
Returns the normalised complement of the incomplete beta function of a, b
and x:
</p>
<p>
<span class="inlinemediaobject"><img src="../../../equations/ibeta4.svg"></span>
</p>
<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>
<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">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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
<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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
</pre>
<p>
Returns the full (non-normalised) incomplete beta function of a, b and x:
</p>
<p>
<span class="inlinemediaobject"><img src="../../../equations/ibeta1.svg"></span>
</p>
<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>
<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">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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
<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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
</pre>
<p>
Returns the full (non-normalised) complement of the incomplete beta function
of a, b and x:
</p>
<p>
<span class="inlinemediaobject"><img src="../../../equations/ibeta2.svg"></span>
</p>
<h5>
<a name="math_toolkit.sf_beta.ibeta_function.h2"></a>
<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>
</h5>
<p>
The following tables give peak and mean relative errors in over various domains
of a, b and x, along with comparisons to the <a href="http://www.gnu.org/software/gsl/" target="_top">GSL-1.9</a>
and <a href="http://www.netlib.org/cephes/" target="_top">Cephes</a> libraries.
Note that only results for the widest floating-point type on the system are
given as narrower types have <a class="link" href="../relative_error.html#math_toolkit.relative_error.zero_error">effectively
zero error</a>.
</p>
<p>
Note that the results for 80 and 128-bit long doubles are noticeably higher
than for doubles: this is because the wider exponent range of these types
allow more extreme test cases to be tested. For example expected results
that are zero at double precision, may be finite but exceptionally small
with the wider exponent range of the long double types.
</p>
<div class="table">
<a name="math_toolkit.sf_beta.ibeta_function.table_ibeta"></a><p class="title"><b>Table&#160;6.18.&#160;Error rates for ibeta</b></p>
<div class="table-contents"><table class="table" summary="Error rates for ibeta">
<colgroup>
<col>
<col>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
</th>
<th>
<p>
Microsoft Visual C++ version 12.0<br> Win32<br> double
</p>
</th>
<th>
<p>
GNU C++ version 5.1.0<br> linux<br> double
</p>
</th>
<th>
<p>
GNU C++ version 5.1.0<br> linux<br> long double
</p>
</th>
<th>
<p>
Sun compiler version 0x5130<br> Sun Solaris<br> long double
</p>
</th>
</tr></thead>
<tbody>
<tr>
<td>
<p>
Incomplete Beta Function: Small Values
</p>
</td>
<td>
<p>
<span class="blue">Max = 9.42&#949; (Mean = 2.24&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
1.16:</em></span> Max = 682&#949; (Mean = 32.6&#949;))<br> (<span class="emphasis"><em>Rmath
3.0.2:</em></span> Max = 22.9&#949; (Mean = 3.35&#949;))<br> (<span class="emphasis"><em>Cephes:</em></span>
Max = 22.7&#949; (Mean = 1.69&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 6.27&#949; (Mean = 1.7&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 21.3&#949; (Mean = 2.74&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
Incomplete Beta Function: Medium Values
</p>
</td>
<td>
<p>
<span class="blue">Max = 108&#949; (Mean = 16.3&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
1.16:</em></span> Max = 690&#949; (Mean = 151&#949;))<br> (<span class="emphasis"><em>Rmath
3.0.2:</em></span> Max = 232&#949; (Mean = 27.9&#949;))<br> (<span class="emphasis"><em>Cephes:</em></span>
Max = 1.55e+03&#949; (Mean = 121&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 51.4&#949; (Mean = 12&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 124&#949; (Mean = 18.4&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
Incomplete Beta Function: Large and Diverse Values
</p>
</td>
<td>
<p>
<span class="blue">Max = 1.19e+003&#949; (Mean = 59.5&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 1.26&#949; (Mean = 0.063&#949;)</span><br> <br>
(<span class="emphasis"><em>GSL 1.16:</em></span> Max = 3.9e+05&#949; (Mean = 1.82e+04&#949;)
<a class="link" href="../logs_and_tables/logs.html#errors_GNU_C_version_5_1_0_linux_double_ibeta_GSL_1_16_Incomplete_Beta_Function_Large_and_Diverse_Values">And
other failures.</a>)<br> (<span class="emphasis"><em>Rmath 3.0.2:</em></span>
Max = 574&#949; (Mean = 49.4&#949;))<br> (<span class="emphasis"><em>Cephes:</em></span> Max
= 5.92e+05&#949; (Mean = 2.17e+04&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 1.96e+04&#949; (Mean = 997&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 4.98e+04&#949; (Mean = 2.07e+03&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
Incomplete Beta Function: Small Integer Values
</p>
</td>
<td>
<p>
<span class="blue">Max = 3.69&#949; (Mean = 0.765&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
1.16:</em></span> Max = 254&#949; (Mean = 50.9&#949;))<br> (<span class="emphasis"><em>Rmath
3.0.2:</em></span> Max = 62.2&#949; (Mean = 8.95&#949;))<br> (<span class="emphasis"><em>Cephes:</em></span>
Max = 7.96&#949; (Mean = 1.3&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 4.45&#949; (Mean = 0.814&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 44.5&#949; (Mean = 10.1&#949;)</span>
</p>
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><div class="table">
<a name="math_toolkit.sf_beta.ibeta_function.table_ibetac"></a><p class="title"><b>Table&#160;6.19.&#160;Error rates for ibetac</b></p>
<div class="table-contents"><table class="table" summary="Error rates for ibetac">
<colgroup>
<col>
<col>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
</th>
<th>
<p>
Microsoft Visual C++ version 12.0<br> Win32<br> double
</p>
</th>
<th>
<p>
GNU C++ version 5.1.0<br> linux<br> double
</p>
</th>
<th>
<p>
GNU C++ version 5.1.0<br> linux<br> long double
</p>
</th>
<th>
<p>
Sun compiler version 0x5130<br> Sun Solaris<br> long double
</p>
</th>
</tr></thead>
<tbody>
<tr>
<td>
<p>
Incomplete Beta Function: Small Values
</p>
</td>
<td>
<p>
<span class="blue">Max = 6.56&#949; (Mean = 1.88&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>Rmath
3.0.2:</em></span> Max = 22.4&#949; (Mean = 3.67&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 8.47&#949; (Mean = 1.68&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 13.8&#949; (Mean = 2.69&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
Incomplete Beta Function: Medium Values
</p>
</td>
<td>
<p>
<span class="blue">Max = 56.2&#949; (Mean = 14.1&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>Rmath
3.0.2:</em></span> Max = 204&#949; (Mean = 25.8&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 75.3&#949; (Mean = 11.3&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 132&#949; (Mean = 19.8&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
Incomplete Beta Function: Large and Diverse Values
</p>
</td>
<td>
<p>
<span class="blue">Max = 1.87e+003&#949; (Mean = 93.8&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.981&#949; (Mean = 0.0638&#949;)</span><br>
<br> (<span class="emphasis"><em>Rmath 3.0.2:</em></span> Max = 889&#949; (Mean = 68.4&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 3.45e+04&#949; (Mean = 1.32e+03&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 4.26e+04&#949; (Mean = 1.54e+03&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
Incomplete Beta Function: Small Integer Values
</p>
</td>
<td>
<p>
<span class="blue">Max = 6.37&#949; (Mean = 1.03&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>Rmath
3.0.2:</em></span> Max = 84.6&#949; (Mean = 18&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 5.34&#949; (Mean = 1.11&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 107&#949; (Mean = 17.1&#949;)</span>
</p>
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><div class="table">
<a name="math_toolkit.sf_beta.ibeta_function.table_beta_incomplete_"></a><p class="title"><b>Table&#160;6.20.&#160;Error rates for beta (incomplete)</b></p>
<div class="table-contents"><table class="table" summary="Error rates for beta (incomplete)">
<colgroup>
<col>
<col>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
</th>
<th>
<p>
Microsoft Visual C++ version 12.0<br> Win32<br> double
</p>
</th>
<th>
<p>
GNU C++ version 5.1.0<br> linux<br> double
</p>
</th>
<th>
<p>
GNU C++ version 5.1.0<br> linux<br> long double
</p>
</th>
<th>
<p>
Sun compiler version 0x5130<br> Sun Solaris<br> long double
</p>
</th>
</tr></thead>
<tbody>
<tr>
<td>
<p>
Incomplete Beta Function: Small Values
</p>
</td>
<td>
<p>
<span class="blue">Max = 11.1&#949; (Mean = 2.28&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 12.5&#949; (Mean = 2.01&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 18.7&#949; (Mean = 3.19&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
Incomplete Beta Function: Medium Values
</p>
</td>
<td>
<p>
<span class="blue">Max = 91.1&#949; (Mean = 12.7&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.568&#949; (Mean = 0.0342&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 67.1&#949; (Mean = 13.3&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 174&#949; (Mean = 25&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
Incomplete Beta Function: Large and Diverse Values
</p>
</td>
<td>
<p>
<span class="blue">Max = 635&#949; (Mean = 29.5&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.999&#949; (Mean = 0.0399&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 6.84e+04&#949; (Mean = 2.76e+03&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 6.86e+04&#949; (Mean = 2.79e+03&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
Incomplete Beta Function: Small Integer Values
</p>
</td>
<td>
<p>
<span class="blue">Max = 26.8&#949; (Mean = 6.61&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.786&#949; (Mean = 0.0248&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 10.2&#949; (Mean = 3.49&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 51.8&#949; (Mean = 11&#949;)</span>
</p>
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><div class="table">
<a name="math_toolkit.sf_beta.ibeta_function.table_betac"></a><p class="title"><b>Table&#160;6.21.&#160;Error rates for betac</b></p>
<div class="table-contents"><table class="table" summary="Error rates for betac">
<colgroup>
<col>
<col>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
</th>
<th>
<p>
Microsoft Visual C++ version 12.0<br> Win32<br> double
</p>
</th>
<th>
<p>
GNU C++ version 5.1.0<br> linux<br> double
</p>
</th>
<th>
<p>
GNU C++ version 5.1.0<br> linux<br> long double
</p>
</th>
<th>
<p>
Sun compiler version 0x5130<br> Sun Solaris<br> long double
</p>
</th>
</tr></thead>
<tbody>
<tr>
<td>
<p>
Incomplete Beta Function: Small Values
</p>
</td>
<td>
<p>
<span class="blue">Max = 12&#949; (Mean = 2.43&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.676&#949; (Mean = 0.0302&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 7.75&#949; (Mean = 1.91&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 12.6&#949; (Mean = 3.02&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
Incomplete Beta Function: Medium Values
</p>
</td>
<td>
<p>
<span class="blue">Max = 91.3&#949; (Mean = 14.8&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.949&#949; (Mean = 0.0944&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 63.5&#949; (Mean = 13.4&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 97.6&#949; (Mean = 24.3&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
Incomplete Beta Function: Large and Diverse Values
</p>
</td>
<td>
<p>
<span class="blue">Max = 3.72e+003&#949; (Mean = 113&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 1.12&#949; (Mean = 0.0458&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 1.05e+05&#949; (Mean = 5.45e+03&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 1.04e+05&#949; (Mean = 5.46e+03&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
Incomplete Beta Function: Small Integer Values
</p>
</td>
<td>
<p>
<span class="blue">Max = 26.7&#949; (Mean = 6.67&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.586&#949; (Mean = 0.0314&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 10.4&#949; (Mean = 3.54&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 103&#949; (Mean = 17.4&#949;)</span>
</p>
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><h5>
<a name="math_toolkit.sf_beta.ibeta_function.h3"></a>
<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>
</h5>
<p>
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
online function evaluator</a> with this implementation: they provide
a basic "sanity check" for the implementation, with one spot-test
in each implementation-domain (see implementation notes below).
</p>
<p>
Accuracy tests use data generated at very high precision (with <a href="http://shoup.net/ntl/doc/RR.txt" target="_top">NTL
RR class</a> set at 1000-bit precision), using the "textbook"
continued fraction representation (refer to the first continued fraction
in the implementation discussion below). Note that this continued fraction
is <span class="emphasis"><em>not</em></span> used in the implementation, and therefore we
have test data that is fully independent of the code.
</p>
<h5>
<a name="math_toolkit.sf_beta.ibeta_function.h4"></a>
<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>
</h5>
<p>
This implementation is closely based upon <a href="http://portal.acm.org/citation.cfm?doid=131766.131776" target="_top">"Algorithm
708; Significant digit computation of the incomplete beta function ratios",
DiDonato and Morris, ACM, 1992.</a>
</p>
<p>
All four of these functions share a common implementation: this is passed
both x and y, and can return either p or q where these are related by:
</p>
<p>
<span class="inlinemediaobject"><img src="../../../equations/ibeta_inv5.svg"></span>
</p>
<p>
so at any point we can swap a for b, x for y and p for q if this results
in a more favourable position. Generally such swaps are performed so that
we always compute a value less than 0.9: when required this can then be subtracted
from 1 without undue cancellation error.
</p>
<p>
The following continued fraction representation is found in many textbooks
but is not used in this implementation - it's both slower and less accurate
than the alternatives - however it is used to generate test data:
</p>
<p>
<span class="inlinemediaobject"><img src="../../../equations/ibeta5.svg"></span>
</p>
<p>
The following continued fraction is due to <a href="http://portal.acm.org/citation.cfm?doid=131766.131776" target="_top">Didonato
and Morris</a>, and is used in this implementation when a and b are both
greater than 1:
</p>
<p>
<span class="inlinemediaobject"><img src="../../../equations/ibeta6.svg"></span>
</p>
<p>
For smallish b and x then a series representation can be used:
</p>
<p>
<span class="inlinemediaobject"><img src="../../../equations/ibeta7.svg"></span>
</p>
<p>
When b &lt;&lt; a then the transition from 0 to 1 occurs very close to x
= 1 and some care has to be taken over the method of computation, in that
case the following series representation is used:
</p>
<p>
<span class="inlinemediaobject"><img src="../../../equations/ibeta8.svg"></span>
</p>
<p>
Where Q(a,x) is an <a href="http://functions.wolfram.com/GammaBetaErf/Gamma2/" target="_top">incomplete
gamma function</a>. Note that this method relies on keeping a table of
all the p<sub>n </sub> previously computed, which does limit the precision of the method,
depending upon the size of the table used.
</p>
<p>
When <span class="emphasis"><em>a</em></span> and <span class="emphasis"><em>b</em></span> are both small integers,
then we can relate the incomplete beta to the binomial distribution and use
the following finite sum:
</p>
<p>
<span class="inlinemediaobject"><img src="../../../equations/ibeta12.svg"></span>
</p>
<p>
Finally we can sidestep difficult areas, or move to an area with a more efficient
means of computation, by using the duplication formulae:
</p>
<p>
<span class="inlinemediaobject"><img src="../../../equations/ibeta10.svg"></span>
</p>
<p>
<span class="inlinemediaobject"><img src="../../../equations/ibeta11.svg"></span>
</p>
<p>
The domains of a, b and x for which the various methods are used are identical
to those described in the <a href="http://portal.acm.org/citation.cfm?doid=131766.131776" target="_top">Didonato
and Morris TOMS 708 paper</a>.
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2006-2010, 2012-2014, 2017 Nikhar
Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan R&#229;de, Gautam
Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg, Daryle Walker
and Xiaogang Zhang<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
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>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<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>
</div>
</body>
</html>

View File

@@ -0,0 +1,913 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>The Incomplete Beta Function Inverses</title>
<link rel="stylesheet" href="../../math.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../index.html" title="Math Toolkit 2.6.0">
<link rel="up" href="../sf_beta.html" title="Beta Functions">
<link rel="prev" href="ibeta_function.html" title="Incomplete Beta Functions">
<link rel="next" href="beta_derivative.html" title="Derivative of the Incomplete Beta Function">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="ibeta_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="beta_derivative.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="math_toolkit.sf_beta.ibeta_inv_function"></a><a class="link" href="ibeta_inv_function.html" title="The Incomplete Beta Function Inverses">The Incomplete
Beta Function Inverses</a>
</h3></div></div></div>
<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>
</pre>
<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>
<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>
<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_inv</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">p</span><span class="special">);</span>
<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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
<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_inv</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">p</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
<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> <span class="identifier">T4</span><span class="special">&gt;</span>
<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_inv</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">p</span><span class="special">,</span> <span class="identifier">T4</span><span class="special">*</span> <span class="identifier">py</span><span class="special">);</span>
<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> <span class="identifier">T4</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
<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_inv</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">p</span><span class="special">,</span> <span class="identifier">T4</span><span class="special">*</span> <span class="identifier">py</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
<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>
<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_inv</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">q</span><span class="special">);</span>
<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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
<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_inv</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">q</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
<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> <span class="identifier">T4</span><span class="special">&gt;</span>
<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_inv</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">q</span><span class="special">,</span> <span class="identifier">T4</span><span class="special">*</span> <span class="identifier">py</span><span class="special">);</span>
<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> <span class="identifier">T4</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
<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_inv</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">q</span><span class="special">,</span> <span class="identifier">T4</span><span class="special">*</span> <span class="identifier">py</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
<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>
<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_inva</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">b</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T3</span> <span class="identifier">p</span><span class="special">);</span>
<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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
<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_inva</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">b</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T3</span> <span class="identifier">p</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
<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>
<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_inva</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">b</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T3</span> <span class="identifier">q</span><span class="special">);</span>
<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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
<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_inva</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">b</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T3</span> <span class="identifier">q</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
<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>
<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_invb</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">x</span><span class="special">,</span> <span class="identifier">T3</span> <span class="identifier">p</span><span class="special">);</span>
<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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
<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_invb</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">x</span><span class="special">,</span> <span class="identifier">T3</span> <span class="identifier">p</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
<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>
<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_invb</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">x</span><span class="special">,</span> <span class="identifier">T3</span> <span class="identifier">q</span><span class="special">);</span>
<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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
<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_invb</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">x</span><span class="special">,</span> <span class="identifier">T3</span> <span class="identifier">q</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
<span class="special">}}</span> <span class="comment">// namespaces</span>
</pre>
<h5>
<a name="math_toolkit.sf_beta.ibeta_inv_function.h0"></a>
<span class="phrase"><a name="math_toolkit.sf_beta.ibeta_inv_function.description"></a></span><a class="link" href="ibeta_inv_function.html#math_toolkit.sf_beta.ibeta_inv_function.description">Description</a>
</h5>
<p>
There are six <a href="http://functions.wolfram.com/GammaBetaErf/" target="_top">incomplete
beta function inverses</a> which allow you solve for any of the three
parameters to the incomplete beta, starting from either the result of the
incomplete beta (p) or its complement (q).
</p>
<p>
The final <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a> argument is optional and can
be used to control the behaviour of the function: how it handles errors,
what level of precision to use etc. Refer to the <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">policy
documentation for more details</a>.
</p>
<div class="tip"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="../../../../../../doc/src/images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top">
<p>
When people normally talk about the inverse of the incomplete beta function,
they are talking about inverting on parameter <span class="emphasis"><em>x</em></span>. These
are implemented here as ibeta_inv and ibetac_inv, and are by far the most
efficient of the inverses presented here.
</p>
<p>
The inverses on the <span class="emphasis"><em>a</em></span> and <span class="emphasis"><em>b</em></span> parameters
find use in some statistical applications, but have to be computed by rather
brute force numerical techniques and are consequently several times slower.
These are implemented here as ibeta_inva and ibeta_invb, and complement
versions ibetac_inva and ibetac_invb.
</p>
</td></tr>
</table></div>
<p>
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
type calculation rules</em></span></a> when called with arguments T1...TN
of different types.
</p>
<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>
<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_inv</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">p</span><span class="special">);</span>
<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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
<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_inv</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">p</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
<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> <span class="identifier">T4</span><span class="special">&gt;</span>
<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_inv</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">p</span><span class="special">,</span> <span class="identifier">T4</span><span class="special">*</span> <span class="identifier">py</span><span class="special">);</span>
<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> <span class="identifier">T4</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
<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_inv</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">p</span><span class="special">,</span> <span class="identifier">T4</span><span class="special">*</span> <span class="identifier">py</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
</pre>
<p>
Returns a value <span class="emphasis"><em>x</em></span> such that: <code class="computeroutput"><span class="identifier">p</span>
<span class="special">=</span> <span class="identifier">ibeta</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="identifier">x</span><span class="special">);</span></code> and
sets <code class="computeroutput"><span class="special">*</span><span class="identifier">py</span>
<span class="special">=</span> <span class="number">1</span> <span class="special">-</span> <span class="identifier">x</span></code> when
the <code class="computeroutput"><span class="identifier">py</span></code> parameter is provided
and is non-null. Note that internally this function computes whichever is
the smaller of <code class="computeroutput"><span class="identifier">x</span></code> and <code class="computeroutput"><span class="number">1</span><span class="special">-</span><span class="identifier">x</span></code>,
and therefore the value assigned to <code class="computeroutput"><span class="special">*</span><span class="identifier">py</span></code> is free from cancellation errors. That
means that even if the function returns <code class="computeroutput"><span class="number">1</span></code>,
the value stored in <code class="computeroutput"><span class="special">*</span><span class="identifier">py</span></code>
may be non-zero, albeit very small.
</p>
<p>
Requires: <span class="emphasis"><em>a,b &gt; 0</em></span> and <span class="emphasis"><em>0 &lt;= p &lt;= 1</em></span>.
</p>
<p>
The final <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a> argument is optional and can
be used to control the behaviour of the function: how it handles errors,
what level of precision to use etc. Refer to the <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">policy
documentation for more details</a>.
</p>
<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>
<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_inv</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">q</span><span class="special">);</span>
<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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
<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_inv</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">q</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
<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> <span class="identifier">T4</span><span class="special">&gt;</span>
<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_inv</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">q</span><span class="special">,</span> <span class="identifier">T4</span><span class="special">*</span> <span class="identifier">py</span><span class="special">);</span>
<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> <span class="identifier">T4</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
<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_inv</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">q</span><span class="special">,</span> <span class="identifier">T4</span><span class="special">*</span> <span class="identifier">py</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
</pre>
<p>
Returns a value <span class="emphasis"><em>x</em></span> such that: <code class="computeroutput"><span class="identifier">q</span>
<span class="special">=</span> <span class="identifier">ibetac</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="identifier">x</span><span class="special">);</span></code> and
sets <code class="computeroutput"><span class="special">*</span><span class="identifier">py</span>
<span class="special">=</span> <span class="number">1</span> <span class="special">-</span> <span class="identifier">x</span></code> when
the <code class="computeroutput"><span class="identifier">py</span></code> parameter is provided
and is non-null. Note that internally this function computes whichever is
the smaller of <code class="computeroutput"><span class="identifier">x</span></code> and <code class="computeroutput"><span class="number">1</span><span class="special">-</span><span class="identifier">x</span></code>,
and therefore the value assigned to <code class="computeroutput"><span class="special">*</span><span class="identifier">py</span></code> is free from cancellation errors. That
means that even if the function returns <code class="computeroutput"><span class="number">1</span></code>,
the value stored in <code class="computeroutput"><span class="special">*</span><span class="identifier">py</span></code>
may be non-zero, albeit very small.
</p>
<p>
Requires: <span class="emphasis"><em>a,b &gt; 0</em></span> and <span class="emphasis"><em>0 &lt;= q &lt;= 1</em></span>.
</p>
<p>
The final <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a> argument is optional and can
be used to control the behaviour of the function: how it handles errors,
what level of precision to use etc. Refer to the <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">policy
documentation for more details</a>.
</p>
<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>
<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_inva</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">b</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T3</span> <span class="identifier">p</span><span class="special">);</span>
<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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
<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_inva</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">b</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T3</span> <span class="identifier">p</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
</pre>
<p>
Returns a value <span class="emphasis"><em>a</em></span> such that: <code class="computeroutput"><span class="identifier">p</span>
<span class="special">=</span> <span class="identifier">ibeta</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="identifier">x</span><span class="special">);</span></code>
</p>
<p>
Requires: <span class="emphasis"><em>b &gt; 0</em></span>, <span class="emphasis"><em>0 &lt; x &lt; 1</em></span>
and <span class="emphasis"><em>0 &lt;= p &lt;= 1</em></span>.
</p>
<p>
The final <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a> argument is optional and can
be used to control the behaviour of the function: how it handles errors,
what level of precision to use etc. Refer to the <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">policy
documentation for more details</a>.
</p>
<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>
<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_inva</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">b</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T3</span> <span class="identifier">p</span><span class="special">);</span>
<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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
<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_inva</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">b</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T3</span> <span class="identifier">p</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
</pre>
<p>
Returns a value <span class="emphasis"><em>a</em></span> such that: <code class="computeroutput"><span class="identifier">q</span>
<span class="special">=</span> <span class="identifier">ibetac</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="identifier">x</span><span class="special">);</span></code>
</p>
<p>
Requires: <span class="emphasis"><em>b &gt; 0</em></span>, <span class="emphasis"><em>0 &lt; x &lt; 1</em></span>
and <span class="emphasis"><em>0 &lt;= q &lt;= 1</em></span>.
</p>
<p>
The final <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a> argument is optional and can
be used to control the behaviour of the function: how it handles errors,
what level of precision to use etc. Refer to the <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">policy
documentation for more details</a>.
</p>
<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>
<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_invb</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">b</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T3</span> <span class="identifier">p</span><span class="special">);</span>
<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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
<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_invb</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">b</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T3</span> <span class="identifier">p</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
</pre>
<p>
Returns a value <span class="emphasis"><em>b</em></span> such that: <code class="computeroutput"><span class="identifier">p</span>
<span class="special">=</span> <span class="identifier">ibeta</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="identifier">x</span><span class="special">);</span></code>
</p>
<p>
Requires: <span class="emphasis"><em>a &gt; 0</em></span>, <span class="emphasis"><em>0 &lt; x &lt; 1</em></span>
and <span class="emphasis"><em>0 &lt;= p &lt;= 1</em></span>.
</p>
<p>
The final <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a> argument is optional and can
be used to control the behaviour of the function: how it handles errors,
what level of precision to use etc. Refer to the <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">policy
documentation for more details</a>.
</p>
<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>
<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_invb</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">b</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T3</span> <span class="identifier">p</span><span class="special">);</span>
<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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
<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_invb</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">b</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T3</span> <span class="identifier">p</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
</pre>
<p>
Returns a value <span class="emphasis"><em>b</em></span> such that: <code class="computeroutput"><span class="identifier">q</span>
<span class="special">=</span> <span class="identifier">ibetac</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="identifier">x</span><span class="special">);</span></code>
</p>
<p>
Requires: <span class="emphasis"><em>a &gt; 0</em></span>, <span class="emphasis"><em>0 &lt; x &lt; 1</em></span>
and <span class="emphasis"><em>0 &lt;= q &lt;= 1</em></span>.
</p>
<p>
The final <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a> argument is optional and can
be used to control the behaviour of the function: how it handles errors,
what level of precision to use etc. Refer to the <a class="link" href="../../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">policy
documentation for more details</a>.
</p>
<h5>
<a name="math_toolkit.sf_beta.ibeta_inv_function.h1"></a>
<span class="phrase"><a name="math_toolkit.sf_beta.ibeta_inv_function.accuracy"></a></span><a class="link" href="ibeta_inv_function.html#math_toolkit.sf_beta.ibeta_inv_function.accuracy">Accuracy</a>
</h5>
<p>
The accuracy of these functions should closely follow that of the regular
forward incomplete beta functions. However, note that in some parts of their
domain, these functions can be extremely sensitive to changes in input, particularly
when the argument <span class="emphasis"><em>p</em></span> (or it's complement <span class="emphasis"><em>q</em></span>)
is very close to <code class="computeroutput"><span class="number">0</span></code> or <code class="computeroutput"><span class="number">1</span></code>.
</p>
<p>
Comparisons to other libraries are shown below, note that our test data exercises
some rather extreme cases in the incomplete beta function which many other
libraries fail to handle:
</p>
<div class="table">
<a name="math_toolkit.sf_beta.ibeta_inv_function.table_ibeta_inv"></a><p class="title"><b>Table&#160;6.22.&#160;Error rates for ibeta_inv</b></p>
<div class="table-contents"><table class="table" summary="Error rates for ibeta_inv">
<colgroup>
<col>
<col>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
</th>
<th>
<p>
Microsoft Visual C++ version 12.0<br> Win32<br> double
</p>
</th>
<th>
<p>
GNU C++ version 5.1.0<br> linux<br> double
</p>
</th>
<th>
<p>
GNU C++ version 5.1.0<br> linux<br> long double
</p>
</th>
<th>
<p>
Sun compiler version 0x5130<br> Sun Solaris<br> long double
</p>
</th>
</tr></thead>
<tbody><tr>
<td>
<p>
Inverse incomplete beta
</p>
</td>
<td>
<p>
<span class="blue">Max = 7.08e+003&#949; (Mean = 244&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 3.21&#949; (Mean = 0.158&#949;)</span><br> <br>
(<span class="emphasis"><em>Rmath 3.0.2:</em></span> <span class="red">Max = +INF&#949; (Mean
= +INF&#949;) <a class="link" href="../logs_and_tables/logs.html#errors_GNU_C_version_5_1_0_linux_double_ibeta_inv_Rmath_3_0_2_Inverse_incomplete_beta">And
other failures.</a>)</span><br> (<span class="emphasis"><em>Cephes:</em></span>
<span class="red">Max = 1.28e+10&#949; (Mean = 5.17e+08&#949;))</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 4.53e+04&#949; (Mean = 2.93e+03&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 4.22e+04&#949; (Mean = 2.8e+03&#949;)</span>
</p>
</td>
</tr></tbody>
</table></div>
</div>
<br class="table-break"><div class="table">
<a name="math_toolkit.sf_beta.ibeta_inv_function.table_ibetac_inv"></a><p class="title"><b>Table&#160;6.23.&#160;Error rates for ibetac_inv</b></p>
<div class="table-contents"><table class="table" summary="Error rates for ibetac_inv">
<colgroup>
<col>
<col>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
</th>
<th>
<p>
Microsoft Visual C++ version 12.0<br> Win32<br> double
</p>
</th>
<th>
<p>
GNU C++ version 5.1.0<br> linux<br> double
</p>
</th>
<th>
<p>
GNU C++ version 5.1.0<br> linux<br> long double
</p>
</th>
<th>
<p>
Sun compiler version 0x5130<br> Sun Solaris<br> long double
</p>
</th>
</tr></thead>
<tbody><tr>
<td>
<p>
Inverse incomplete beta
</p>
</td>
<td>
<p>
<span class="blue">Max = 5.53e+003&#949; (Mean = 220&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 1.71&#949; (Mean = 0.108&#949;)</span><br> <br>
(<span class="emphasis"><em>Rmath 3.0.2:</em></span> <span class="red">Max = +INF&#949; (Mean
= +INF&#949;) <a class="link" href="../logs_and_tables/logs.html#errors_GNU_C_version_5_1_0_linux_double_ibetac_inv_Rmath_3_0_2_Inverse_incomplete_beta">And
other failures.</a>)</span><br> (<span class="emphasis"><em>Cephes:</em></span>
Max = 1.71&#949; (Mean = 0.108&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 6.17e+04&#949; (Mean = 3.77e+03&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 5.15e+04&#949; (Mean = 3.51e+03&#949;)</span>
</p>
</td>
</tr></tbody>
</table></div>
</div>
<br class="table-break"><div class="table">
<a name="math_toolkit.sf_beta.ibeta_inv_function.table_ibeta_inva"></a><p class="title"><b>Table&#160;6.24.&#160;Error rates for ibeta_inva</b></p>
<div class="table-contents"><table class="table" summary="Error rates for ibeta_inva">
<colgroup>
<col>
<col>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
</th>
<th>
<p>
Microsoft Visual C++ version 12.0<br> Win32<br> double
</p>
</th>
<th>
<p>
GNU C++ version 5.1.0<br> linux<br> double
</p>
</th>
<th>
<p>
GNU C++ version 5.1.0<br> linux<br> long double
</p>
</th>
<th>
<p>
Sun compiler version 0x5130<br> Sun Solaris<br> long double
</p>
</th>
</tr></thead>
<tbody><tr>
<td>
<p>
Inverse incomplete beta
</p>
</td>
<td>
<p>
<span class="blue">Max = 395&#949; (Mean = 24.7&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.602&#949; (Mean = 0.0239&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 377&#949; (Mean = 25.1&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 438&#949; (Mean = 31.6&#949;)</span>
</p>
</td>
</tr></tbody>
</table></div>
</div>
<br class="table-break"><div class="table">
<a name="math_toolkit.sf_beta.ibeta_inv_function.table_ibetac_inva"></a><p class="title"><b>Table&#160;6.25.&#160;Error rates for ibetac_inva</b></p>
<div class="table-contents"><table class="table" summary="Error rates for ibetac_inva">
<colgroup>
<col>
<col>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
</th>
<th>
<p>
Microsoft Visual C++ version 12.0<br> Win32<br> double
</p>
</th>
<th>
<p>
GNU C++ version 5.1.0<br> linux<br> double
</p>
</th>
<th>
<p>
GNU C++ version 5.1.0<br> linux<br> long double
</p>
</th>
<th>
<p>
Sun compiler version 0x5130<br> Sun Solaris<br> long double
</p>
</th>
</tr></thead>
<tbody><tr>
<td>
<p>
Inverse incomplete beta
</p>
</td>
<td>
<p>
<span class="blue">Max = 408&#949; (Mean = 27.8&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.683&#949; (Mean = 0.0271&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 382&#949; (Mean = 22.2&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 315&#949; (Mean = 23.7&#949;)</span>
</p>
</td>
</tr></tbody>
</table></div>
</div>
<br class="table-break"><div class="table">
<a name="math_toolkit.sf_beta.ibeta_inv_function.table_ibeta_invb"></a><p class="title"><b>Table&#160;6.26.&#160;Error rates for ibeta_invb</b></p>
<div class="table-contents"><table class="table" summary="Error rates for ibeta_invb">
<colgroup>
<col>
<col>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
</th>
<th>
<p>
Microsoft Visual C++ version 12.0<br> Win32<br> double
</p>
</th>
<th>
<p>
GNU C++ version 5.1.0<br> linux<br> double
</p>
</th>
<th>
<p>
GNU C++ version 5.1.0<br> linux<br> long double
</p>
</th>
<th>
<p>
Sun compiler version 0x5130<br> Sun Solaris<br> long double
</p>
</th>
</tr></thead>
<tbody><tr>
<td>
<p>
Inverse incomplete beta
</p>
</td>
<td>
<p>
<span class="blue">Max = 409&#949; (Mean = 17.9&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.836&#949; (Mean = 0.0491&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 407&#949; (Mean = 27.2&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 407&#949; (Mean = 24.4&#949;)</span>
</p>
</td>
</tr></tbody>
</table></div>
</div>
<br class="table-break"><div class="table">
<a name="math_toolkit.sf_beta.ibeta_inv_function.table_ibetac_invb"></a><p class="title"><b>Table&#160;6.27.&#160;Error rates for ibetac_invb</b></p>
<div class="table-contents"><table class="table" summary="Error rates for ibetac_invb">
<colgroup>
<col>
<col>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
</th>
<th>
<p>
Microsoft Visual C++ version 12.0<br> Win32<br> double
</p>
</th>
<th>
<p>
GNU C++ version 5.1.0<br> linux<br> double
</p>
</th>
<th>
<p>
GNU C++ version 5.1.0<br> linux<br> long double
</p>
</th>
<th>
<p>
Sun compiler version 0x5130<br> Sun Solaris<br> long double
</p>
</th>
</tr></thead>
<tbody><tr>
<td>
<p>
Inverse incomplete beta
</p>
</td>
<td>
<p>
<span class="blue">Max = 329&#949; (Mean = 18.2&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.724&#949; (Mean = 0.0303&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 317&#949; (Mean = 19.7&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 369&#949; (Mean = 21.7&#949;)</span>
</p>
</td>
</tr></tbody>
</table></div>
</div>
<br class="table-break"><h5>
<a name="math_toolkit.sf_beta.ibeta_inv_function.h2"></a>
<span class="phrase"><a name="math_toolkit.sf_beta.ibeta_inv_function.testing"></a></span><a class="link" href="ibeta_inv_function.html#math_toolkit.sf_beta.ibeta_inv_function.testing">Testing</a>
</h5>
<p>
There are two sets of tests:
</p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
Basic sanity checks attempt to "round-trip" from <span class="emphasis"><em>a,
b</em></span> and <span class="emphasis"><em>x</em></span> to <span class="emphasis"><em>p</em></span> or
<span class="emphasis"><em>q</em></span> and back again. These tests have quite generous
tolerances: in general both the incomplete beta and its inverses change
so rapidly, that round tripping to more than a couple of significant
digits isn't possible. This is especially true when <span class="emphasis"><em>p</em></span>
or <span class="emphasis"><em>q</em></span> is very near one: in this case there isn't
enough "information content" in the input to the inverse function
to get back where you started.
</li>
<li class="listitem">
Accuracy checks using high precision test values. These measure the accuracy
of the result, given exact input values.
</li>
</ul></div>
<h5>
<a name="math_toolkit.sf_beta.ibeta_inv_function.h3"></a>
<span class="phrase"><a name="math_toolkit.sf_beta.ibeta_inv_function.implementation_of_ibeta_inv_and_"></a></span><a class="link" href="ibeta_inv_function.html#math_toolkit.sf_beta.ibeta_inv_function.implementation_of_ibeta_inv_and_">Implementation
of ibeta_inv and ibetac_inv</a>
</h5>
<p>
These two functions share a common implementation.
</p>
<p>
First an initial approximation to x is computed then the last few bits are
cleaned up using <a href="http://en.wikipedia.org/wiki/Simple_rational_approximation" target="_top">Halley
iteration</a>. The iteration limit is set to 1/2 of the number of bits
in T, which by experiment is sufficient to ensure that the inverses are at
least as accurate as the normal incomplete beta functions. Up to 5 iterations
may be required in extreme cases, although normally only one or two are required.
Further, the number of iterations required decreases with increasing <span class="emphasis"><em>a</em></span>
and <span class="emphasis"><em>b</em></span> (which generally form the more important use cases).
</p>
<p>
The initial guesses used for iteration are obtained as follows:
</p>
<p>
Firstly recall that:
</p>
<p>
<span class="inlinemediaobject"><img src="../../../equations/ibeta_inv5.svg"></span>
</p>
<p>
We may wish to start from either p or q, and to calculate either x or y.
In addition at any stage we can exchange a for b, p for q, and x for y if
it results in a more manageable problem.
</p>
<p>
For <code class="computeroutput"><span class="identifier">a</span><span class="special">+</span><span class="identifier">b</span> <span class="special">&gt;=</span> <span class="number">5</span></code> the initial guess is computed using the methods
described in:
</p>
<p>
Asymptotic Inversion of the Incomplete Beta Function, by N. M. <a href="http://homepages.cwi.nl/~nicot/" target="_top">Temme</a>.
Journal of Computational and Applied Mathematics 41 (1992) 145-157.
</p>
<p>
The nearly symmetrical case (section 2 of the paper) is used for
</p>
<p>
<span class="inlinemediaobject"><img src="../../../equations/ibeta_inv2.svg"></span>
</p>
<p>
and involves solving the inverse error function first. The method is accurate
to at least 2 decimal digits when <code class="literal">a = 5</code> rising to at least
8 digits when <code class="literal">a = 10<sup>5</sup></code>.
</p>
<p>
The general error function case (section 3 of the paper) is used for
</p>
<p>
<span class="inlinemediaobject"><img src="../../../equations/ibeta_inv3.svg"></span>
</p>
<p>
and again expresses the inverse incomplete beta in terms of the inverse of
the error function. The method is accurate to at least 2 decimal digits when
<code class="literal">a+b = 5</code> rising to 11 digits when <code class="literal">a+b = 10<sup>5</sup></code>.
However, when the result is expected to be very small, and when a+b is also
small, then its accuracy tails off, in this case when p<sup>1/a</sup> &lt; 0.0025 then
it is better to use the following as an initial estimate:
</p>
<p>
<span class="inlinemediaobject"><img src="../../../equations/ibeta_inv4.svg"></span>
</p>
<p>
Finally the for all other cases where <code class="computeroutput"><span class="identifier">a</span><span class="special">+</span><span class="identifier">b</span> <span class="special">&gt;</span>
<span class="number">5</span></code> the method of section 4 of the paper
is used. This expresses the inverse incomplete beta in terms of the inverse
of the incomplete gamma function, and is therefore significantly more expensive
to compute than the other cases. However the method is accurate to at least
3 decimal digits when <code class="literal">a = 5</code> rising to at least 10 digits
when <code class="literal">a = 10<sup>5</sup></code>. This method is limited to a &gt; b, and
therefore we need to perform an exchange a for b, p for q and x for y when
this is not the case. In addition when p is close to 1 the method is inaccurate
should we actually want y rather than x as output. Therefore when q is small
(<code class="literal">q<sup>1/p</sup> &lt; 10<sup>-3</sup></code>) we use:
</p>
<p>
<span class="inlinemediaobject"><img src="../../../equations/ibeta_inv6.svg"></span>
</p>
<p>
which is both cheaper to compute than the full method, and a more accurate
estimate on q.
</p>
<p>
When a and b are both small there is a distinct lack of information in the
literature on how to proceed. I am extremely grateful to Prof Nico Temme
who provided the following information with a great deal of patience and
explanation on his part. Any errors that follow are entirely my own, and
not Prof Temme's.
</p>
<p>
When a and b are both less than 1, then there is a point of inflection in
the incomplete beta at point <code class="computeroutput"><span class="identifier">xs</span>
<span class="special">=</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="special">/</span> <span class="special">(</span><span class="number">2</span> <span class="special">-</span> <span class="identifier">a</span>
<span class="special">-</span> <span class="identifier">b</span><span class="special">)</span></code>. Therefore if <code class="literal">p &gt; I<sub>x</sub>(a,b)</code>
we swap a for b, p for q and x for y, so that now we always look for a point
x below the point of inflection <code class="computeroutput"><span class="identifier">xs</span></code>,
and on a convex curve. An initial estimate for x is made with:
</p>
<p>
<span class="inlinemediaobject"><img src="../../../equations/ibeta_inv7.svg"></span>
</p>
<p>
which is provably below the true value for x: <a href="http://en.wikipedia.org/wiki/Newton%27s_method" target="_top">Newton
iteration</a> will therefore smoothly converge on x without problems
caused by overshooting etc.
</p>
<p>
When a and b are both greater than 1, but a+b is too small to use the other
methods mentioned above, we proceed as follows. Observe that there is a point
of inflection in the incomplete beta at <code class="computeroutput"><span class="identifier">xs</span>
<span class="special">=</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="special">/</span> <span class="special">(</span><span class="number">2</span> <span class="special">-</span> <span class="identifier">a</span>
<span class="special">-</span> <span class="identifier">b</span><span class="special">)</span></code>. Therefore if <code class="literal">p &gt; I<sub>x</sub>(a,b)</code>
we swap a for b, p for q and x for y, so that now we always look for a point
x below the point of inflection <code class="computeroutput"><span class="identifier">xs</span></code>,
and on a concave curve. An initial estimate for x is made with:
</p>
<p>
<span class="inlinemediaobject"><img src="../../../equations/ibeta_inv4.svg"></span>
</p>
<p>
which can be improved somewhat to:
</p>
<p>
<span class="inlinemediaobject"><img src="../../../equations/ibeta_inv1.svg"></span>
</p>
<p>
when b and x are both small (I've used b &lt; a and x &lt; 0.2). This actually
under-estimates x, which drops us on the wrong side of x for Newton iteration
to converge monotonically. However, use of higher derivatives and Halley
iteration keeps everything under control.
</p>
<p>
The final case to be considered if when one of a and b is less than or equal
to 1, and the other greater that 1. Here, if b &lt; a we swap a for b, p
for q and x for y. Now the curve of the incomplete beta is convex with no
points of inflection in [0,1]. For small p, x can be estimated using
</p>
<p>
<span class="inlinemediaobject"><img src="../../../equations/ibeta_inv4.svg"></span>
</p>
<p>
which under-estimates x, and drops us on the right side of the true value
for Newton iteration to converge monotonically. However, when p is large
this can quite badly underestimate x. This is especially an issue when we
really want to find y, in which case this method can be an arbitrary number
of order of magnitudes out, leading to very poor convergence during iteration.
</p>
<p>
Things can be improved by considering the incomplete beta as a distorted
quarter circle, and estimating y from:
</p>
<p>
<span class="inlinemediaobject"><img src="../../../equations/ibeta_inv8.svg"></span>
</p>
<p>
This doesn't guarantee that we will drop in on the right side of x for monotonic
convergence, but it does get us close enough that Halley iteration rapidly
converges on the true value.
</p>
<h5>
<a name="math_toolkit.sf_beta.ibeta_inv_function.h4"></a>
<span class="phrase"><a name="math_toolkit.sf_beta.ibeta_inv_function.implementation_of_inverses_on_th"></a></span><a class="link" href="ibeta_inv_function.html#math_toolkit.sf_beta.ibeta_inv_function.implementation_of_inverses_on_th">Implementation
of inverses on the a and b parameters</a>
</h5>
<p>
These four functions share a common implementation.
</p>
<p>
First an initial approximation is computed for <span class="emphasis"><em>a</em></span> or
<span class="emphasis"><em>b</em></span>: where possible this uses a Cornish-Fisher expansion
for the negative binomial distribution to get within around 1 of the result.
However, when <span class="emphasis"><em>a</em></span> or <span class="emphasis"><em>b</em></span> are very small
the Cornish Fisher expansion is not usable, in this case the initial approximation
is chosen so that I<sub>x</sub>(a, b) is near the middle of the range [0,1].
</p>
<p>
This initial guess is then used as a starting value for a generic root finding
algorithm. The algorithm converges rapidly on the root once it has been bracketed,
but bracketing the root may take several iterations. A better initial approximation
for <span class="emphasis"><em>a</em></span> or <span class="emphasis"><em>b</em></span> would improve these
functions quite substantially: currently 10-20 incomplete beta function invocations
are required to find the root.
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2006-2010, 2012-2014, 2017 Nikhar
Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan R&#229;de, Gautam
Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg, Daryle Walker
and Xiaogang Zhang<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
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>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="ibeta_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="beta_derivative.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>