]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | <html> |
2 | <head> | |
3 | <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> | |
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.77.1"> | |
7 | <link rel="home" href="../index.html" title="Math Toolkit 2.5.1"> | |
8 | <link rel="up" href="../special.html" title="Chapter 6. Special Functions"> | |
9 | <link rel="prev" href="inv_hyper/atanh.html" title="atanh"> | |
10 | <link rel="next" href="../extern_c.html" title='Chapter 7. TR1 and C99 external "C" 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="../extern_c.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"><</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">></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"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></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"><</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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></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 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</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 15. 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 15. Policies: Controlling Precision, Error Handling etc">policy documentation | |
57 | for more details</a>. | |
58 | </p> | |
59 | <p> | |
60 |     <span class="inlinemediaobject"><img src="../../equations/owens_t.svg"></span> | |
61 | </p> | |
62 | <p> | |
63 | <span class="inlinemediaobject"><img src="../../graphs/plot_owens_t.png"></span> | |
64 | </p> | |
65 | <p> | |
66 | 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 | |
67 | > h and 0 < Y < a * X)</em></span>, where <span class="emphasis"><em>X</em></span> and | |
68 | <span class="emphasis"><em>Y</em></span> are independent standard normal random variables. | |
69 | </p> | |
70 | <p> | |
71 | For h and a > 0, T(h,a), gives the volume of an uncorrelated bivariate normal | |
72 | distribution with zero means and unit variances over the area between <span class="emphasis"><em>y | |
73 | = ax</em></span> and <span class="emphasis"><em>y = 0</em></span> and to the right of <span class="emphasis"><em>x | |
74 | = h</em></span>. | |
75 | </p> | |
76 | <p> | |
77 | That is the area shaded in the figure below (Owens 1956). | |
78 | </p> | |
79 | <p> | |
80 | <span class="inlinemediaobject"><img src="../../graphs/owens_integration_area.svg" align="middle"></span> | |
81 | </p> | |
82 | <p> | |
83 | and is also illustrated by a 3D plot. | |
84 | </p> | |
85 | <p> | |
86 | <span class="inlinemediaobject"><img src="../../graphs/plot_owens_3d_xyp.png"></span> | |
87 | </p> | |
88 | <p> | |
89 | 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 | |
90 | Normal Distribution</a>. It is also used in the computation of bivariate | |
91 | and multivariate normal distribution probabilities. The return type of this | |
92 | 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 | |
93 | 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 | |
94 | otherwise. | |
95 | </p> | |
96 | <p> | |
97 | Owen's original paper (page 1077) provides some additional corner cases. | |
98 | </p> | |
99 | <div class="blockquote"><blockquote class="blockquote"><p> | |
100 | <span class="emphasis"><em>T(h, 0) = 0</em></span> | |
101 | </p></blockquote></div> | |
102 | <div class="blockquote"><blockquote class="blockquote"><p> | |
103 | <span class="emphasis"><em>T(0, a) = ½π arctan(a)</em></span> | |
104 | </p></blockquote></div> | |
105 | <div class="blockquote"><blockquote class="blockquote"><p> | |
106 | <span class="emphasis"><em>T(h, 1) = ½ G(h) [1 - G(h)]</em></span> | |
107 | </p></blockquote></div> | |
108 | <div class="blockquote"><blockquote class="blockquote"><p> | |
109 | <span class="emphasis"><em>T(h, ∞) = G(|h|)</em></span> | |
110 | </p></blockquote></div> | |
111 | <p> | |
112 | where G(h) is the univariate normal with zero mean and unit variance integral | |
113 | from -∞ to h. | |
114 | </p> | |
115 | <h5> | |
116 | <a name="math_toolkit.owens_t.h2"></a> | |
117 | <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> | |
118 | </h5> | |
119 | <p> | |
120 | Over the built-in types and range tested, errors are less than 10 * std::numeric_limits<RealType>::epsilon(). | |
121 | </p> | |
122 | <div class="table"> | |
123 | <a name="math_toolkit.owens_t.table_owens_t"></a><p class="title"><b>Table 6.83. Error rates for owens_t</b></p> | |
124 | <div class="table-contents"><table class="table" summary="Error rates for owens_t"> | |
125 | <colgroup> | |
126 | <col> | |
127 | <col> | |
128 | <col> | |
129 | <col> | |
130 | <col> | |
131 | </colgroup> | |
132 | <thead><tr> | |
133 | <th> | |
134 | </th> | |
135 | <th> | |
136 | <p> | |
137 | Microsoft Visual C++ version 12.0<br> Win32<br> double | |
138 | </p> | |
139 | </th> | |
140 | <th> | |
141 | <p> | |
142 | GNU C++ version 5.1.0<br> linux<br> double | |
143 | </p> | |
144 | </th> | |
145 | <th> | |
146 | <p> | |
147 | GNU C++ version 5.1.0<br> linux<br> long double | |
148 | </p> | |
149 | </th> | |
150 | <th> | |
151 | <p> | |
152 | Sun compiler version 0x5130<br> Sun Solaris<br> long double | |
153 | </p> | |
154 | </th> | |
155 | </tr></thead> | |
156 | <tbody> | |
157 | <tr> | |
158 | <td> | |
159 | <p> | |
160 | Owens T (medium small values) | |
161 | </p> | |
162 | </td> | |
163 | <td> | |
164 | <p> | |
165 | <span class="blue">Max = 4.37ε (Mean = 0.973ε)</span> | |
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.942ε)</span> | |
176 | </p> | |
177 | </td> | |
178 | <td> | |
179 | <p> | |
180 | <span class="blue">Max = 3.34ε (Mean = 0.91ε)</span> | |
181 | </p> | |
182 | </td> | |
183 | </tr> | |
184 | <tr> | |
185 | <td> | |
186 | <p> | |
187 | Owens T (large and diverse values) | |
188 | </p> | |
189 | </td> | |
190 | <td> | |
191 | <p> | |
192 | <span class="blue">Max = 3.78ε (Mean = 0.621ε)</span> | |
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.38ε)</span> | |
208 | </p> | |
209 | </td> | |
210 | </tr> | |
211 | </tbody> | |
212 | </table></div> | |
213 | </div> | |
214 | <br class="table-break"><h5> | |
215 | <a name="math_toolkit.owens_t.h3"></a> | |
216 | <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> | |
217 | </h5> | |
218 | <p> | |
219 | Test data was generated by Patefield and Tandy algorithms T1 and T4, and also | |
220 | the suggested reference routine T7. | |
221 | </p> | |
222 | <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> | |
223 | <li class="listitem"> | |
224 | 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> | |
225 | (ie cancellation), | |
226 | </li> | |
227 | <li class="listitem"> | |
228 | T4 was rejected if there was no convergence, | |
229 | </li> | |
230 | <li class="listitem"> | |
231 | Both were rejected if they didn't agree. | |
232 | </li> | |
233 | </ul></div> | |
234 | <p> | |
235 | Over the built-in types and range tested, errors are less than 10 std::numeric_limits<RealType>::epsilon(). | |
236 | </p> | |
237 | <p> | |
238 | However, that there was a whole domain (large <span class="emphasis"><em>h</em></span>, small | |
239 | <span class="emphasis"><em>a</em></span>) where it was not possible to generate any reliable | |
240 | test values (all the methods got rejected for one reason or another). | |
241 | </p> | |
242 | <p> | |
243 | 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> | |
244 | and <a href="http://www.r-project.org/" target="_top">The R Project for Statistical Computing</a>. | |
245 | </p> | |
246 | <h5> | |
247 | <a name="math_toolkit.owens_t.h4"></a> | |
248 | <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> | |
249 | </h5> | |
250 | <p> | |
251 | The function was proposed and evaluated by <a href="http://projecteuclid.org/DPubS?service=UI&version=1.0&verb=Display&handle=euclid.aoms/1177728074" target="_top">Donald. | |
252 | B. Owen, Tables for computing bivariate normal probabilities, Ann. Math. Statist., | |
253 | 27, 1075-1090 (1956)</a>. | |
254 | </p> | |
255 | <p> | |
256 | The algorithms of Patefield, M. and Tandy, D. "Fast and accurate Calculation | |
257 | of Owen's T-Function", Journal of Statistical Software, 5 (5), 1 - 25 | |
258 | (2000) are adapted for C++ with arbitrary RealType. | |
259 | </p> | |
260 | <p> | |
261 | The Patefield-Tandy algorithm provides six methods of evalualution (T1 to T6); | |
262 | the best method is selected according to the values of <span class="emphasis"><em>a</em></span> | |
263 | 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> | |
264 | for details. | |
265 | </p> | |
266 | <p> | |
267 | The Patefield-Tandy algorithm is accurate to approximately 20 decimal places, | |
268 | so for types with greater precision we use: | |
269 | </p> | |
270 | <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> | |
271 | <li class="listitem"> | |
272 | A modified version of T1 which folds the calculation of <span class="emphasis"><em>atan(h)</em></span> | |
273 | into the T1 series (to avoid subtracting two values similar in magnitude), | |
274 | and then accelerates the resulting alternating series using method 1 from | |
275 | H. Cohen, F. Rodriguez Villegas, D. Zagier, "Convergence acceleration | |
276 | of alternating series", Bonn, (1991). The result is valid everywhere, | |
277 | but doesn't always converge, or may become too divergent in the first few | |
278 | terms to sum accurately. This is used for <span class="emphasis"><em>ah < 1</em></span>. | |
279 | </li> | |
280 | <li class="listitem"> | |
281 | A modified version of T2 which is accelerated in the same manner as T1. | |
282 | This is used for <span class="emphasis"><em>h > 1</em></span>. | |
283 | </li> | |
284 | <li class="listitem"> | |
285 | A version of T4 only when both T1 and T2 have failed to produce an accurate | |
286 | answer. | |
287 | </li> | |
288 | <li class="listitem"> | |
289 | Fallback to the Patefiled Tandy algorithm when all the above methods fail: | |
290 | this happens not at all for our test data at 100 decimal digits precision. | |
291 | However, there is a difficult area when <span class="emphasis"><em>a</em></span> is very | |
292 | close to 1 and the precision increases which may cause this to happen in | |
293 | very exceptional circumstances. | |
294 | </li> | |
295 | </ul></div> | |
296 | <p> | |
297 | Using the above algorithm and a 100-decimal digit type, results accurate to | |
298 | 80 decimal places were obtained in the difficult area where <span class="emphasis"><em>a</em></span> | |
299 | is close to 1, and greater than 95 decimal places elsewhere. | |
300 | </p> | |
301 | </div> | |
302 | <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> | |
303 | <td align="left"></td> | |
304 | <td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal, | |
305 | Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert | |
306 | Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani, | |
307 | Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p> | |
308 | Distributed under the Boost Software License, Version 1.0. (See accompanying | |
309 | 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>) | |
310 | </p> | |
311 | </div></td> | |
312 | </tr></table> | |
313 | <hr> | |
314 | <div class="spirit-nav"> | |
315 | <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="../extern_c.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> | |
316 | </div> | |
317 | </body> | |
318 | </html> |