[section:nc_t_dist Noncentral T Distribution]

``#include <boost/math/distributions/non_central_t.hpp>``

   namespace boost{ namespace math{ 

   template <class RealType = double, 
             class ``__Policy``   = ``__policy_class`` >
   class non_central_t_distribution;

   typedef non_central_t_distribution<> non_central_t;

   template <class RealType, class ``__Policy``>
   class non_central_t_distribution
   {
   public:
      typedef RealType  value_type;
      typedef Policy    policy_type;

      // Constructor:
      non_central_t_distribution(RealType v, RealType delta);

      // Accessor to degrees_of_freedom parameter v:
      RealType degrees_of_freedom()const;

      // Accessor to non-centrality parameter lambda:
      RealType non_centrality()const;
   };
   
   }} // namespaces
   
The noncentral T distribution is a generalization of the __students_t_distrib.
Let X have a normal distribution with mean [delta] and variance 1, and let 
[nu] S[super 2] have
a chi-squared distribution with degrees of freedom [nu]. Assume that 
X and S[super 2] are independent. The
distribution of t[sub [nu]]([delta])=X/S is called a 
noncentral t distribution with degrees of freedom [nu] and noncentrality
parameter [delta].

This gives the following PDF:

[equation nc_t_ref1]

where [sub 1]F[sub 1](a;b;x) is a confluent hypergeometric function.

The following graph illustrates how the distribution changes
for different values of [delta]:

[graph nc_t_pdf]

[h4 Member Functions]

      non_central_t_distribution(RealType v, RealType lambda);
      
Constructs a non-central t distribution with degrees of freedom
parameter /v/ and non-centrality parameter /delta/.

Requires v > 0 and finite delta, otherwise calls __domain_error.

      RealType degrees_of_freedom()const;
      
Returns the parameter /v/ from which this object was constructed.

      RealType non_centrality()const;
      
Returns the non-centrality parameter /delta/ from which this object was constructed.

[h4 Non-member Accessors]

All the [link math_toolkit.dist.dist_ref.nmp usual non-member accessor functions]
that are generic to all distributions are supported: __usual_accessors.

The domain of the random variable is \[-[infin], +[infin]\].

[h4 Accuracy]

The following table shows the peak errors
(in units of [@http://en.wikipedia.org/wiki/Machine_epsilon epsilon]) 
found on various platforms with various floating-point types.
Unless otherwise specified, any floating-point type that is narrower
than the one shown will have __zero_error.

[table Errors In CDF of the Noncentral T Distribution
[[Significand Size] [Platform and Compiler] [[nu],[delta] < 600]]
[[53] [Win32, Visual C++ 8] [Peak=120 Mean=26 ] ]
[[64] [RedHat Linux IA32, gcc-4.1.1] [Peak=121 Mean=26] ]

[[64] [Redhat Linux IA64, gcc-3.4.4] [Peak=122 Mean=25] ]

[[113] [HPUX IA64, aCC A.06.06] [Peak=115 Mean=24] ]
]

[caution The complexity of the current algorithm is dependent upon
[delta][super 2]: consequently the time taken to evaluate the CDF
increases rapidly for [delta] > 500, likewise the accuracy decreases
rapidly for very large [delta].]

Accuracy for the quantile and PDF functions should be broadly similar,
note however that the /mode/ is determined numerically and can not
in principal be more accurate than the square root of machine epsilon.

[h4 Tests]

There are two sets of tests of this distribution: basic sanity checks
compare this implementation to the test values given in
"Computing discrete mixtures of continuous
distributions: noncentral chisquare, noncentral t
and the distribution of the square of the sample
multiple correlation coefficient."
Denise Benton, K. Krishnamoorthy, 
Computational Statistics & Data Analysis 43 (2003) 249-267.
While accuracy checks use test data computed with this
implementation and arbitary precision interval arithmetic:
this test data is believed to be accurate to at least 50
decimal places.


[h4 Implementation]

The CDF is computed using a modification of the method
described in
"Computing discrete mixtures of continuous
distributions: noncentral chisquare, noncentral t
and the distribution of the square of the sample
multiple correlation coefficient."
Denise Benton, K. Krishnamoorthy, 
Computational Statistics & Data Analysis 43 (2003) 249-267.

This uses the following formula for the CDF:

[equation nc_t_ref2]

Where I[sub x](a,b) is the incomplete beta function, and
[Phi](x) is the normal CDF at x.

Iteration starts at the largest of the Poisson weighting terms
(at i = [delta][super 2] / 2) and then proceeds in both directions
as per Benton and Krishnamoorthy's paper.

Alternatively, by considering what happens when t = [infin], we have
x = 1, and therefore I[sub x](a,b) = 1 and:

[equation nc_t_ref3]

From this we can easily show that:

[equation nc_t_ref4]

and therefore we have a means to compute either the probability or its
complement directly without the risk of cancellation error.  The
crossover criterion for choosing whether to calculate the CDF or
it's complement is the same as for the 
__non_central_beta_distrib.

The PDF can be computed by a very similar method using:

[equation nc_t_ref5]

Where I[sub x][super '](a,b) is the derivative of the incomplete beta function.

The quantile is calculated via the usual 
[link math_toolkit.toolkit.internals1.roots2
derivative-free root-finding techniques],
with the initial guess taken as the quantile of a normal approximation
to the noncentral T.

There is no closed form for the mode, so this is computed via
functional maximisation of the PDF.

The remaining functions (mean, variance etc) are implemented
using the formulas given in 
Weisstein, Eric W. "Noncentral Student's t-Distribution." 
From MathWorld--A Wolfram Web Resource. 
[@http://mathworld.wolfram.com/NoncentralStudentst-Distribution.html
http://mathworld.wolfram.com/NoncentralStudentst-Distribution.html]
and in the 
[@http://reference.wolfram.com/mathematica/ref/NoncentralStudentTDistribution.html 
Mathematica documentation].

Some analytic properties of noncentral distributions
(particularly unimodality, and monotonicity of their modes)
are surveyed and summarized by:

Andrea van Aubel & Wolfgang Gawronski, Applied Mathematics and Computation, 141 (2003) 3-12.

[endsect] [/section:nc_t_dist]

[/ nc_t.qbk
  Copyright 2008 John Maddock and Paul A. Bristow.
  Distributed under the Boost Software License, Version 1.0.
  (See accompanying file LICENSE_1_0.txt or copy at
  http://www.boost.org/LICENSE_1_0.txt).
]

