diff options
| author | Christoph Berg <myon@debian.org> | 2018-12-19 22:58:32 +0100 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2018-12-19 22:58:32 +0100 |
| commit | e0737c56c1e384e05064a0c6e1ac46979371041b (patch) | |
| tree | a0123d694a2d36c43dabdf0a3907392fce11d457 /boost/libs/math/doc/html/math_toolkit/sf_beta | |
| parent | b4aebf2d137b892f53503b13785ecae900062ff7 (diff) | |
New upstream version 2.0.0+repackupstream/2.0.0+repack
Diffstat (limited to 'boost/libs/math/doc/html/math_toolkit/sf_beta')
4 files changed, 2225 insertions, 0 deletions
diff --git a/boost/libs/math/doc/html/math_toolkit/sf_beta/beta_derivative.html b/boost/libs/math/doc/html/math_toolkit/sf_beta/beta_derivative.html new file mode 100644 index 00000000..d759f98a --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/sf_beta/beta_derivative.html @@ -0,0 +1,102 @@ +<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.5.1"> +<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"><</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">></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"><</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> +<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"><</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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</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 15. 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 15. 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 © 2006-2010, 2012-2014 Nikhar Agrawal, + Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert + Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani, + Benjamin Sobotta, 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> diff --git a/boost/libs/math/doc/html/math_toolkit/sf_beta/beta_function.html b/boost/libs/math/doc/html/math_toolkit/sf_beta/beta_function.html new file mode 100644 index 00000000..252486ae --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/sf_beta/beta_function.html @@ -0,0 +1,318 @@ +<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.5.1"> +<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"><</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">></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"><</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> +<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"><</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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</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 15. 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 15. 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 6.17. 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ε (Mean = 0.828ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 2.65ε (Mean = 1.22ε)</span><br> <br> + (<span class="emphasis"><em><tr1/cmath>:</em></span> Max = 11.9ε (Mean = 7.03ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>GSL + 1.16:</em></span> Max = 3.94ε (Mean = 1.44ε))<br> (<span class="emphasis"><em>Rmath + 3.0.2:</em></span> Max = 1.14ε (Mean = 0.601ε))<br> (<span class="emphasis"><em>Cephes:</em></span> + Max = 1.97ε (Mean = 0.934ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 2.86ε (Mean = 1.31ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + Beta Function: Medium Values + </p> + </td> +<td> + <p> + <span class="blue">Max = 99.1ε (Mean = 22.4ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 60.4ε (Mean = 19.4ε)</span><br> <br> + (<span class="emphasis"><em><tr1/cmath>:</em></span> Max = 1.07e+03ε (Mean = + 264ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.978ε (Mean = 0.0578ε)</span><br> + <br> (<span class="emphasis"><em>GSL 1.16:</em></span> Max = 1.18e+03ε (Mean = 238ε))<br> + (<span class="emphasis"><em>Rmath 3.0.2:</em></span> Max = 1.09e+03ε (Mean = 265ε))<br> + (<span class="emphasis"><em>Cephes:</em></span> Max = 1.5e+03ε (Mean = 329ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 107ε (Mean = 24.5ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + Beta Function: Divergent Values + </p> + </td> +<td> + <p> + <span class="blue">Max = 10.7ε (Mean = 2.22ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 10.3ε (Mean = 2.41ε)</span><br> <br> + (<span class="emphasis"><em><tr1/cmath>:</em></span> Max = 128ε (Mean = 23.8ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>GSL + 1.16:</em></span> Max = 12.1ε (Mean = 1.99ε))<br> (<span class="emphasis"><em>Rmath + 3.0.2:</em></span> Max = 176ε (Mean = 28ε))<br> (<span class="emphasis"><em>Cephes:</em></span> + Max = 175ε (Mean = 22ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 19.7ε (Mean = 2.75ε)</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 > 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 © 2006-2010, 2012-2014 Nikhar Agrawal, + Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert + Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani, + Benjamin Sobotta, 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> diff --git a/boost/libs/math/doc/html/math_toolkit/sf_beta/ibeta_function.html b/boost/libs/math/doc/html/math_toolkit/sf_beta/ibeta_function.html new file mode 100644 index 00000000..be444993 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/sf_beta/ibeta_function.html @@ -0,0 +1,893 @@ +<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.5.1"> +<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"><</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">></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"><</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> +<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"><</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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> + +<span class="keyword">template</span> <span class="special"><</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> +<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"><</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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> + +<span class="keyword">template</span> <span class="special"><</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> +<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"><</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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> + +<span class="keyword">template</span> <span class="special"><</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> +<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"><</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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</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 <= x <= 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 >= 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 > 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 15. 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 15. Policies: Controlling Precision, Error Handling etc">policy + documentation for more details</a>. + </p> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</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> +<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"><</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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</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"><</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> +<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"><</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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</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"><</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> +<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"><</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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</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"><</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> +<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"><</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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</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 6.18. 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ε (Mean = 2.24ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>GSL + 1.16:</em></span> Max = 682ε (Mean = 32.6ε))<br> (<span class="emphasis"><em>Rmath + 3.0.2:</em></span> Max = 22.9ε (Mean = 3.35ε))<br> (<span class="emphasis"><em>Cephes:</em></span> + Max = 22.7ε (Mean = 1.69ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 6.27ε (Mean = 1.7ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 21.3ε (Mean = 2.74ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + Incomplete Beta Function: Medium Values + </p> + </td> +<td> + <p> + <span class="blue">Max = 108ε (Mean = 16.3ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>GSL + 1.16:</em></span> Max = 690ε (Mean = 151ε))<br> (<span class="emphasis"><em>Rmath + 3.0.2:</em></span> Max = 232ε (Mean = 27.9ε))<br> (<span class="emphasis"><em>Cephes:</em></span> + Max = 1.55e+03ε (Mean = 121ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 51.4ε (Mean = 12ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 124ε (Mean = 18.4ε)</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ε (Mean = 59.5ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 1.26ε (Mean = 0.063ε)</span><br> <br> + (<span class="emphasis"><em>GSL 1.16:</em></span> Max = 3.9e+05ε (Mean = 1.82e+04ε) + <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ε (Mean = 49.4ε))<br> (<span class="emphasis"><em>Cephes:</em></span> Max + = 5.92e+05ε (Mean = 2.17e+04ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 1.96e+04ε (Mean = 997ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 4.98e+04ε (Mean = 2.07e+03ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + Incomplete Beta Function: Small Integer Values + </p> + </td> +<td> + <p> + <span class="blue">Max = 3.69ε (Mean = 0.765ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>GSL + 1.16:</em></span> Max = 254ε (Mean = 50.9ε))<br> (<span class="emphasis"><em>Rmath + 3.0.2:</em></span> Max = 62.2ε (Mean = 8.95ε))<br> (<span class="emphasis"><em>Cephes:</em></span> + Max = 7.96ε (Mean = 1.3ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 4.45ε (Mean = 0.814ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 44.5ε (Mean = 10.1ε)</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 6.19. 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ε (Mean = 1.88ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>Rmath + 3.0.2:</em></span> Max = 22.4ε (Mean = 3.67ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 8.47ε (Mean = 1.68ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 13.8ε (Mean = 2.69ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + Incomplete Beta Function: Medium Values + </p> + </td> +<td> + <p> + <span class="blue">Max = 56.2ε (Mean = 14.1ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>Rmath + 3.0.2:</em></span> Max = 204ε (Mean = 25.8ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 75.3ε (Mean = 11.3ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 132ε (Mean = 19.8ε)</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ε (Mean = 93.8ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.981ε (Mean = 0.0638ε)</span><br> + <br> (<span class="emphasis"><em>Rmath 3.0.2:</em></span> Max = 889ε (Mean = 68.4ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 3.45e+04ε (Mean = 1.32e+03ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 4.26e+04ε (Mean = 1.54e+03ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + Incomplete Beta Function: Small Integer Values + </p> + </td> +<td> + <p> + <span class="blue">Max = 6.37ε (Mean = 1.03ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>Rmath + 3.0.2:</em></span> Max = 84.6ε (Mean = 18ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 5.34ε (Mean = 1.11ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 107ε (Mean = 17.1ε)</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 6.20. 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ε (Mean = 2.28ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 12.5ε (Mean = 2.01ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 18.7ε (Mean = 3.19ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + Incomplete Beta Function: Medium Values + </p> + </td> +<td> + <p> + <span class="blue">Max = 91.1ε (Mean = 12.7ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.568ε (Mean = 0.0342ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 67.1ε (Mean = 13.3ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 174ε (Mean = 25ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + Incomplete Beta Function: Large and Diverse Values + </p> + </td> +<td> + <p> + <span class="blue">Max = 635ε (Mean = 29.5ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.999ε (Mean = 0.0399ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 6.84e+04ε (Mean = 2.76e+03ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 6.86e+04ε (Mean = 2.79e+03ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + Incomplete Beta Function: Small Integer Values + </p> + </td> +<td> + <p> + <span class="blue">Max = 26.8ε (Mean = 6.61ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.786ε (Mean = 0.0248ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 10.2ε (Mean = 3.49ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 51.8ε (Mean = 11ε)</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 6.21. 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ε (Mean = 2.43ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.676ε (Mean = 0.0302ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 7.75ε (Mean = 1.91ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 12.6ε (Mean = 3.02ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + Incomplete Beta Function: Medium Values + </p> + </td> +<td> + <p> + <span class="blue">Max = 91.3ε (Mean = 14.8ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.949ε (Mean = 0.0944ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 63.5ε (Mean = 13.4ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 97.6ε (Mean = 24.3ε)</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ε (Mean = 113ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 1.12ε (Mean = 0.0458ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 1.05e+05ε (Mean = 5.45e+03ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 1.04e+05ε (Mean = 5.46e+03ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + Incomplete Beta Function: Small Integer Values + </p> + </td> +<td> + <p> + <span class="blue">Max = 26.7ε (Mean = 6.67ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.586ε (Mean = 0.0314ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 10.4ε (Mean = 3.54ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 103ε (Mean = 17.4ε)</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 << 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 © 2006-2010, 2012-2014 Nikhar Agrawal, + Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert + Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani, + Benjamin Sobotta, 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> diff --git a/boost/libs/math/doc/html/math_toolkit/sf_beta/ibeta_inv_function.html b/boost/libs/math/doc/html/math_toolkit/sf_beta/ibeta_inv_function.html new file mode 100644 index 00000000..b0538b9b --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/sf_beta/ibeta_inv_function.html @@ -0,0 +1,912 @@ +<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.5.1"> +<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"><</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">></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"><</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> +<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"><</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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> + +<span class="keyword">template</span> <span class="special"><</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> +<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"><</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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> + +<span class="keyword">template</span> <span class="special"><</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> +<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"><</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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> + +<span class="keyword">template</span> <span class="special"><</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> +<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"><</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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> + +<span class="keyword">template</span> <span class="special"><</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> +<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"><</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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> + +<span class="keyword">template</span> <span class="special"><</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> +<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"><</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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> + +<span class="keyword">template</span> <span class="special"><</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> +<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"><</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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> + +<span class="keyword">template</span> <span class="special"><</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> +<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"><</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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</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 15. 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 15. 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"><</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> +<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"><</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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> + +<span class="keyword">template</span> <span class="special"><</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> +<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"><</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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</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 > 0</em></span> and <span class="emphasis"><em>0 <= p <= 1</em></span>. + </p> +<p> + The final <a class="link" href="../../policy.html" title="Chapter 15. 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 15. Policies: Controlling Precision, Error Handling etc">policy + documentation for more details</a>. + </p> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</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> +<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"><</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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> + +<span class="keyword">template</span> <span class="special"><</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> +<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"><</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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</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 > 0</em></span> and <span class="emphasis"><em>0 <= q <= 1</em></span>. + </p> +<p> + The final <a class="link" href="../../policy.html" title="Chapter 15. 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 15. Policies: Controlling Precision, Error Handling etc">policy + documentation for more details</a>. + </p> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</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> +<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"><</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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</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 > 0</em></span>, <span class="emphasis"><em>0 < x < 1</em></span> + and <span class="emphasis"><em>0 <= p <= 1</em></span>. + </p> +<p> + The final <a class="link" href="../../policy.html" title="Chapter 15. 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 15. Policies: Controlling Precision, Error Handling etc">policy + documentation for more details</a>. + </p> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</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> +<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"><</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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</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 > 0</em></span>, <span class="emphasis"><em>0 < x < 1</em></span> + and <span class="emphasis"><em>0 <= q <= 1</em></span>. + </p> +<p> + The final <a class="link" href="../../policy.html" title="Chapter 15. 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 15. Policies: Controlling Precision, Error Handling etc">policy + documentation for more details</a>. + </p> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</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> +<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"><</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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</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 > 0</em></span>, <span class="emphasis"><em>0 < x < 1</em></span> + and <span class="emphasis"><em>0 <= p <= 1</em></span>. + </p> +<p> + The final <a class="link" href="../../policy.html" title="Chapter 15. 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 15. Policies: Controlling Precision, Error Handling etc">policy + documentation for more details</a>. + </p> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</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> +<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"><</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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</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 > 0</em></span>, <span class="emphasis"><em>0 < x < 1</em></span> + and <span class="emphasis"><em>0 <= q <= 1</em></span>. + </p> +<p> + The final <a class="link" href="../../policy.html" title="Chapter 15. 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 15. 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 6.22. 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ε (Mean = 244ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 3.21ε (Mean = 0.158ε)</span><br> <br> + (<span class="emphasis"><em>Rmath 3.0.2:</em></span> <span class="red">Max = +INFε (Mean + = +INFε) <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ε (Mean = 5.17e+08ε))</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 4.53e+04ε (Mean = 2.93e+03ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 4.22e+04ε (Mean = 2.8e+03ε)</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 6.23. 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ε (Mean = 220ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 1.71ε (Mean = 0.108ε)</span><br> <br> + (<span class="emphasis"><em>Rmath 3.0.2:</em></span> <span class="red">Max = +INFε (Mean + = +INFε) <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ε (Mean = 0.108ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 6.17e+04ε (Mean = 3.77e+03ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 5.15e+04ε (Mean = 3.51e+03ε)</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 6.24. 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ε (Mean = 24.7ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.602ε (Mean = 0.0239ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 377ε (Mean = 25.1ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 438ε (Mean = 31.6ε)</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 6.25. 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ε (Mean = 27.8ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.683ε (Mean = 0.0271ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 382ε (Mean = 22.2ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 315ε (Mean = 23.7ε)</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 6.26. 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ε (Mean = 17.9ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.836ε (Mean = 0.0491ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 407ε (Mean = 27.2ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 407ε (Mean = 24.4ε)</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 6.27. 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ε (Mean = 18.2ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.724ε (Mean = 0.0303ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 317ε (Mean = 19.7ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 369ε (Mean = 21.7ε)</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">>=</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> < 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">></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 > 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> < 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 > 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 > 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 < a and x < 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 < 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 © 2006-2010, 2012-2014 Nikhar Agrawal, + Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert + Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani, + Benjamin Sobotta, 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> |
