File: owens_t.html

package info (click to toggle)
scipy 1.16.0-1exp7
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 234,820 kB
  • sloc: cpp: 503,145; python: 344,611; ansic: 195,638; javascript: 89,566; fortran: 56,210; cs: 3,081; f90: 1,150; sh: 848; makefile: 785; pascal: 284; csh: 135; lisp: 134; xml: 56; perl: 51
file content (322 lines) | stat: -rw-r--r-- 17,095 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Owen's T function</title>
<link rel="stylesheet" href="../math.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../index.html" title="Math Toolkit 4.2.1">
<link rel="up" href="../special.html" title="Chapter 8. Special Functions">
<link rel="prev" href="inv_hyper/atanh.html" title="atanh">
<link rel="next" href="daubechies.html" title="Daubechies Wavelets and Scaling Functions">
<meta name="viewport" content="width=device-width, initial-scale=1">
</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="daubechies.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">&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>
</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">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</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">&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 22. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</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 22. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</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 22. 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 22. Policies: Controlling Precision, Error Handling etc">policy documentation
      for more details</a>.
    </p>
<p>
         
    </p>
<div class="blockquote"><blockquote class="blockquote"><p>
        <span class="inlinemediaobject"><img src="../../equations/owens_t.svg"></span>

      </p></blockquote></div>
<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
      &gt; h and 0 &lt; Y &lt; 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 &gt; 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>
<div class="blockquote"><blockquote class="blockquote"><p>
        <span class="inlinemediaobject"><img src="../../graphs/owens_integration_area.svg" align="middle"></span>

      </p></blockquote></div>
<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="serif_italic"><span class="emphasis"><em>T(h, 0) = 0</em></span></span>
      </p></blockquote></div>
<div class="blockquote"><blockquote class="blockquote"><p>
        <span class="serif_italic"><span class="emphasis"><em>T(0, a) = ½π arctan(a)</em></span></span>
      </p></blockquote></div>
<div class="blockquote"><blockquote class="blockquote"><p>
        <span class="serif_italic"><span class="emphasis"><em>T(h, 1) = ½ G(h) [1 - G(h)]</em></span></span>
      </p></blockquote></div>
<div class="blockquote"><blockquote class="blockquote"><p>
        <span class="serif_italic"><span class="emphasis"><em>T(h, ∞) = G(|h|)</em></span></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&lt;RealType&gt;::epsilon().
    </p>
<div class="table">
<a name="math_toolkit.owens_t.table_owens_t"></a><p class="title"><b>Table 8.86. Error rates for owens_t</b></p>
<div class="table-contents"><table class="table" summary="Error rates for owens_t">
<colgroup>
<col>
<col>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
            </th>
<th>
              <p>
                GNU C++ version 7.1.0<br> linux<br> double
              </p>
            </th>
<th>
              <p>
                GNU C++ version 7.1.0<br> linux<br> long double
              </p>
            </th>
<th>
              <p>
                Sun compiler version 0x5150<br> Sun Solaris<br> long double
              </p>
            </th>
<th>
              <p>
                Microsoft Visual C++ version 14.1<br> Win32<br> double
              </p>
            </th>
</tr></thead>
<tbody>
<tr>
<td>
              <p>
                Owens T (medium small values)
              </p>
            </td>
<td>
              <p>
                <span class="blue">Max = 0ε (Mean = 0ε)</span>
              </p>
            </td>
<td>
              <p>
                <span class="blue">Max = 3.34ε (Mean = 0.944ε)</span>
              </p>
            </td>
<td>
              <p>
                <span class="blue">Max = 3.34ε (Mean = 0.911ε)</span>
              </p>
            </td>
<td>
              <p>
                <span class="blue">Max = 4.37ε (Mean = 0.98ε)</span>
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                Owens T (large and diverse values)
              </p>
            </td>
<td>
              <p>
                <span class="blue">Max = 0ε (Mean = 0ε)</span>
              </p>
            </td>
<td>
              <p>
                <span class="blue">Max = 49ε (Mean = 2.16ε)</span>
              </p>
            </td>
<td>
              <p>
                <span class="blue">Max = 24.5ε (Mean = 1.39ε)</span>
              </p>
            </td>
<td>
              <p>
                <span class="blue">Max = 3.78ε (Mean = 0.621ε)</span>
              </p>
            </td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><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&lt;RealType&gt;::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&amp;version=1.0&amp;verb=Display&amp;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 evaluation (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 &lt; 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 &gt; 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>
<div class="copyright-footer">Copyright © 2006-2021 Nikhar Agrawal, Anton Bikineev, Matthew Borland,
      Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert Holin, Bruno
      Lalande, John Maddock, Evan Miller, Jeremy Murphy, Matthew Pulver, Johan Råde,
      Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, 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>
<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="daubechies.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>