|
1 | 1 | # Owen's T Function |
2 | 2 | # Written by Andy Gough; August 2021 (see https://github.com/JuliaStats/StatsFuns.jl/issues/99#issuecomment-1124581689) |
3 | | -# Edited by Johanni Brea to make type stable; January 2025 |
| 3 | +# Edited by Johanni Brea; January 2025 |
4 | 4 | # Rev 1.09 |
5 | 5 | # MIT License |
6 | 6 | # |
7 | 7 | # dependencies |
8 | 8 | # IrrationalConstants |
9 | 9 | # SpecialFunctions |
10 | | -# LinearAlgebra |
11 | 10 | # |
12 | 11 | # HISTORY |
13 | 12 | # In the past 20 or so years, most implementations of Owen's T function have followed the algorithms given in "Fast and accurate Calculation of Owen's |
|
33 | 32 | # T1 through T4 are not implemented. Instead, if a < 0.999999, T5 is used to calculate Owen's T (using 48 point Gauss-Legendre quadrature) |
34 | 33 | # For 0.999999 < a < 1.0, T6 is implemented. |
35 | 34 | # |
36 | | -# REFERENCES |
37 | | -# [1] "Fast and accurate Calculation of Owen's T-Function", by M. Patefield and D. Tandy, Journal of Statistical Software, 5 (5), 1 - 25 (2000) |
38 | | -# [2] "Tables for Computing Bivariate Normal Probabilities", by Donald P. Owen, The Annals of Mathematical Statistics, Vol. 27, No. 4 (Dec 1956), pp. 1075-1090 |
39 | | -# |
40 | 35 | # Partial Derivatives (FYI) |
41 | 36 | # D[owent[x,a],x] = -exp(-0.5*x^2)*erf(a*x/sqrt2)/(2*sqrt2π) |
42 | 37 | # D[owent[x,a],a] = exp(-0.5*(1+a^2)*(x^2))/((1+a^2)*2π) |
43 | 38 | # |
44 | 39 | @doc raw""" |
45 | | -owent(h,a) : Returns the value of Owen's T function for (h,a) |
| 40 | + owent(h, a) |
46 | 41 |
|
47 | | -Owen's T function: |
| 42 | +Returns the value of Owen's T function |
48 | 43 | ```math |
49 | 44 | T(h,a) = \frac{1}{2\pi } \int_{0}^{a} \frac{e^{-\frac{1}{2}h^2(1+x^2)}}{1+x^2}dx\quad(-\infty < h,a < +\infty) |
50 | 45 | ``` |
51 | 46 |
|
52 | | -For *h* and *a* > 0, *T(h,a)* gives the volume of the uncorrelated bivariate normal distribution with zero mean and unit variance |
53 | | -over the area from *y = ax* and *y = 0* and to the right of *x = h*. |
| 47 | +For *h* and *a* > 0, *T(h,a)* gives the volume of the uncorrelated bivariate normal distribution with zero mean and unit variance over the area from *y = ax* and *y = 0* and to the right of *x = h*. |
54 | 48 |
|
55 | | -EXAMPLE: |
| 49 | +## Example |
56 | 50 | ``` |
57 | 51 | julia> owent(0.0625, 0.025) |
58 | 52 | 0.003970281304296922 |
59 | 53 | ``` |
60 | 54 |
|
61 | | -Worst case accuracy is about 2e-16. |
| 55 | +## References |
| 56 | +"Fast and accurate Calculation of Owen's T-Function", by M. Patefield and D. Tandy, Journal of Statistical Software, 5 (5), 1 - 25 (2000) |
| 57 | +
|
| 58 | +"Tables for Computing Bivariate Normal Probabilities", by Donald P. Owen, The Annals of Mathematical Statistics, Vol. 27, No. 4 (Dec 1956), pp. 1075-1090 |
| 59 | +# |
62 | 60 | """ |
63 | 61 | function owent(h::T, a::T) where {T <: Real} |
64 | 62 |
|
|
0 commit comments