owens_t.qbk 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. [section:owens_t Owen's T function]
  2. [h4 Synopsis]
  3. ``
  4. #include <boost/math/special_functions/owens_t.hpp>
  5. ``
  6. namespace boost{ namespace math{
  7. template <class T>
  8. ``__sf_result`` owens_t(T h, T a);
  9. template <class T, class ``__Policy``>
  10. ``__sf_result`` owens_t(T h, T a, const ``__Policy``&);
  11. }} // namespaces
  12. [h4 Description]
  13. Returns the
  14. [@http://en.wikipedia.org/wiki/Owen%27s_T_function Owens_t function]
  15. of ['h] and ['a].
  16. [optional_policy]
  17. [sixemspace][sixemspace][equation owens_t]
  18. [$../graphs/plot_owens_t.png]
  19. The function `owens_t(h, a)` gives the probability
  20. of the event ['(X > h and 0 < Y < a * X)],
  21. where ['X] and ['Y] are independent standard normal random variables.
  22. For h and a > 0, T(h,a),
  23. gives the volume of an uncorrelated bivariate normal distribution
  24. with zero means and unit variances over the area between
  25. ['y = ax] and ['y = 0] and to the right of ['x = h].
  26. That is the area shaded in the figure below (Owens 1956).
  27. [graph owens_integration_area]
  28. and is also illustrated by a 3D plot.
  29. [$../graphs/plot_owens_3d_xyp.png]
  30. This function is used in the computation of the __skew_normal_distrib.
  31. It is also used in the computation of bivariate and
  32. multivariate normal distribution probabilities.
  33. The return type of this function is computed using the __arg_promotion_rules:
  34. the result is of type `double` when T is an integer type, and type T otherwise.
  35. Owen's original paper (page 1077) provides some additional corner cases.
  36. [expression ['T(h, 0) = 0]]
  37. [expression ['T(0, a) = [frac12][pi] arctan(a)]]
  38. [expression ['T(h, 1) = [frac12] G(h) \[1 - G(h)\]]]
  39. [expression ['T(h, [infin]) = G(|h|)]]
  40. where G(h) is the univariate normal with zero mean and unit variance integral from -[infin] to h.
  41. [h4 Accuracy]
  42. Over the built-in types and range tested,
  43. errors are less than 10 * std::numeric_limits<RealType>::epsilon().
  44. [table_owens_t]
  45. [h4 Testing]
  46. Test data was generated by Patefield and Tandy algorithms T1 and T4,
  47. and also the suggested reference routine T7.
  48. * T1 was rejected if the result was too small compared to `atan(a)` (ie cancellation),
  49. * T4 was rejected if there was no convergence,
  50. * Both were rejected if they didn't agree.
  51. Over the built-in types and range tested,
  52. errors are less than 10 std::numeric_limits<RealType>::epsilon().
  53. However, that there was a whole domain (large ['h], small ['a])
  54. where it was not possible to generate any reliable test values
  55. (all the methods got rejected for one reason or another).
  56. There are also two sets of sanity tests: spot values are computed using __Mathematica and __R.
  57. [h4 Implementation]
  58. The function was proposed and evaluated by
  59. [@http://projecteuclid.org/DPubS?service=UI&version=1.0&verb=Display&handle=euclid.aoms/1177728074
  60. Donald. B. Owen, Tables for computing bivariate normal probabilities,
  61. Ann. Math. Statist., 27, 1075-1090 (1956)].
  62. The algorithms of Patefield, M. and Tandy, D.
  63. "Fast and accurate Calculation of Owen's T-Function", Journal of Statistical Software, 5 (5), 1 - 25 (2000)
  64. are adapted for C++ with arbitrary RealType.
  65. The Patefield-Tandy algorithm provides six methods of evalualution (T1 to T6);
  66. the best method is selected according to the values of ['a] and ['h].
  67. See the original paper and the source in
  68. [@../../../../boost/math/special_functions/owens_t.hpp owens_t.hpp] for details.
  69. The Patefield-Tandy algorithm is accurate to approximately 20 decimal places, so for
  70. types with greater precision we use:
  71. * A modified version of T1 which folds the calculation of ['atan(h)] into the T1 series
  72. (to avoid subtracting two values similar in magnitude), and then accelerates the
  73. resulting alternating series using method 1 from H. Cohen, F. Rodriguez Villegas, D. Zagier,
  74. "Convergence acceleration of alternating series", Bonn, (1991). The result is valid everywhere,
  75. but doesn't always converge, or may become too divergent in the first few terms to sum accurately.
  76. This is used for ['ah < 1].
  77. * A modified version of T2 which is accelerated in the same manner as T1. This is used for ['h > 1].
  78. * A version of T4 only when both T1 and T2 have failed to produce an accurate answer.
  79. * Fallback to the Patefiled Tandy algorithm when all the above methods fail: this happens not at all
  80. for our test data at 100 decimal digits precision. However, there is a difficult area when
  81. ['a] is very close to 1 and the precision increases which may cause this to happen in very exceptional
  82. circumstances.
  83. Using the above algorithm and a 100-decimal digit type, results accurate to 80 decimal places were obtained
  84. in the difficult area where ['a] is close to 1, and greater than 95 decimal places elsewhere.
  85. [endsect] [/section:owens_t The owens_t Function]
  86. [/
  87. Copyright 2012 Bejamin Sobotta, John Maddock and Paul A. Bristow.
  88. Distributed under the Boost Software License, Version 1.0.
  89. (See accompanying file LICENSE_1_0.txt or copy at
  90. http://www.boost.org/LICENSE_1_0.txt).
  91. ]