/Src/Dependencies/Boost/libs/math/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/nc_t_dist.html

http://hadesmem.googlecode.com/ · HTML · 367 lines · 359 code · 8 blank · 0 comment · 0 complexity · bcf1e6cdd17d184826495df3ac72ff92 MD5 · raw file

  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
  4. <title>Noncentral T Distribution</title>
  5. <link rel="stylesheet" href="../../../../../../../../../doc/src/boostbook.css" type="text/css">
  6. <meta name="generator" content="DocBook XSL Stylesheets V1.74.0">
  7. <link rel="home" href="../../../../index.html" title="Math Toolkit">
  8. <link rel="up" href="../dists.html" title="Distributions">
  9. <link rel="prev" href="nc_f_dist.html" title="Noncentral F Distribution">
  10. <link rel="next" href="normal_dist.html" title="Normal (Gaussian) Distribution">
  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="nc_f_dist.html"><img src="../../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../dists.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="normal_dist.html"><img src="../../../../../../../../../doc/src/images/next.png" alt="Next"></a>
  24. </div>
  25. <div class="section" lang="en">
  26. <div class="titlepage"><div><div><h5 class="title">
  27. <a name="math_toolkit.dist.dist_ref.dists.nc_t_dist"></a><a class="link" href="nc_t_dist.html" title="Noncentral T Distribution">Noncentral
  28. T Distribution</a>
  29. </h5></div></div></div>
  30. <p>
  31. </p>
  32. <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">distributions</span><span class="special">/</span><span class="identifier">non_central_t</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></pre>
  33. <p>
  34. </p>
  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. <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">RealType</span> <span class="special">=</span> <span class="keyword">double</span><span class="special">,</span>
  37. <span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Policies">Policy</a> <span class="special">=</span> <a class="link" href="../../../policy/pol_ref/pol_ref_ref.html" title="Policy Class Reference">policies::policy&lt;&gt;</a> <span class="special">&gt;</span>
  38. <span class="keyword">class</span> <span class="identifier">non_central_t_distribution</span><span class="special">;</span>
  39. <span class="keyword">typedef</span> <span class="identifier">non_central_t_distribution</span><span class="special">&lt;&gt;</span> <span class="identifier">non_central_t</span><span class="special">;</span>
  40. <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">RealType</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Policies">Policy</a><span class="special">&gt;</span>
  41. <span class="keyword">class</span> <span class="identifier">non_central_t_distribution</span>
  42. <span class="special">{</span>
  43. <span class="keyword">public</span><span class="special">:</span>
  44. <span class="keyword">typedef</span> <span class="identifier">RealType</span> <span class="identifier">value_type</span><span class="special">;</span>
  45. <span class="keyword">typedef</span> <span class="identifier">Policy</span> <span class="identifier">policy_type</span><span class="special">;</span>
  46. <span class="comment">// Constructor:
  47. </span> <span class="identifier">non_central_t_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">v</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">delta</span><span class="special">);</span>
  48. <span class="comment">// Accessor to degrees_of_freedom parameter v:
  49. </span> <span class="identifier">RealType</span> <span class="identifier">degrees_of_freedom</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
  50. <span class="comment">// Accessor to non-centrality parameter lambda:
  51. </span> <span class="identifier">RealType</span> <span class="identifier">non_centrality</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
  52. <span class="special">};</span>
  53. <span class="special">}}</span> <span class="comment">// namespaces
  54. </span></pre>
  55. <p>
  56. The noncentral T distribution is a generalization of the <a class="link" href="students_t_dist.html" title="Students t Distribution">Students
  57. t Distribution</a>. Let X have a normal distribution with mean &#948; and
  58. variance 1, and let &#957; S<sup>2</sup> have a chi-squared distribution with degrees of
  59. freedom &#957;. Assume that X and S<sup>2</sup> are independent. The distribution of t<sub>&#957;</sub>(&#948;)=X/S
  60. is called a noncentral t distribution with degrees of freedom &#957; and noncentrality
  61. parameter &#948;.
  62. </p>
  63. <p>
  64. This gives the following PDF:
  65. </p>
  66. <p>
  67. <span class="inlinemediaobject"><img src="../../../../../equations/nc_t_ref1.png"></span>
  68. </p>
  69. <p>
  70. where <sub>1</sub>F<sub>1</sub>(a;b;x) is a confluent hypergeometric function.
  71. </p>
  72. <p>
  73. The following graph illustrates how the distribution changes for different
  74. values of &#948;:
  75. </p>
  76. <p>
  77. <span class="inlinemediaobject"><img src="../../../../../graphs/nc_t_pdf.png" align="middle"></span>
  78. </p>
  79. <a name="math_toolkit.dist.dist_ref.dists.nc_t_dist.member_functions"></a><h5>
  80. <a name="id1212026"></a>
  81. <a class="link" href="nc_t_dist.html#math_toolkit.dist.dist_ref.dists.nc_t_dist.member_functions">Member
  82. Functions</a>
  83. </h5>
  84. <pre class="programlisting"><span class="identifier">non_central_t_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">v</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">lambda</span><span class="special">);</span>
  85. </pre>
  86. <p>
  87. Constructs a non-central t distribution with degrees of freedom parameter
  88. <span class="emphasis"><em>v</em></span> and non-centrality parameter <span class="emphasis"><em>delta</em></span>.
  89. </p>
  90. <p>
  91. Requires v &gt; 0 and finite delta, otherwise calls <a class="link" href="../../../main_overview/error_handling.html#domain_error">domain_error</a>.
  92. </p>
  93. <pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">degrees_of_freedom</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
  94. </pre>
  95. <p>
  96. Returns the parameter <span class="emphasis"><em>v</em></span> from which this object was
  97. constructed.
  98. </p>
  99. <pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">non_centrality</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
  100. </pre>
  101. <p>
  102. Returns the non-centrality parameter <span class="emphasis"><em>delta</em></span> from
  103. which this object was constructed.
  104. </p>
  105. <a name="math_toolkit.dist.dist_ref.dists.nc_t_dist.non_member_accessors"></a><h5>
  106. <a name="id1212164"></a>
  107. <a class="link" href="nc_t_dist.html#math_toolkit.dist.dist_ref.dists.nc_t_dist.non_member_accessors">Non-member
  108. Accessors</a>
  109. </h5>
  110. <p>
  111. All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member
  112. accessor functions</a> that are generic to all distributions are supported:
  113. <a class="link" href="../nmp.html#math.dist.cdf">Cumulative Distribution Function</a>,
  114. <a class="link" href="../nmp.html#math.dist.pdf">Probability Density Function</a>, <a class="link" href="../nmp.html#math.dist.quantile">Quantile</a>, <a class="link" href="../nmp.html#math.dist.hazard">Hazard
  115. Function</a>, <a class="link" href="../nmp.html#math.dist.chf">Cumulative Hazard Function</a>,
  116. <a class="link" href="../nmp.html#math.dist.mean">mean</a>, <a class="link" href="../nmp.html#math.dist.median">median</a>,
  117. <a class="link" href="../nmp.html#math.dist.mode">mode</a>, <a class="link" href="../nmp.html#math.dist.variance">variance</a>,
  118. <a class="link" href="../nmp.html#math.dist.sd">standard deviation</a>, <a class="link" href="../nmp.html#math.dist.skewness">skewness</a>,
  119. <a class="link" href="../nmp.html#math.dist.kurtosis">kurtosis</a>, <a class="link" href="../nmp.html#math.dist.kurtosis_excess">kurtosis_excess</a>,
  120. <a class="link" href="../nmp.html#math.dist.range">range</a> and <a class="link" href="../nmp.html#math.dist.support">support</a>.
  121. </p>
  122. <p>
  123. The domain of the random variable is [-&#8734;, +&#8734;].
  124. </p>
  125. <a name="math_toolkit.dist.dist_ref.dists.nc_t_dist.accuracy"></a><h5>
  126. <a name="id1212264"></a>
  127. <a class="link" href="nc_t_dist.html#math_toolkit.dist.dist_ref.dists.nc_t_dist.accuracy">Accuracy</a>
  128. </h5>
  129. <p>
  130. The following table shows the peak errors (in units of <a href="http://en.wikipedia.org/wiki/Machine_epsilon" target="_top">epsilon</a>)
  131. found on various platforms with various floating-point types. Unless
  132. otherwise specified, any floating-point type that is narrower than the
  133. one shown will have <a class="link" href="../../../backgrounders/relative_error.html#zero_error">effectively zero error</a>.
  134. </p>
  135. <div class="table">
  136. <a name="math_toolkit.dist.dist_ref.dists.nc_t_dist.errors_in_cdf_of_the_noncentral_t_distribution"></a><p class="title"><b>Table&#160;18.&#160;Errors In CDF of the Noncentral T Distribution</b></p>
  137. <div class="table-contents"><table class="table" summary="Errors In CDF of the Noncentral T Distribution">
  138. <colgroup>
  139. <col>
  140. <col>
  141. <col>
  142. </colgroup>
  143. <thead><tr>
  144. <th>
  145. <p>
  146. Significand Size
  147. </p>
  148. </th>
  149. <th>
  150. <p>
  151. Platform and Compiler
  152. </p>
  153. </th>
  154. <th>
  155. <p>
  156. &#957;,&#948; &lt; 600
  157. </p>
  158. </th>
  159. </tr></thead>
  160. <tbody>
  161. <tr>
  162. <td>
  163. <p>
  164. 53
  165. </p>
  166. </td>
  167. <td>
  168. <p>
  169. Win32, Visual C++ 8
  170. </p>
  171. </td>
  172. <td>
  173. <p>
  174. Peak=120 Mean=26
  175. </p>
  176. </td>
  177. </tr>
  178. <tr>
  179. <td>
  180. <p>
  181. 64
  182. </p>
  183. </td>
  184. <td>
  185. <p>
  186. RedHat Linux IA32, gcc-4.1.1
  187. </p>
  188. </td>
  189. <td>
  190. <p>
  191. Peak=121 Mean=26
  192. </p>
  193. </td>
  194. </tr>
  195. <tr>
  196. <td>
  197. <p>
  198. 64
  199. </p>
  200. </td>
  201. <td>
  202. <p>
  203. Redhat Linux IA64, gcc-3.4.4
  204. </p>
  205. </td>
  206. <td>
  207. <p>
  208. Peak=122 Mean=25
  209. </p>
  210. </td>
  211. </tr>
  212. <tr>
  213. <td>
  214. <p>
  215. 113
  216. </p>
  217. </td>
  218. <td>
  219. <p>
  220. HPUX IA64, aCC A.06.06
  221. </p>
  222. </td>
  223. <td>
  224. <p>
  225. Peak=115 Mean=24
  226. </p>
  227. </td>
  228. </tr>
  229. </tbody>
  230. </table></div>
  231. </div>
  232. <br class="table-break"><div class="caution"><table border="0" summary="Caution">
  233. <tr>
  234. <td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="../../../../../../../../../doc/src/images/caution.png"></td>
  235. <th align="left">Caution</th>
  236. </tr>
  237. <tr><td align="left" valign="top"><p>
  238. The complexity of the current algorithm is dependent upon &#948;<sup>2</sup>: consequently
  239. the time taken to evaluate the CDF increases rapidly for &#948; &gt; 500,
  240. likewise the accuracy decreases rapidly for very large &#948;.
  241. </p></td></tr>
  242. </table></div>
  243. <p>
  244. Accuracy for the quantile and PDF functions should be broadly similar,
  245. note however that the <span class="emphasis"><em>mode</em></span> is determined numerically
  246. and can not in principal be more accurate than the square root of machine
  247. epsilon.
  248. </p>
  249. <a name="math_toolkit.dist.dist_ref.dists.nc_t_dist.tests"></a><h5>
  250. <a name="id1212457"></a>
  251. <a class="link" href="nc_t_dist.html#math_toolkit.dist.dist_ref.dists.nc_t_dist.tests">Tests</a>
  252. </h5>
  253. <p>
  254. There are two sets of tests of this distribution: basic sanity checks
  255. compare this implementation to the test values given in "Computing
  256. discrete mixtures of continuous distributions: noncentral chisquare,
  257. noncentral t and the distribution of the square of the sample multiple
  258. correlation coefficient." Denise Benton, K. Krishnamoorthy, Computational
  259. Statistics &amp; Data Analysis 43 (2003) 249-267. While accuracy checks
  260. use test data computed with this implementation and arbitary precision
  261. interval arithmetic: this test data is believed to be accurate to at
  262. least 50 decimal places.
  263. </p>
  264. <a name="math_toolkit.dist.dist_ref.dists.nc_t_dist.implementation"></a><h5>
  265. <a name="id1212476"></a>
  266. <a class="link" href="nc_t_dist.html#math_toolkit.dist.dist_ref.dists.nc_t_dist.implementation">Implementation</a>
  267. </h5>
  268. <p>
  269. The CDF is computed using a modification of the method described in "Computing
  270. discrete mixtures of continuous distributions: noncentral chisquare,
  271. noncentral t and the distribution of the square of the sample multiple
  272. correlation coefficient." Denise Benton, K. Krishnamoorthy, Computational
  273. Statistics &amp; Data Analysis 43 (2003) 249-267.
  274. </p>
  275. <p>
  276. This uses the following formula for the CDF:
  277. </p>
  278. <p>
  279. <span class="inlinemediaobject"><img src="../../../../../equations/nc_t_ref2.png"></span>
  280. </p>
  281. <p>
  282. Where I<sub>x</sub>(a,b) is the incomplete beta function, and &#934;(x) is the normal
  283. CDF at x.
  284. </p>
  285. <p>
  286. Iteration starts at the largest of the Poisson weighting terms (at i
  287. = &#948;<sup>2</sup> / 2) and then proceeds in both directions as per Benton and Krishnamoorthy's
  288. paper.
  289. </p>
  290. <p>
  291. Alternatively, by considering what happens when t = &#8734;, we have x = 1,
  292. and therefore I<sub>x</sub>(a,b) = 1 and:
  293. </p>
  294. <p>
  295. <span class="inlinemediaobject"><img src="../../../../../equations/nc_t_ref3.png"></span>
  296. </p>
  297. <p>
  298. From this we can easily show that:
  299. </p>
  300. <p>
  301. <span class="inlinemediaobject"><img src="../../../../../equations/nc_t_ref4.png"></span>
  302. </p>
  303. <p>
  304. and therefore we have a means to compute either the probability or its
  305. complement directly without the risk of cancellation error. The crossover
  306. criterion for choosing whether to calculate the CDF or its complement
  307. is the same as for the <a class="link" href="nc_beta_dist.html" title="Noncentral Beta Distribution">Noncentral
  308. Beta Distribution</a>.
  309. </p>
  310. <p>
  311. The PDF can be computed by a very similar method using:
  312. </p>
  313. <p>
  314. <span class="inlinemediaobject"><img src="../../../../../equations/nc_t_ref5.png"></span>
  315. </p>
  316. <p>
  317. Where I<sub>x</sub><sup>'</sup>(a,b) is the derivative of the incomplete beta function.
  318. </p>
  319. <p>
  320. The quantile is calculated via the usual <a class="link" href="../../../toolkit/internals1/roots2.html" title="Root Finding Without Derivatives: Bisection, Bracket and TOMS748">derivative-free
  321. root-finding techniques</a>, with the initial guess taken as the quantile
  322. of a normal approximation to the noncentral T.
  323. </p>
  324. <p>
  325. There is no closed form for the mode, so this is computed via functional
  326. maximisation of the PDF.
  327. </p>
  328. <p>
  329. The remaining functions (mean, variance etc) are implemented using the
  330. formulas given in Weisstein, Eric W. "Noncentral Student's t-Distribution."
  331. From MathWorld--A Wolfram Web Resource. <a href="http://mathworld.wolfram.com/NoncentralStudentst-Distribution.html" target="_top">http://mathworld.wolfram.com/NoncentralStudentst-Distribution.html</a>
  332. and in the <a href="http://reference.wolfram.com/mathematica/ref/NoncentralStudentTDistribution.html" target="_top">Mathematica
  333. documentation</a>.
  334. </p>
  335. <p>
  336. Some analytic properties of noncentral distributions (particularly unimodality,
  337. and monotonicity of their modes) are surveyed and summarized by:
  338. </p>
  339. <p>
  340. Andrea van Aubel &amp; Wolfgang Gawronski, Applied Mathematics and Computation,
  341. 141 (2003) 3-12.
  342. </p>
  343. </div>
  344. <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
  345. <td align="left"></td>
  346. <td align="right"><div class="copyright-footer">Copyright &#169; 2006 , 2007, 2008, 2009, 2010 John Maddock, Paul A. Bristow,
  347. Hubert Holin, Xiaogang Zhang, Bruno Lalande, Johan R&#229;de, Gautam Sewani and
  348. Thijs van den Berg<p>
  349. Distributed under the Boost Software License, Version 1.0. (See accompanying
  350. 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>)
  351. </p>
  352. </div></td>
  353. </tr></table>
  354. <hr>
  355. <div class="spirit-nav">
  356. <a accesskey="p" href="nc_f_dist.html"><img src="../../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../dists.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="normal_dist.html"><img src="../../../../../../../../../doc/src/images/next.png" alt="Next"></a>
  357. </div>
  358. </body>
  359. </html>