1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>Incomplete Gamma Function Inverses</title> 5<link rel="stylesheet" href="../../math.css" type="text/css"> 6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 7<link rel="home" href="../../index.html" title="Math Toolkit 2.12.0"> 8<link rel="up" href="../sf_gamma.html" title="Gamma Functions"> 9<link rel="prev" href="igamma.html" title="Incomplete Gamma Functions"> 10<link rel="next" href="gamma_derivatives.html" title="Derivative of the Incomplete Gamma Function"> 11</head> 12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 13<table cellpadding="2" width="100%"><tr> 14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> 15<td align="center"><a href="../../../../../../index.html">Home</a></td> 16<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> 17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 19<td align="center"><a href="../../../../../../more/index.htm">More</a></td> 20</tr></table> 21<hr> 22<div class="spirit-nav"> 23<a accesskey="p" href="igamma.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../sf_gamma.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="gamma_derivatives.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="section"> 26<div class="titlepage"><div><div><h3 class="title"> 27<a name="math_toolkit.sf_gamma.igamma_inv"></a><a class="link" href="igamma_inv.html" title="Incomplete Gamma Function Inverses">Incomplete Gamma Function 28 Inverses</a> 29</h3></div></div></div> 30<h5> 31<a name="math_toolkit.sf_gamma.igamma_inv.h0"></a> 32 <span class="phrase"><a name="math_toolkit.sf_gamma.igamma_inv.synopsis"></a></span><a class="link" href="igamma_inv.html#math_toolkit.sf_gamma.igamma_inv.synopsis">Synopsis</a> 33 </h5> 34<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">gamma</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 35</pre> 36<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">math</span><span class="special">{</span> 37 38<span class="keyword">template</span> <span class="special"><</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> 39<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">gamma_q_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">q</span><span class="special">);</span> 40 41<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 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> 42<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">gamma_q_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">q</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> 43 44<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> 45<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">gamma_p_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">p</span><span class="special">);</span> 46 47<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 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> 48<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">gamma_p_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">p</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> 49 50<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> 51<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">gamma_q_inva</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">q</span><span class="special">);</span> 52 53<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 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> 54<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">gamma_q_inva</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">q</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> 55 56<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> 57<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">gamma_p_inva</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">p</span><span class="special">);</span> 58 59<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 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> 60<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">gamma_p_inva</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">p</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> 61 62<span class="special">}}</span> <span class="comment">// namespaces</span> 63</pre> 64<h5> 65<a name="math_toolkit.sf_gamma.igamma_inv.h1"></a> 66 <span class="phrase"><a name="math_toolkit.sf_gamma.igamma_inv.description"></a></span><a class="link" href="igamma_inv.html#math_toolkit.sf_gamma.igamma_inv.description">Description</a> 67 </h5> 68<p> 69 There are four <a href="http://mathworld.wolfram.com/IncompleteGammaFunction.html" target="_top">incomplete 70 gamma function</a> inverses which either compute <span class="emphasis"><em>x</em></span> 71 given <span class="emphasis"><em>a</em></span> and <span class="emphasis"><em>p</em></span> or <span class="emphasis"><em>q</em></span>, 72 or else compute <span class="emphasis"><em>a</em></span> given <span class="emphasis"><em>x</em></span> and either 73 <span class="emphasis"><em>p</em></span> or <span class="emphasis"><em>q</em></span>. 74 </p> 75<p> 76 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 77 type calculation rules</em></span></a> when T1 and T2 are different types, 78 otherwise the return type is simply T1. 79 </p> 80<p> 81 The final <a class="link" href="../../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">Policy</a> argument is optional and can 82 be used to control the behaviour of the function: how it handles errors, 83 what level of precision to use etc. Refer to the <a class="link" href="../../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">policy 84 documentation for more details</a>. 85 </p> 86<div class="tip"><table border="0" summary="Tip"> 87<tr> 88<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="../../../../../../doc/src/images/tip.png"></td> 89<th align="left">Tip</th> 90</tr> 91<tr><td align="left" valign="top"> 92<p> 93 When people normally talk about the inverse of the incomplete gamma function, 94 they are talking about inverting on parameter <span class="emphasis"><em>x</em></span>. These 95 are implemented here as <code class="computeroutput"><span class="identifier">gamma_p_inv</span></code> 96 and <code class="computeroutput"><span class="identifier">gamma_q_inv</span></code>, and are 97 by far the most efficient of the inverses presented here. 98 </p> 99<p> 100 The inverse on the <span class="emphasis"><em>a</em></span> parameter finds use in some statistical 101 applications but has to be computed by rather brute force numerical techniques 102 and is consequently several times slower. These are implemented here as 103 <code class="computeroutput"><span class="identifier">gamma_p_inva</span></code> and <code class="computeroutput"><span class="identifier">gamma_q_inva</span></code>. 104 </p> 105</td></tr> 106</table></div> 107<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> 108<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">gamma_q_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">q</span><span class="special">);</span> 109 110<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 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> 111<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">gamma_q_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">q</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> 112</pre> 113<p> 114 Returns a value x such that: <code class="computeroutput"><span class="identifier">q</span> 115 <span class="special">=</span> <span class="identifier">gamma_q</span><span class="special">(</span><span class="identifier">a</span><span class="special">,</span> 116 <span class="identifier">x</span><span class="special">);</span></code> 117 </p> 118<p> 119 Requires: <span class="emphasis"><em>a > 0</em></span> and <span class="emphasis"><em>1 >= p,q >= 0</em></span>. 120 </p> 121<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> 122<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">gamma_p_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">p</span><span class="special">);</span> 123 124<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 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> 125<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">gamma_p_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">p</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> 126</pre> 127<p> 128 Returns a value x such that: <code class="computeroutput"><span class="identifier">p</span> 129 <span class="special">=</span> <span class="identifier">gamma_p</span><span class="special">(</span><span class="identifier">a</span><span class="special">,</span> 130 <span class="identifier">x</span><span class="special">);</span></code> 131 </p> 132<p> 133 Requires: <span class="emphasis"><em>a > 0</em></span> and <span class="emphasis"><em>1 >= p,q >= 0</em></span>. 134 </p> 135<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> 136<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">gamma_q_inva</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">q</span><span class="special">);</span> 137 138<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 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> 139<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">gamma_q_inva</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">q</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> 140</pre> 141<p> 142 Returns a value a such that: <code class="computeroutput"><span class="identifier">q</span> 143 <span class="special">=</span> <span class="identifier">gamma_q</span><span class="special">(</span><span class="identifier">a</span><span class="special">,</span> 144 <span class="identifier">x</span><span class="special">);</span></code> 145 </p> 146<p> 147 Requires: <span class="emphasis"><em>x > 0</em></span> and <span class="emphasis"><em>1 >= p,q >= 0</em></span>. 148 </p> 149<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> 150<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">gamma_p_inva</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">p</span><span class="special">);</span> 151 152<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 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> 153<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">gamma_p_inva</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">p</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> 154</pre> 155<p> 156 Returns a value a such that: <code class="computeroutput"><span class="identifier">p</span> 157 <span class="special">=</span> <span class="identifier">gamma_p</span><span class="special">(</span><span class="identifier">a</span><span class="special">,</span> 158 <span class="identifier">x</span><span class="special">);</span></code> 159 </p> 160<p> 161 Requires: <span class="emphasis"><em>x > 0</em></span> and <span class="emphasis"><em>1 >= p,q >= 0</em></span>. 162 </p> 163<h5> 164<a name="math_toolkit.sf_gamma.igamma_inv.h2"></a> 165 <span class="phrase"><a name="math_toolkit.sf_gamma.igamma_inv.accuracy"></a></span><a class="link" href="igamma_inv.html#math_toolkit.sf_gamma.igamma_inv.accuracy">Accuracy</a> 166 </h5> 167<p> 168 The accuracy of these functions doesn't vary much by platform or by the type 169 T. Given that these functions are computed by iterative methods, they are 170 deliberately "detuned" so as not to be too accurate: it is in any 171 case impossible for these function to be more accurate than the regular forward 172 incomplete gamma functions. In practice, the accuracy of these functions 173 is very similar to that of <a class="link" href="igamma.html" title="Incomplete Gamma Functions">gamma_p</a> 174 and <a class="link" href="igamma.html" title="Incomplete Gamma Functions">gamma_q</a> functions: 175 </p> 176<div class="table"> 177<a name="math_toolkit.sf_gamma.igamma_inv.table_gamma_p_inv"></a><p class="title"><b>Table 8.13. Error rates for gamma_p_inv</b></p> 178<div class="table-contents"><table class="table" summary="Error rates for gamma_p_inv"> 179<colgroup> 180<col> 181<col> 182<col> 183<col> 184<col> 185</colgroup> 186<thead><tr> 187<th> 188 </th> 189<th> 190 <p> 191 GNU C++ version 7.1.0<br> linux<br> double 192 </p> 193 </th> 194<th> 195 <p> 196 GNU C++ version 7.1.0<br> linux<br> long double 197 </p> 198 </th> 199<th> 200 <p> 201 Sun compiler version 0x5150<br> Sun Solaris<br> long double 202 </p> 203 </th> 204<th> 205 <p> 206 Microsoft Visual C++ version 14.1<br> Win32<br> double 207 </p> 208 </th> 209</tr></thead> 210<tbody> 211<tr> 212<td> 213 <p> 214 incomplete gamma inverse(a, z) medium values 215 </p> 216 </td> 217<td> 218 <p> 219 <span class="blue">Max = 0.993ε (Mean = 0.15ε)</span><br> <br> 220 (<span class="emphasis"><em>Rmath 3.2.3:</em></span> Max = 4.88ε (Mean = 0.868ε)) 221 </p> 222 </td> 223<td> 224 <p> 225 <span class="blue">Max = 1.8ε (Mean = 0.406ε)</span> 226 </p> 227 </td> 228<td> 229 <p> 230 <span class="blue">Max = 1.89ε (Mean = 0.466ε)</span> 231 </p> 232 </td> 233<td> 234 <p> 235 <span class="blue">Max = 1.71ε (Mean = 0.34ε)</span> 236 </p> 237 </td> 238</tr> 239<tr> 240<td> 241 <p> 242 incomplete gamma inverse(a, z) large values 243 </p> 244 </td> 245<td> 246 <p> 247 <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>Rmath 248 3.2.3:</em></span> Max = 0.816ε (Mean = 0.0874ε)) 249 </p> 250 </td> 251<td> 252 <p> 253 <span class="blue">Max = 0.509ε (Mean = 0.0447ε)</span> 254 </p> 255 </td> 256<td> 257 <p> 258 <span class="blue">Max = 0.509ε (Mean = 0.0447ε)</span> 259 </p> 260 </td> 261<td> 262 <p> 263 <span class="blue">Max = 0.924ε (Mean = 0.108ε)</span> 264 </p> 265 </td> 266</tr> 267<tr> 268<td> 269 <p> 270 incomplete gamma inverse(a, z) small values 271 </p> 272 </td> 273<td> 274 <p> 275 <span class="blue">Max = 441ε (Mean = 53.9ε)</span><br> <br> 276 (<span class="emphasis"><em>Rmath 3.2.3:</em></span> Max = 547ε (Mean = 61.6ε)) 277 </p> 278 </td> 279<td> 280 <p> 281 <span class="blue">Max = 9.17e+03ε (Mean = 1.45e+03ε)</span> 282 </p> 283 </td> 284<td> 285 <p> 286 <span class="blue">Max = 1.09e+04ε (Mean = 1.3e+03ε)</span> 287 </p> 288 </td> 289<td> 290 <p> 291 <span class="blue">Max = 1.1e+03ε (Mean = 131ε)</span> 292 </p> 293 </td> 294</tr> 295</tbody> 296</table></div> 297</div> 298<br class="table-break"><div class="table"> 299<a name="math_toolkit.sf_gamma.igamma_inv.table_gamma_q_inv"></a><p class="title"><b>Table 8.14. Error rates for gamma_q_inv</b></p> 300<div class="table-contents"><table class="table" summary="Error rates for gamma_q_inv"> 301<colgroup> 302<col> 303<col> 304<col> 305<col> 306<col> 307</colgroup> 308<thead><tr> 309<th> 310 </th> 311<th> 312 <p> 313 GNU C++ version 7.1.0<br> linux<br> double 314 </p> 315 </th> 316<th> 317 <p> 318 GNU C++ version 7.1.0<br> linux<br> long double 319 </p> 320 </th> 321<th> 322 <p> 323 Sun compiler version 0x5150<br> Sun Solaris<br> long double 324 </p> 325 </th> 326<th> 327 <p> 328 Microsoft Visual C++ version 14.1<br> Win32<br> double 329 </p> 330 </th> 331</tr></thead> 332<tbody> 333<tr> 334<td> 335 <p> 336 incomplete gamma inverse(a, z) medium values 337 </p> 338 </td> 339<td> 340 <p> 341 <span class="blue">Max = 0.912ε (Mean = 0.154ε)</span><br> <br> 342 (<span class="emphasis"><em>Rmath 3.2.3:</em></span> Max = 4.66ε (Mean = 0.792ε)) 343 </p> 344 </td> 345<td> 346 <p> 347 <span class="blue">Max = 6.2ε (Mean = 0.627ε)</span> 348 </p> 349 </td> 350<td> 351 <p> 352 <span class="blue">Max = 6.2ε (Mean = 0.683ε)</span> 353 </p> 354 </td> 355<td> 356 <p> 357 <span class="blue">Max = 2.88ε (Mean = 0.469ε)</span> 358 </p> 359 </td> 360</tr> 361<tr> 362<td> 363 <p> 364 incomplete gamma inverse(a, z) large values 365 </p> 366 </td> 367<td> 368 <p> 369 <span class="blue">Max = 0.894ε (Mean = 0.0915ε)</span><br> 370 <br> (<span class="emphasis"><em>Rmath 3.2.3:</em></span> Max = 0.894ε (Mean = 0.106ε)) 371 </p> 372 </td> 373<td> 374 <p> 375 <span class="blue">Max = 0ε (Mean = 0ε)</span> 376 </p> 377 </td> 378<td> 379 <p> 380 <span class="blue">Max = 0ε (Mean = 0ε)</span> 381 </p> 382 </td> 383<td> 384 <p> 385 <span class="blue">Max = 0.814ε (Mean = 0.0856ε)</span> 386 </p> 387 </td> 388</tr> 389<tr> 390<td> 391 <p> 392 incomplete gamma inverse(a, z) small values 393 </p> 394 </td> 395<td> 396 <p> 397 <span class="blue">Max = 292ε (Mean = 36.4ε)</span><br> <br> 398 (<span class="emphasis"><em>Rmath 3.2.3:</em></span> Max = 415ε (Mean = 48.7ε)) 399 </p> 400 </td> 401<td> 402 <p> 403 <span class="blue">Max = 8.28e+03ε (Mean = 1.09e+03ε)</span> 404 </p> 405 </td> 406<td> 407 <p> 408 <span class="blue">Max = 8.98e+03ε (Mean = 877ε)</span> 409 </p> 410 </td> 411<td> 412 <p> 413 <span class="blue">Max = 451ε (Mean = 64.7ε)</span> 414 </p> 415 </td> 416</tr> 417</tbody> 418</table></div> 419</div> 420<br class="table-break"><div class="table"> 421<a name="math_toolkit.sf_gamma.igamma_inv.table_gamma_p_inva"></a><p class="title"><b>Table 8.15. Error rates for gamma_p_inva</b></p> 422<div class="table-contents"><table class="table" summary="Error rates for gamma_p_inva"> 423<colgroup> 424<col> 425<col> 426<col> 427<col> 428<col> 429</colgroup> 430<thead><tr> 431<th> 432 </th> 433<th> 434 <p> 435 GNU C++ version 7.1.0<br> linux<br> double 436 </p> 437 </th> 438<th> 439 <p> 440 GNU C++ version 7.1.0<br> linux<br> long double 441 </p> 442 </th> 443<th> 444 <p> 445 Sun compiler version 0x5150<br> Sun Solaris<br> long double 446 </p> 447 </th> 448<th> 449 <p> 450 Microsoft Visual C++ version 14.1<br> Win32<br> double 451 </p> 452 </th> 453</tr></thead> 454<tbody><tr> 455<td> 456 <p> 457 Incomplete gamma inverses. 458 </p> 459 </td> 460<td> 461 <p> 462 <span class="blue">Max = 0ε (Mean = 0ε)</span> 463 </p> 464 </td> 465<td> 466 <p> 467 <span class="blue">Max = 7.87ε (Mean = 1.15ε)</span> 468 </p> 469 </td> 470<td> 471 <p> 472 <span class="blue">Max = 4.08ε (Mean = 1.12ε)</span> 473 </p> 474 </td> 475<td> 476 <p> 477 <span class="blue">Max = 4.92ε (Mean = 1.03ε)</span> 478 </p> 479 </td> 480</tr></tbody> 481</table></div> 482</div> 483<br class="table-break"><div class="table"> 484<a name="math_toolkit.sf_gamma.igamma_inv.table_gamma_q_inva"></a><p class="title"><b>Table 8.16. Error rates for gamma_q_inva</b></p> 485<div class="table-contents"><table class="table" summary="Error rates for gamma_q_inva"> 486<colgroup> 487<col> 488<col> 489<col> 490<col> 491<col> 492</colgroup> 493<thead><tr> 494<th> 495 </th> 496<th> 497 <p> 498 GNU C++ version 7.1.0<br> linux<br> double 499 </p> 500 </th> 501<th> 502 <p> 503 GNU C++ version 7.1.0<br> linux<br> long double 504 </p> 505 </th> 506<th> 507 <p> 508 Sun compiler version 0x5150<br> Sun Solaris<br> long double 509 </p> 510 </th> 511<th> 512 <p> 513 Microsoft Visual C++ version 14.1<br> Win32<br> double 514 </p> 515 </th> 516</tr></thead> 517<tbody><tr> 518<td> 519 <p> 520 Incomplete gamma inverses. 521 </p> 522 </td> 523<td> 524 <p> 525 <span class="blue">Max = 0ε (Mean = 0ε)</span> 526 </p> 527 </td> 528<td> 529 <p> 530 <span class="blue">Max = 8.42ε (Mean = 1.3ε)</span> 531 </p> 532 </td> 533<td> 534 <p> 535 <span class="blue">Max = 7.86ε (Mean = 1.24ε)</span> 536 </p> 537 </td> 538<td> 539 <p> 540 <span class="blue">Max = 5.05ε (Mean = 1.08ε)</span> 541 </p> 542 </td> 543</tr></tbody> 544</table></div> 545</div> 546<br class="table-break"><h5> 547<a name="math_toolkit.sf_gamma.igamma_inv.h3"></a> 548 <span class="phrase"><a name="math_toolkit.sf_gamma.igamma_inv.testing"></a></span><a class="link" href="igamma_inv.html#math_toolkit.sf_gamma.igamma_inv.testing">Testing</a> 549 </h5> 550<p> 551 There are two sets of tests: 552 </p> 553<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 554<li class="listitem"> 555 Basic sanity checks attempt to "round-trip" from <span class="emphasis"><em>a</em></span> 556 and <span class="emphasis"><em>x</em></span> to <span class="emphasis"><em>p</em></span> or <span class="emphasis"><em>q</em></span> 557 and back again. These tests have quite generous tolerances: in general 558 both the incomplete gamma, and its inverses, change so rapidly that round 559 tripping to more than a couple of significant digits isn't possible. 560 This is especially true when <span class="emphasis"><em>p</em></span> or <span class="emphasis"><em>q</em></span> 561 is very near one: in this case there isn't enough "information content" 562 in the input to the inverse function to get back where you started. 563 </li> 564<li class="listitem"> 565 Accuracy checks using high precision test values. These measure the accuracy 566 of the result, given exact input values. 567 </li> 568</ul></div> 569<h5> 570<a name="math_toolkit.sf_gamma.igamma_inv.h4"></a> 571 <span class="phrase"><a name="math_toolkit.sf_gamma.igamma_inv.implementation"></a></span><a class="link" href="igamma_inv.html#math_toolkit.sf_gamma.igamma_inv.implementation">Implementation</a> 572 </h5> 573<p> 574 The functions <code class="computeroutput"><span class="identifier">gamma_p_inv</span></code> 575 and <a href="http://functions.wolfram.com/GammaBetaErf/InverseGammaRegularized/" target="_top"><code class="computeroutput"><span class="identifier">gamma_q_inv</span></code></a> share a common implementation. 576 </p> 577<p> 578 First an initial approximation is computed using the methodology described 579 in: 580 </p> 581<p> 582 <a href="http://portal.acm.org/citation.cfm?id=23109&coll=portal&dl=ACM" target="_top">A. 583 R. Didonato and A. H. Morris, Computation of the Incomplete Gamma Function 584 Ratios and their Inverse, ACM Trans. Math. Software 12 (1986), 377-393.</a> 585 </p> 586<p> 587 Finally, the last few bits are cleaned up using Halley iteration, the iteration 588 limit is set to 2/3 of the number of bits in T, which by experiment is sufficient 589 to ensure that the inverses are at least as accurate as the normal incomplete 590 gamma functions. In testing, no more than 3 iterations are required to produce 591 a result as accurate as the forward incomplete gamma function, and in many 592 cases only one iteration is required. 593 </p> 594<p> 595 The functions <code class="computeroutput"><span class="identifier">gamma_p_inva</span></code> 596 and <code class="computeroutput"><span class="identifier">gamma_q_inva</span></code> also share 597 a common implementation but are handled separately from <code class="computeroutput"><span class="identifier">gamma_p_inv</span></code> 598 and <code class="computeroutput"><span class="identifier">gamma_q_inv</span></code>. 599 </p> 600<p> 601 An initial approximation for <span class="emphasis"><em>a</em></span> is computed very crudely 602 so that <span class="emphasis"><em>gamma_p(a, x) ~ 0.5</em></span>, this value is then used 603 as a starting point for a generic derivative-free root finding algorithm. 604 As a consequence, these two functions are rather more expensive to compute 605 than the <code class="computeroutput"><span class="identifier">gamma_p_inv</span></code> or 606 <code class="computeroutput"><span class="identifier">gamma_q_inv</span></code> functions. Even 607 so, the root is usually found in fewer than 10 iterations. 608 </p> 609</div> 610<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 611<td align="left"></td> 612<td align="right"><div class="copyright-footer">Copyright © 2006-2019 Nikhar 613 Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, 614 Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Matthew Pulver, Johan 615 Råde, Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg, 616 Daryle Walker and Xiaogang Zhang<p> 617 Distributed under the Boost Software License, Version 1.0. (See accompanying 618 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>) 619 </p> 620</div></td> 621</tr></table> 622<hr> 623<div class="spirit-nav"> 624<a accesskey="p" href="igamma.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../sf_gamma.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="gamma_derivatives.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> 625</div> 626</body> 627</html> 628