]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/math/doc/distributions/nc_t.qbk
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / math / doc / distributions / nc_t.qbk
CommitLineData
7c673cae
FG
1[section:nc_t_dist Noncentral T Distribution]
2
3``#include <boost/math/distributions/non_central_t.hpp>``
4
5 namespace boost{ namespace math{
6
7 template <class RealType = double,
8 class ``__Policy`` = ``__policy_class`` >
9 class non_central_t_distribution;
10
11 typedef non_central_t_distribution<> non_central_t;
12
13 template <class RealType, class ``__Policy``>
14 class non_central_t_distribution
15 {
16 public:
17 typedef RealType value_type;
18 typedef Policy policy_type;
19
20 // Constructor:
21 non_central_t_distribution(RealType v, RealType delta);
22
23 // Accessor to degrees_of_freedom parameter v:
24 RealType degrees_of_freedom()const;
25
26 // Accessor to non-centrality parameter delta:
27 RealType non_centrality()const;
28 };
29
30 }} // namespaces
31
32The noncentral T distribution is a generalization of the __students_t_distrib.
33Let X have a normal distribution with mean [delta] and variance 1, and let
34[nu] S[super 2] have
35a chi-squared distribution with degrees of freedom [nu]. Assume that
36X and S[super 2] are independent. The
37distribution of t[sub [nu]]([delta])=X/S is called a
38noncentral t distribution with degrees of freedom [nu] and noncentrality
39parameter [delta].
40
41This gives the following PDF:
42
43[equation nc_t_ref1]
44
45where [sub 1]F[sub 1](a;b;x) is a confluent hypergeometric function.
46
47The following graph illustrates how the distribution changes
48for different values of [nu] and [delta]:
49
50[graph nc_t_pdf]
51[graph nc_t_cdf]
52
53[h4 Member Functions]
54
55 non_central_t_distribution(RealType v, RealType delta);
56
57Constructs a non-central t distribution with degrees of freedom
58parameter /v/ and non-centrality parameter /delta/.
59
60Requires /v/ > 0 (including positive infinity) and finite /delta/, otherwise calls __domain_error.
61
62 RealType degrees_of_freedom()const;
63
64Returns the parameter /v/ from which this object was constructed.
65
66 RealType non_centrality()const;
67
68Returns the non-centrality parameter /delta/ from which this object was constructed.
69
70[h4 Non-member Accessors]
71
72All the [link math_toolkit.dist_ref.nmp usual non-member accessor functions]
73that are generic to all distributions are supported: __usual_accessors.
74
75The domain of the random variable is \[-[infin], +[infin]\].
76
77[h4 Accuracy]
78
79The following table shows the peak errors
80(in units of [@http://en.wikipedia.org/wiki/Machine_epsilon epsilon])
81found on various platforms with various floating-point types.
82Unless otherwise specified, any floating-point type that is narrower
83than the one shown will have __zero_error.
84
85[table_non_central_t_CDF]
86
87[table_non_central_t_CDF_complement]
88
89[caution The complexity of the current algorithm is dependent upon
90[delta][super 2]: consequently the time taken to evaluate the CDF
91increases rapidly for [delta] > 500, likewise the accuracy decreases
92rapidly for very large [delta].]
93
94Accuracy for the quantile and PDF functions should be broadly similar.
95The /mode/ is determined numerically and cannot
96in principal be more accurate than the square root of
97floating-point type FPT epsilon, accessed using `boost::math::tools::epsilon<FPT>()`.
98For 64-bit `double`, epsilon is about 1e-16, so the fractional accuracy is limited to 1e-8.
99
100[h4 Tests]
101
102There are two sets of tests of this distribution:
103
104Basic sanity checks compare this implementation to the test values given in
105"Computing discrete mixtures of continuous
106distributions: noncentral chisquare, noncentral t
107and the distribution of the square of the sample
108multiple correlation coefficient."
109Denise Benton, K. Krishnamoorthy,
110Computational Statistics & Data Analysis 43 (2003) 249-267.
111
112Accuracy checks use test data computed with this
113implementation and arbitary precision interval arithmetic:
114this test data is believed to be accurate to at least 50
115decimal places.
116
117The cases of large (or infinite) [nu] and/or large [delta] has received special
118treatment to avoid catastrophic loss of accuracy.
119New tests have been added to confirm the improvement achieved.
120
121From Boost 1.52, degrees of freedom [nu] can be +[infin]
122when the normal distribution located at [delta]
123(equivalent to the central Student's t distribution)
124is used in place for accuracy and speed.
125
126[h4 Implementation]
127
128The CDF is computed using a modification of the method
129described in
130"Computing discrete mixtures of continuous
131distributions: noncentral chisquare, noncentral t
132and the distribution of the square of the sample
133multiple correlation coefficient."
134Denise Benton, K. Krishnamoorthy,
135Computational Statistics & Data Analysis 43 (2003) 249-267.
136
137This uses the following formula for the CDF:
138
139[equation nc_t_ref2]
140
141Where I[sub x](a,b) is the incomplete beta function, and
142[Phi](x) is the normal CDF at x.
143
144Iteration starts at the largest of the Poisson weighting terms
145(at i = [delta][super 2] / 2) and then proceeds in both directions
146as per Benton and Krishnamoorthy's paper.
147
148Alternatively, by considering what happens when t = [infin], we have
149x = 1, and therefore I[sub x](a,b) = 1 and:
150
151[equation nc_t_ref3]
152
153From this we can easily show that:
154
155[equation nc_t_ref4]
156
157and therefore we have a means to compute either the probability or its
158complement directly without the risk of cancellation error. The
159crossover criterion for choosing whether to calculate the CDF or
160its complement is the same as for the
161__non_central_beta_distrib.
162
163The PDF can be computed by a very similar method using:
164
165[equation nc_t_ref5]
166
167Where I[sub x][super '](a,b) is the derivative of the incomplete beta function.
168
169For both the PDF and CDF we switch to approximating the distribution by a
170Student's t distribution centred on [delta] when [nu] is very large.
171The crossover location appears to be when [delta]/(4[nu]) < [epsilon],
172this location was estimated by inspection of equation 2.6 in
173"A Comparison of Approximations To Percentiles of the
174Noncentral t-Distribution". H. Sahai and M. M. Ojeda,
175Revista Investigacion Operacional Vol 21, No 2, 2000, page 123.
176
177Equation 2.6 is a Fisher-Cornish expansion by Eeden and Johnson.
178The second term includes the ratio [delta]/(4[nu]),
179so when this term become negligible, this and following terms can be ignored,
180leaving just Student's t distribution centred on [delta].
181
182This was also confirmed by experimental testing.
183
184See also
185
186* "Some Approximations to the Percentage Points of the Noncentral
187t-Distribution". C. van Eeden. International Statistical Review, 29, 4-31.
188
189* "Continuous Univariate Distributions". N.L. Johnson, S. Kotz and
190N. Balkrishnan. 1995. John Wiley and Sons New York.
191
192The quantile is calculated via the usual
193__root_finding_without_derivatives method
194with the initial guess taken as the quantile of a normal approximation
195to the noncentral T.
196
197There is no closed form for the mode, so this is computed via
198functional maximisation of the PDF.
199
200The remaining functions (mean, variance etc) are implemented
201using the formulas given in
202Weisstein, Eric W. "Noncentral Student's t-Distribution."
203From MathWorld--A Wolfram Web Resource.
204[@http://mathworld.wolfram.com/NoncentralStudentst-Distribution.html
205http://mathworld.wolfram.com/NoncentralStudentst-Distribution.html]
206and in the
207[@http://reference.wolfram.com/mathematica/ref/NoncentralStudentTDistribution.html
208Mathematica documentation].
209
210Some analytic properties of noncentral distributions
211(particularly unimodality, and monotonicity of their modes)
212are surveyed and summarized by:
213
214Andrea van Aubel & Wolfgang Gawronski, Applied Mathematics and Computation, 141 (2003) 3-12.
215
216[endsect] [/section:nc_t_dist]
217
218[/ nc_t.qbk
219 Copyright 2008, 2012 John Maddock and Paul A. Bristow.
220 Distributed under the Boost Software License, Version 1.0.
221 (See accompanying file LICENSE_1_0.txt or copy at
222 http://www.boost.org/LICENSE_1_0.txt).
223]
224