• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>Owen's T function</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="../special.html" title="Chapter 8. Special Functions">
9<link rel="prev" href="inv_hyper/atanh.html" title="atanh">
10<link rel="next" href="daubechies.html" title="Daubechies Wavelets and Scaling Functions">
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="inv_hyper/atanh.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../special.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="daubechies.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="section">
26<div class="titlepage"><div><div><h2 class="title" style="clear: both">
27<a name="math_toolkit.owens_t"></a><a class="link" href="owens_t.html" title="Owen's T function">Owen's T function</a>
28</h2></div></div></div>
29<h5>
30<a name="math_toolkit.owens_t.h0"></a>
31      <span class="phrase"><a name="math_toolkit.owens_t.synopsis"></a></span><a class="link" href="owens_t.html#math_toolkit.owens_t.synopsis">Synopsis</a>
32    </h5>
33<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">special_functions</span><span class="special">/</span><span class="identifier">owens_t</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
34</pre>
35<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>
36
37<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
38<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">owens_t</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">h</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">a</span><span class="special">);</span>
39
40<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
41<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">owens_t</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">h</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
42
43<span class="special">}}</span> <span class="comment">// namespaces</span>
44</pre>
45<h5>
46<a name="math_toolkit.owens_t.h1"></a>
47      <span class="phrase"><a name="math_toolkit.owens_t.description"></a></span><a class="link" href="owens_t.html#math_toolkit.owens_t.description">Description</a>
48    </h5>
49<p>
50      Returns the <a href="http://en.wikipedia.org/wiki/Owen%27s_T_function" target="_top">Owens_t
51      function</a> of <span class="emphasis"><em>h</em></span> and <span class="emphasis"><em>a</em></span>.
52    </p>
53<p>
54      The final <a class="link" href="../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">Policy</a> argument is optional and can
55      be used to control the behaviour of the function: how it handles errors, what
56      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 documentation
57      for more details</a>.
58    </p>
59<p>
60         
61    </p>
62<div class="blockquote"><blockquote class="blockquote"><p>
63        <span class="inlinemediaobject"><img src="../../equations/owens_t.svg"></span>
64
65      </p></blockquote></div>
66<p>
67      <span class="inlinemediaobject"><img src="../../graphs/plot_owens_t.png"></span>
68    </p>
69<p>
70      The function <code class="computeroutput"><span class="identifier">owens_t</span><span class="special">(</span><span class="identifier">h</span><span class="special">,</span> <span class="identifier">a</span><span class="special">)</span></code> gives the probability of the event <span class="emphasis"><em>(X
71      &gt; h and 0 &lt; Y &lt; a * X)</em></span>, where <span class="emphasis"><em>X</em></span> and
72      <span class="emphasis"><em>Y</em></span> are independent standard normal random variables.
73    </p>
74<p>
75      For h and a &gt; 0, T(h,a), gives the volume of an uncorrelated bivariate normal
76      distribution with zero means and unit variances over the area between <span class="emphasis"><em>y
77      = ax</em></span> and <span class="emphasis"><em>y = 0</em></span> and to the right of <span class="emphasis"><em>x
78      = h</em></span>.
79    </p>
80<p>
81      That is the area shaded in the figure below (Owens 1956).
82    </p>
83<div class="blockquote"><blockquote class="blockquote"><p>
84        <span class="inlinemediaobject"><img src="../../graphs/owens_integration_area.svg" align="middle"></span>
85
86      </p></blockquote></div>
87<p>
88      and is also illustrated by a 3D plot.
89    </p>
90<p>
91      <span class="inlinemediaobject"><img src="../../graphs/plot_owens_3d_xyp.png"></span>
92    </p>
93<p>
94      This function is used in the computation of the <a class="link" href="dist_ref/dists/skew_normal_dist.html" title="Skew Normal Distribution">Skew
95      Normal Distribution</a>. It is also used in the computation of bivariate
96      and multivariate normal distribution probabilities. The return type of this
97      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
98      type calculation rules</em></span></a>: the result is of type <code class="computeroutput"><span class="keyword">double</span></code> when T is an integer type, and type T
99      otherwise.
100    </p>
101<p>
102      Owen's original paper (page 1077) provides some additional corner cases.
103    </p>
104<div class="blockquote"><blockquote class="blockquote"><p>
105        <span class="serif_italic"><span class="emphasis"><em>T(h, 0) = 0</em></span></span>
106      </p></blockquote></div>
107<div class="blockquote"><blockquote class="blockquote"><p>
108        <span class="serif_italic"><span class="emphasis"><em>T(0, a) = ½π arctan(a)</em></span></span>
109      </p></blockquote></div>
110<div class="blockquote"><blockquote class="blockquote"><p>
111        <span class="serif_italic"><span class="emphasis"><em>T(h, 1) = ½ G(h) [1 - G(h)]</em></span></span>
112      </p></blockquote></div>
113<div class="blockquote"><blockquote class="blockquote"><p>
114        <span class="serif_italic"><span class="emphasis"><em>T(h, ∞) = G(|h|)</em></span></span>
115      </p></blockquote></div>
116<p>
117      where G(h) is the univariate normal with zero mean and unit variance integral
118      from -∞ to h.
119    </p>
120<h5>
121<a name="math_toolkit.owens_t.h2"></a>
122      <span class="phrase"><a name="math_toolkit.owens_t.accuracy"></a></span><a class="link" href="owens_t.html#math_toolkit.owens_t.accuracy">Accuracy</a>
123    </h5>
124<p>
125      Over the built-in types and range tested, errors are less than 10 * std::numeric_limits&lt;RealType&gt;::epsilon().
126    </p>
127<div class="table">
128<a name="math_toolkit.owens_t.table_owens_t"></a><p class="title"><b>Table 8.86. Error rates for owens_t</b></p>
129<div class="table-contents"><table class="table" summary="Error rates for owens_t">
130<colgroup>
131<col>
132<col>
133<col>
134<col>
135<col>
136</colgroup>
137<thead><tr>
138<th>
139            </th>
140<th>
141              <p>
142                GNU C++ version 7.1.0<br> linux<br> double
143              </p>
144            </th>
145<th>
146              <p>
147                GNU C++ version 7.1.0<br> linux<br> long double
148              </p>
149            </th>
150<th>
151              <p>
152                Sun compiler version 0x5150<br> Sun Solaris<br> long double
153              </p>
154            </th>
155<th>
156              <p>
157                Microsoft Visual C++ version 14.1<br> Win32<br> double
158              </p>
159            </th>
160</tr></thead>
161<tbody>
162<tr>
163<td>
164              <p>
165                Owens T (medium small values)
166              </p>
167            </td>
168<td>
169              <p>
170                <span class="blue">Max = 0ε (Mean = 0ε)</span>
171              </p>
172            </td>
173<td>
174              <p>
175                <span class="blue">Max = 3.34ε (Mean = 0.944ε)</span>
176              </p>
177            </td>
178<td>
179              <p>
180                <span class="blue">Max = 3.34ε (Mean = 0.911ε)</span>
181              </p>
182            </td>
183<td>
184              <p>
185                <span class="blue">Max = 4.37ε (Mean = 0.98ε)</span>
186              </p>
187            </td>
188</tr>
189<tr>
190<td>
191              <p>
192                Owens T (large and diverse values)
193              </p>
194            </td>
195<td>
196              <p>
197                <span class="blue">Max = 0ε (Mean = 0ε)</span>
198              </p>
199            </td>
200<td>
201              <p>
202                <span class="blue">Max = 49ε (Mean = 2.16ε)</span>
203              </p>
204            </td>
205<td>
206              <p>
207                <span class="blue">Max = 24.5ε (Mean = 1.39ε)</span>
208              </p>
209            </td>
210<td>
211              <p>
212                <span class="blue">Max = 3.78ε (Mean = 0.621ε)</span>
213              </p>
214            </td>
215</tr>
216</tbody>
217</table></div>
218</div>
219<br class="table-break"><h5>
220<a name="math_toolkit.owens_t.h3"></a>
221      <span class="phrase"><a name="math_toolkit.owens_t.testing"></a></span><a class="link" href="owens_t.html#math_toolkit.owens_t.testing">Testing</a>
222    </h5>
223<p>
224      Test data was generated by Patefield and Tandy algorithms T1 and T4, and also
225      the suggested reference routine T7.
226    </p>
227<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
228<li class="listitem">
229          T1 was rejected if the result was too small compared to <code class="computeroutput"><span class="identifier">atan</span><span class="special">(</span><span class="identifier">a</span><span class="special">)</span></code>
230          (ie cancellation),
231        </li>
232<li class="listitem">
233          T4 was rejected if there was no convergence,
234        </li>
235<li class="listitem">
236          Both were rejected if they didn't agree.
237        </li>
238</ul></div>
239<p>
240      Over the built-in types and range tested, errors are less than 10 std::numeric_limits&lt;RealType&gt;::epsilon().
241    </p>
242<p>
243      However, that there was a whole domain (large <span class="emphasis"><em>h</em></span>, small
244      <span class="emphasis"><em>a</em></span>) where it was not possible to generate any reliable
245      test values (all the methods got rejected for one reason or another).
246    </p>
247<p>
248      There are also two sets of sanity tests: spot values are computed using <a href="http://www.wolfram.com/products/mathematica/index.html" target="_top">Wolfram Mathematica</a>
249      and <a href="http://www.r-project.org/" target="_top">The R Project for Statistical Computing</a>.
250    </p>
251<h5>
252<a name="math_toolkit.owens_t.h4"></a>
253      <span class="phrase"><a name="math_toolkit.owens_t.implementation"></a></span><a class="link" href="owens_t.html#math_toolkit.owens_t.implementation">Implementation</a>
254    </h5>
255<p>
256      The function was proposed and evaluated by <a href="http://projecteuclid.org/DPubS?service=UI&amp;version=1.0&amp;verb=Display&amp;handle=euclid.aoms/1177728074" target="_top">Donald.
257      B. Owen, Tables for computing bivariate normal probabilities, Ann. Math. Statist.,
258      27, 1075-1090 (1956)</a>.
259    </p>
260<p>
261      The algorithms of Patefield, M. and Tandy, D. "Fast and accurate Calculation
262      of Owen's T-Function", Journal of Statistical Software, 5 (5), 1 - 25
263      (2000) are adapted for C++ with arbitrary RealType.
264    </p>
265<p>
266      The Patefield-Tandy algorithm provides six methods of evaluation (T1 to T6);
267      the best method is selected according to the values of <span class="emphasis"><em>a</em></span>
268      and <span class="emphasis"><em>h</em></span>. See the original paper and the source in <a href="../../../../../boost/math/special_functions/owens_t.hpp" target="_top">owens_t.hpp</a>
269      for details.
270    </p>
271<p>
272      The Patefield-Tandy algorithm is accurate to approximately 20 decimal places,
273      so for types with greater precision we use:
274    </p>
275<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
276<li class="listitem">
277          A modified version of T1 which folds the calculation of <span class="emphasis"><em>atan(h)</em></span>
278          into the T1 series (to avoid subtracting two values similar in magnitude),
279          and then accelerates the resulting alternating series using method 1 from
280          H. Cohen, F. Rodriguez Villegas, D. Zagier, "Convergence acceleration
281          of alternating series", Bonn, (1991). The result is valid everywhere,
282          but doesn't always converge, or may become too divergent in the first few
283          terms to sum accurately. This is used for <span class="emphasis"><em>ah &lt; 1</em></span>.
284        </li>
285<li class="listitem">
286          A modified version of T2 which is accelerated in the same manner as T1.
287          This is used for <span class="emphasis"><em>h &gt; 1</em></span>.
288        </li>
289<li class="listitem">
290          A version of T4 only when both T1 and T2 have failed to produce an accurate
291          answer.
292        </li>
293<li class="listitem">
294          Fallback to the Patefiled Tandy algorithm when all the above methods fail:
295          this happens not at all for our test data at 100 decimal digits precision.
296          However, there is a difficult area when <span class="emphasis"><em>a</em></span> is very
297          close to 1 and the precision increases which may cause this to happen in
298          very exceptional circumstances.
299        </li>
300</ul></div>
301<p>
302      Using the above algorithm and a 100-decimal digit type, results accurate to
303      80 decimal places were obtained in the difficult area where <span class="emphasis"><em>a</em></span>
304      is close to 1, and greater than 95 decimal places elsewhere.
305    </p>
306</div>
307<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
308<td align="left"></td>
309<td align="right"><div class="copyright-footer">Copyright © 2006-2019 Nikhar
310      Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
311      Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Matthew Pulver, Johan
312      Råde, Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg,
313      Daryle Walker and Xiaogang Zhang<p>
314        Distributed under the Boost Software License, Version 1.0. (See accompanying
315        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>)
316      </p>
317</div></td>
318</tr></table>
319<hr>
320<div class="spirit-nav">
321<a accesskey="p" href="inv_hyper/atanh.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../special.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="daubechies.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
322</div>
323</body>
324</html>
325