| <html> |
| <head> |
| <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> |
| <title>Owen's T function</title> |
| <link rel="stylesheet" href="../math.css" type="text/css"> |
| <meta name="generator" content="DocBook XSL Stylesheets V1.77.1"> |
| <link rel="home" href="../index.html" title="Math Toolkit 2.2.0"> |
| <link rel="up" href="../special.html" title="Chapter 6. Special Functions"> |
| <link rel="prev" href="inv_hyper/atanh.html" title="atanh"> |
| <link rel="next" href="../extern_c.html" title='Chapter 7. TR1 and C99 external "C" Functions'> |
| </head> |
| <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> |
| <table cellpadding="2" width="100%"><tr> |
| <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td> |
| <td align="center"><a href="../../../../../index.html">Home</a></td> |
| <td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td> |
| <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> |
| <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> |
| <td align="center"><a href="../../../../../more/index.htm">More</a></td> |
| </tr></table> |
| <hr> |
| <div class="spirit-nav"> |
| <a accesskey="p" href="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> |
| </div> |
| <div class="section"> |
| <div class="titlepage"><div><div><h2 class="title" style="clear: both"> |
| <a name="math_toolkit.owens_t"></a><a class="link" href="owens_t.html" title="Owen's T function">Owen's T function</a> |
| </h2></div></div></div> |
| <h5> |
| <a name="math_toolkit.owens_t.h0"></a> |
| <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> |
| </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">owens_t</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">T</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">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">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 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">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 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.owens_t.h1"></a> |
| <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> |
| </h5> |
| <p> |
| Returns the <a href="http://en.wikipedia.org/wiki/Owen%27s_T_function" target="_top">Owens_t |
| function</a> of <span class="emphasis"><em>h</em></span> and <span class="emphasis"><em>a</em></span>. |
| </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> |
| <p> |
|     <span class="inlinemediaobject"><img src="../../equations/owens_t.svg"></span> |
| </p> |
| <p> |
| <span class="inlinemediaobject"><img src="../../graphs/plot_owens_t.png"></span> |
| </p> |
| <p> |
| 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 |
| > h and 0 < Y < a * X)</em></span>, where <span class="emphasis"><em>X</em></span> and |
| <span class="emphasis"><em>Y</em></span> are independent standard normal random variables. |
| </p> |
| <p> |
| For h and a > 0, T(h,a), gives the volume of an uncorrelated bivariate normal |
| distribution with zero means and unit variances over the area between <span class="emphasis"><em>y |
| = ax</em></span> and <span class="emphasis"><em>y = 0</em></span> and to the right of <span class="emphasis"><em>x |
| = h</em></span>. |
| </p> |
| <p> |
| That is the area shaded in the figure below (Owens 1956). |
| </p> |
| <p> |
| <span class="inlinemediaobject"><img src="../../graphs/owens_integration_area.svg" align="middle"></span> |
| </p> |
| <p> |
| and is also illustrated by a 3D plot. |
| </p> |
| <p> |
| <span class="inlinemediaobject"><img src="../../graphs/plot_owens_3d_xyp.png"></span> |
| </p> |
| <p> |
| 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 |
| Normal Distribution</a>. It is also used in the computation of bivariate |
| and multivariate normal distribution probabilities. The return type of this |
| function is computed using the <a class="link" href="result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>result |
| type calculation rules</em></span></a>: the result is of type <code class="computeroutput"><span class="keyword">double</span></code> when T is an integer type, and type T |
| otherwise. |
| </p> |
| <p> |
| Owen's original paper (page 1077) provides some additional corner cases. |
| </p> |
| <div class="blockquote"><blockquote class="blockquote"><p> |
| <span class="emphasis"><em>T(h, 0) = 0</em></span> |
| </p></blockquote></div> |
| <div class="blockquote"><blockquote class="blockquote"><p> |
| <span class="emphasis"><em>T(0, a) = ½π arctan(a)</em></span> |
| </p></blockquote></div> |
| <div class="blockquote"><blockquote class="blockquote"><p> |
| <span class="emphasis"><em>T(h, 1) = ½ G(h) [1 - G(h)]</em></span> |
| </p></blockquote></div> |
| <div class="blockquote"><blockquote class="blockquote"><p> |
| <span class="emphasis"><em>T(h, ∞) = G(|h|)</em></span> |
| </p></blockquote></div> |
| <p> |
| where G(h) is the univariate normal with zero mean and unit variance integral |
| from -∞ to h. |
| </p> |
| <h5> |
| <a name="math_toolkit.owens_t.h2"></a> |
| <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> |
| </h5> |
| <p> |
| Over the built-in types and range tested, errors are less than 10 * std::numeric_limits<RealType>::epsilon(). |
| </p> |
| <h5> |
| <a name="math_toolkit.owens_t.h3"></a> |
| <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> |
| </h5> |
| <p> |
| Test data was generated by Patefield and Tandy algorithms T1 and T4, and also |
| the suggested reference routine T7. |
| </p> |
| <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> |
| <li class="listitem"> |
| 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> |
| (ie cancellation), |
| </li> |
| <li class="listitem"> |
| T4 was rejected if there was no convergence, |
| </li> |
| <li class="listitem"> |
| Both were rejected if they didn't agree. |
| </li> |
| </ul></div> |
| <p> |
| Over the built-in types and range tested, errors are less than 10 std::numeric_limits<RealType>::epsilon(). |
| </p> |
| <p> |
| However, that there was a whole domain (large <span class="emphasis"><em>h</em></span>, small |
| <span class="emphasis"><em>a</em></span>) where it was not possible to generate any reliable |
| test values (all the methods got rejected for one reason or another). |
| </p> |
| <p> |
| 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> |
| and <a href="http://www.r-project.org/" target="_top">The R Project for Statistical Computing</a>. |
| </p> |
| <h5> |
| <a name="math_toolkit.owens_t.h4"></a> |
| <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> |
| </h5> |
| <p> |
| 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. |
| B. Owen, Tables for computing bivariate normal probabilities, Ann. Math. Statist., |
| 27, 1075-1090 (1956)</a>. |
| </p> |
| <p> |
| The algorithms of Patefield, M. and Tandy, D. "Fast and accurate Calculation |
| of Owen's T-Function", Journal of Statistical Software, 5 (5), 1 - 25 |
| (2000) are adapted for C++ with arbitrary RealType. |
| </p> |
| <p> |
| The Patefield-Tandy algorithm provides six methods of evalualution (T1 to T6); |
| the best method is selected according to the values of <span class="emphasis"><em>a</em></span> |
| 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> |
| for details. |
| </p> |
| <p> |
| The Patefield-Tandy algorithm is accurate to approximately 20 decimal places, |
| so for types with greater precision we use: |
| </p> |
| <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> |
| <li class="listitem"> |
| A modified version of T1 which folds the calculation of <span class="emphasis"><em>atan(h)</em></span> |
| into the T1 series (to avoid subtracting two values similar in magnitude), |
| and then accelerates the resulting alternating series using method 1 from |
| H. Cohen, F. Rodriguez Villegas, D. Zagier, "Convergence acceleration |
| of alternating series", Bonn, (1991). The result is valid everywhere, |
| but doesn't always converge, or may become too divergent in the first few |
| terms to sum accurately. This is used for <span class="emphasis"><em>ah < 1</em></span>. |
| </li> |
| <li class="listitem"> |
| A modified version of T2 which is accelerated in the same manner as T1. |
| This is used for <span class="emphasis"><em>h > 1</em></span>. |
| </li> |
| <li class="listitem"> |
| A version of T4 only when both T1 and T2 have failed to produce an accurate |
| answer. |
| </li> |
| <li class="listitem"> |
| Fallback to the Patefiled Tandy algorithm when all the above methods fail: |
| this happens not at all for our test data at 100 decimal digits precision. |
| However, there is a difficult area when <span class="emphasis"><em>a</em></span> is very |
| close to 1 and the precision increases which may cause this to happen in |
| very exceptional circumstances. |
| </li> |
| </ul></div> |
| <p> |
| Using the above algorithm and a 100-decimal digit type, results accurate to |
| 80 decimal places were obtained in the difficult area where <span class="emphasis"><em>a</em></span> |
| is close to 1, and greater than 95 decimal places elsewhere. |
| </p> |
| </div> |
| <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> |
| <td align="left"></td> |
| <td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal, |
| Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert |
| Holin, Bruno Lalande, John Maddock, 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="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> |
| </div> |
| </body> |
| </html> |