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