mirror of
https://github.com/boostorg/math.git
synced 2026-01-27 07:02:08 +00:00
980 lines
46 KiB
HTML
980 lines
46 KiB
HTML
<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.78.1">
|
|
<link rel="home" href="../../index.html" title="Math Toolkit 1.9.0">
|
|
<link rel="up" href="../sf_beta.html" title="Beta Functions">
|
|
<link rel="prev" href="beta_function.html" title="Beta">
|
|
<link rel="next" href="ibeta_inv_function.html" title="The Incomplete Beta Function Inverses">
|
|
</head>
|
|
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|
<table cellpadding="2" width="100%"><tr>
|
|
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
|
|
<td align="center"><a href="../../../../../../index.html">Home</a></td>
|
|
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
|
|
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
|
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
|
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
|
|
</tr></table>
|
|
<hr>
|
|
<div class="spirit-nav">
|
|
<a accesskey="p" href="beta_function.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../sf_beta.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="ibeta_inv_function.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
|
</div>
|
|
<div class="section">
|
|
<div class="titlepage"><div><div><h3 class="title">
|
|
<a name="math_toolkit.sf_beta.ibeta_function"></a><a class="link" href="ibeta_function.html" title="Incomplete Beta Functions">Incomplete Beta
|
|
Functions</a>
|
|
</h3></div></div></div>
|
|
<h5>
|
|
<a name="math_toolkit.sf_beta.ibeta_function.h0"></a>
|
|
<span class="phrase"><a name="math_toolkit.sf_beta.ibeta_function.synopsis"></a></span><a class="link" href="ibeta_function.html#math_toolkit.sf_beta.ibeta_function.synopsis">Synopsis</a>
|
|
</h5>
|
|
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</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 14. 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 14. 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 14. 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 14. 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 14. 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 14. 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 14. 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 14. 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 14. 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 14. 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 14. 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 14. 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.png"></span>
|
|
</p>
|
|
<p>
|
|
<span class="inlinemediaobject"><img src="../../../graphs/ibeta.png" 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 14. 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 14. 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.png"></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 14. 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 14. 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.png"></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 14. 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 14. 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.png"></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.errors_in_the_function_ibeta_a_b"></a><p class="title"><b>Table 6.8. Errors In the Function ibeta(a,b,x)</b></p>
|
|
<div class="table-contents"><table class="table" summary="Errors In the Function ibeta(a,b,x)">
|
|
<colgroup>
|
|
<col>
|
|
<col>
|
|
<col>
|
|
<col>
|
|
<col>
|
|
</colgroup>
|
|
<thead><tr>
|
|
<th>
|
|
<p>
|
|
Significand Size
|
|
</p>
|
|
</th>
|
|
<th>
|
|
<p>
|
|
Platform and Compiler
|
|
</p>
|
|
</th>
|
|
<th>
|
|
<p>
|
|
0 < a,b < 10
|
|
</p>
|
|
<p>
|
|
and
|
|
</p>
|
|
<p>
|
|
0 < x < 1
|
|
</p>
|
|
</th>
|
|
<th>
|
|
<p>
|
|
0 < a,b < 100
|
|
</p>
|
|
<p>
|
|
and
|
|
</p>
|
|
<p>
|
|
0 < x < 1
|
|
</p>
|
|
</th>
|
|
<th>
|
|
<p>
|
|
1x10<sup>-5</sup> < a,b < 1x10<sup>5</sup>
|
|
</p>
|
|
<p>
|
|
and
|
|
</p>
|
|
<p>
|
|
0 < x < 1
|
|
</p>
|
|
</th>
|
|
</tr></thead>
|
|
<tbody>
|
|
<tr>
|
|
<td>
|
|
<p>
|
|
53
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Win32, Visual C++ 8
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak=42.3 Mean=2.9
|
|
</p>
|
|
<p>
|
|
(GSL Peak=682 Mean=32.5)
|
|
</p>
|
|
<p>
|
|
(<a href="http://www.netlib.org/cephes/" target="_top">Cephes</a> Peak=42.7
|
|
Mean=7.0)
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak=108 Mean=16.6
|
|
</p>
|
|
<p>
|
|
(GSL Peak=690 Mean=151)
|
|
</p>
|
|
<p>
|
|
(<a href="http://www.netlib.org/cephes/" target="_top">Cephes</a> Peak=1545
|
|
Mean=218)
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak=4x10<sup>3</sup>   Mean=203
|
|
</p>
|
|
<p>
|
|
(GSL Peak~3x10<sup>5</sup>   Mean~2x10<sup>4</sup>  )
|
|
</p>
|
|
<p>
|
|
(<a href="http://www.netlib.org/cephes/" target="_top">Cephes</a> Peak~5x10<sup>5</sup>   Mean~2x10<sup>4</sup>  )
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<p>
|
|
64
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Redhat Linux IA32, gcc-3.4.4
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak=21.9 Mean=3.1
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak=270.7 Mean=26.8
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak~5x10<sup>4</sup>   Mean=3x10<sup>3</sup>  
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<p>
|
|
64
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Redhat Linux IA64, gcc-3.4.4
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak=15.4 Mean=3.0
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak=112.9 Mean=14.3
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak~5x10<sup>4</sup>   Mean=3x10<sup>3</sup>  
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<p>
|
|
113
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
HPUX IA64, aCC A.06.06
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak=20.9 Mean=2.6
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak=88.1 Mean=14.3
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak~2x10<sup>4</sup>   Mean=1x10<sup>3</sup>  
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table></div>
|
|
</div>
|
|
<br class="table-break"><div class="table">
|
|
<a name="math_toolkit.sf_beta.ibeta_function.errors_in_the_function_ibetac_a_"></a><p class="title"><b>Table 6.9. Errors In the Function ibetac(a,b,x)</b></p>
|
|
<div class="table-contents"><table class="table" summary="Errors In the Function ibetac(a,b,x)">
|
|
<colgroup>
|
|
<col>
|
|
<col>
|
|
<col>
|
|
<col>
|
|
<col>
|
|
</colgroup>
|
|
<thead><tr>
|
|
<th>
|
|
<p>
|
|
Significand Size
|
|
</p>
|
|
</th>
|
|
<th>
|
|
<p>
|
|
Platform and Compiler
|
|
</p>
|
|
</th>
|
|
<th>
|
|
<p>
|
|
0 < a,b < 10
|
|
</p>
|
|
<p>
|
|
and
|
|
</p>
|
|
<p>
|
|
0 < x < 1
|
|
</p>
|
|
</th>
|
|
<th>
|
|
<p>
|
|
0 < a,b < 100
|
|
</p>
|
|
<p>
|
|
and
|
|
</p>
|
|
<p>
|
|
0 < x < 1
|
|
</p>
|
|
</th>
|
|
<th>
|
|
<p>
|
|
1x10<sup>-5</sup> < a,b < 1x10<sup>5</sup>
|
|
</p>
|
|
<p>
|
|
and
|
|
</p>
|
|
<p>
|
|
0 < x < 1
|
|
</p>
|
|
</th>
|
|
</tr></thead>
|
|
<tbody>
|
|
<tr>
|
|
<td>
|
|
<p>
|
|
53
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Win32, Visual C++ 8
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak=13.9 Mean=2.0
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak=56.2 Mean=14
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak=3x10<sup>3</sup>   Mean=159
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<p>
|
|
64
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Redhat Linux IA32, gcc-3.4.4
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak=21.1 Mean=3.6
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak=221.7 Mean=25.8
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak~9x10<sup>4</sup>   Mean=3x10<sup>3</sup>  
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<p>
|
|
64
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Redhat Linux IA64, gcc-3.4.4
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak=10.6 Mean=2.2
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak=73.9 Mean=11.9
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak~9x10<sup>4</sup>   Mean=3x10<sup>3</sup>  
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<p>
|
|
113
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
HPUX IA64, aCC A.06.06
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak=9.9 Mean=2.6
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak=117.7 Mean=15.1
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak~3x10<sup>4</sup>   Mean=1x10<sup>3</sup>  
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table></div>
|
|
</div>
|
|
<br class="table-break"><div class="table">
|
|
<a name="math_toolkit.sf_beta.ibeta_function.errors_in_the_function_beta_a_b_"></a><p class="title"><b>Table 6.10. Errors In the Function beta(a, b, x)</b></p>
|
|
<div class="table-contents"><table class="table" summary="Errors In the Function beta(a, b, x)">
|
|
<colgroup>
|
|
<col>
|
|
<col>
|
|
<col>
|
|
<col>
|
|
<col>
|
|
</colgroup>
|
|
<thead><tr>
|
|
<th>
|
|
<p>
|
|
Significand Size
|
|
</p>
|
|
</th>
|
|
<th>
|
|
<p>
|
|
Platform and Compiler
|
|
</p>
|
|
</th>
|
|
<th>
|
|
<p>
|
|
0 < a,b < 10
|
|
</p>
|
|
<p>
|
|
and
|
|
</p>
|
|
<p>
|
|
0 < x < 1
|
|
</p>
|
|
</th>
|
|
<th>
|
|
<p>
|
|
0 < a,b < 100
|
|
</p>
|
|
<p>
|
|
and
|
|
</p>
|
|
<p>
|
|
0 < x < 1
|
|
</p>
|
|
</th>
|
|
<th>
|
|
<p>
|
|
1x10<sup>-5</sup> < a,b < 1x10<sup>5</sup>
|
|
</p>
|
|
<p>
|
|
and
|
|
</p>
|
|
<p>
|
|
0 < x < 1
|
|
</p>
|
|
</th>
|
|
</tr></thead>
|
|
<tbody>
|
|
<tr>
|
|
<td>
|
|
<p>
|
|
53
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Win32, Visual C++ 8
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak=39 Mean=2.9
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak=91 Mean=12.7
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak=635 Mean=25
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<p>
|
|
64
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Redhat Linux IA32, gcc-3.4.4
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak=26 Mean=3.6
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak=180.7 Mean=30.1
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak~7x10<sup>4</sup>   Mean=3x10<sup>3</sup>  
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<p>
|
|
64
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Redhat Linux IA64, gcc-3.4.4
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak=13 Mean=2.4
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak=67.1 Mean=13.4
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak~7x10<sup>4</sup>   Mean=3x10<sup>3</sup>  
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<p>
|
|
113
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
HPUX IA64, aCC A.06.06
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak=27.3 Mean=3.6
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak=49.8 Mean=9.1
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak~6x10<sup>4</sup>   Mean=3x10<sup>3</sup>  
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table></div>
|
|
</div>
|
|
<br class="table-break"><div class="table">
|
|
<a name="math_toolkit.sf_beta.ibeta_function.errors_in_the_function_betac_a_b"></a><p class="title"><b>Table 6.11. Errors In the Function betac(a,b,x)</b></p>
|
|
<div class="table-contents"><table class="table" summary="Errors In the Function betac(a,b,x)">
|
|
<colgroup>
|
|
<col>
|
|
<col>
|
|
<col>
|
|
<col>
|
|
<col>
|
|
</colgroup>
|
|
<thead><tr>
|
|
<th>
|
|
<p>
|
|
Significand Size
|
|
</p>
|
|
</th>
|
|
<th>
|
|
<p>
|
|
Platform and Compiler
|
|
</p>
|
|
</th>
|
|
<th>
|
|
<p>
|
|
0 < a,b < 10
|
|
</p>
|
|
<p>
|
|
and
|
|
</p>
|
|
<p>
|
|
0 < x < 1
|
|
</p>
|
|
</th>
|
|
<th>
|
|
<p>
|
|
0 < a,b < 100
|
|
</p>
|
|
<p>
|
|
and
|
|
</p>
|
|
<p>
|
|
0 < x < 1
|
|
</p>
|
|
</th>
|
|
<th>
|
|
<p>
|
|
1x10<sup>-5</sup> < a,b < 1x10<sup>5</sup>
|
|
</p>
|
|
<p>
|
|
and
|
|
</p>
|
|
<p>
|
|
0 < x < 1
|
|
</p>
|
|
</th>
|
|
</tr></thead>
|
|
<tbody>
|
|
<tr>
|
|
<td>
|
|
<p>
|
|
53
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Win32, Visual C++ 8
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak=12.0 Mean=2.4
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak=91 Mean=15
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak=4x10<sup>3</sup>   Mean=113
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<p>
|
|
64
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Redhat Linux IA32, gcc-3.4.4
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak=19.8 Mean=3.8
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak=295.1 Mean=33.9
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak~1x10<sup>5</sup>   Mean=5x10<sup>3</sup>  
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<p>
|
|
64
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Redhat Linux IA64, gcc-3.4.4
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak=11.2 Mean=2.4
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak=63.5 Mean=13.6
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak~1x10<sup>5</sup>   Mean=5x10<sup>3</sup>  
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<p>
|
|
113
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
HPUX IA64, aCC A.06.06
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak=15.6 Mean=3.5
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak=39.8 Mean=8.9
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Peak~9x10<sup>4</sup>   Mean=5x10<sup>3</sup>  
|
|
</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.png"></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.png"></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.png"></span>
|
|
</p>
|
|
<p>
|
|
For smallish b and x then a series representation can be used:
|
|
</p>
|
|
<p>
|
|
<span class="inlinemediaobject"><img src="../../../equations/ibeta7.png"></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.png"></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.png"></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.png"></span>
|
|
</p>
|
|
<p>
|
|
<span class="inlinemediaobject"><img src="../../../equations/ibeta11.png"></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, 2013 Nikhar Agrawal, Anton Bikineev,
|
|
Paul A. Bristow, Christopher Kormanyos, Hubert Holin, Bruno Lalande, John Maddock,
|
|
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>
|