Boost logo

Boost-Commit :

From: john_at_[hidden]
Date: 2008-02-23 04:52:41


Author: johnmaddock
Date: 2008-02-23 04:52:40 EST (Sat, 23 Feb 2008)
New Revision: 43401
URL: http://svn.boost.org/trac/boost/changeset/43401

Log:
Added non central distros to fwd.hpp.
Tightened up error handing in the NC beta and T.
Added NC T docs and equations.
Updated NC T tests.
Added:
   sandbox/math_toolkit/libs/math/doc/sf_and_dist/distributions/nc_t.qbk (contents, props changed)
   sandbox/math_toolkit/libs/math/doc/sf_and_dist/equations/nc_t_ref1.mml (contents, props changed)
   sandbox/math_toolkit/libs/math/doc/sf_and_dist/equations/nc_t_ref1.png (contents, props changed)
   sandbox/math_toolkit/libs/math/doc/sf_and_dist/equations/nc_t_ref1.svg (contents, props changed)
   sandbox/math_toolkit/libs/math/doc/sf_and_dist/equations/nc_t_ref2.mml (contents, props changed)
   sandbox/math_toolkit/libs/math/doc/sf_and_dist/equations/nc_t_ref2.png (contents, props changed)
   sandbox/math_toolkit/libs/math/doc/sf_and_dist/equations/nc_t_ref2.svg (contents, props changed)
   sandbox/math_toolkit/libs/math/doc/sf_and_dist/equations/nc_t_ref3.mml (contents, props changed)
   sandbox/math_toolkit/libs/math/doc/sf_and_dist/equations/nc_t_ref3.png (contents, props changed)
   sandbox/math_toolkit/libs/math/doc/sf_and_dist/equations/nc_t_ref3.svg (contents, props changed)
   sandbox/math_toolkit/libs/math/doc/sf_and_dist/equations/nc_t_ref4.mml (contents, props changed)
   sandbox/math_toolkit/libs/math/doc/sf_and_dist/equations/nc_t_ref4.png (contents, props changed)
   sandbox/math_toolkit/libs/math/doc/sf_and_dist/equations/nc_t_ref4.svg (contents, props changed)
   sandbox/math_toolkit/libs/math/doc/sf_and_dist/equations/nc_t_ref5.mml (contents, props changed)
   sandbox/math_toolkit/libs/math/doc/sf_and_dist/equations/nc_t_ref5.png (contents, props changed)
   sandbox/math_toolkit/libs/math/doc/sf_and_dist/equations/nc_t_ref5.svg (contents, props changed)
Text files modified:
   sandbox/math_toolkit/boost/math/distributions/fwd.hpp | 4 ++
   sandbox/math_toolkit/boost/math/distributions/non_central_beta.hpp | 64 +++++++++++++++++++++++++++++++++----
   sandbox/math_toolkit/boost/math/distributions/non_central_t.hpp | 67 ++++++++++++++++++++++++++++++++++-----
   sandbox/math_toolkit/libs/math/doc/sf_and_dist/dist_reference.qbk | 1
   sandbox/math_toolkit/libs/math/test/Jamfile.v2 | 25 ++++++++++++++
   sandbox/math_toolkit/libs/math/test/compile_test/instantiate.hpp | 31 ++++++++++++++++++
   sandbox/math_toolkit/libs/math/test/nct.ipp | 12 +++++++
   sandbox/math_toolkit/libs/math/test/test_nc_t.cpp | 9 ++++
   8 files changed, 194 insertions(+), 19 deletions(-)

Modified: sandbox/math_toolkit/boost/math/distributions/fwd.hpp
==============================================================================
--- sandbox/math_toolkit/boost/math/distributions/fwd.hpp (original)
+++ sandbox/math_toolkit/boost/math/distributions/fwd.hpp 2008-02-23 04:52:40 EST (Sat, 23 Feb 2008)
@@ -90,5 +90,9 @@
    typedef boost::math::triangular_distribution<Type, Policy> triangular;\
    typedef boost::math::uniform_distribution<Type, Policy> uniform;\
    typedef boost::math::weibull_distribution<Type, Policy> weibull;\
+ typedef boost::math::non_central_chi_squared_distribution<Type, Policy> non_central_chi_squared;\
+ typedef boost::math::non_central_beta_distribution<Type, Policy> non_central_beta;\
+ typedef boost::math::non_central_f_distribution<Type, Policy> non_central_f;\
+ typedef boost::math::non_central_t_distribution<Type, Policy> non_central_t;\
 
 #endif // BOOST_MATH_DISTRIBUTIONS_FWD_HPP

Modified: sandbox/math_toolkit/boost/math/distributions/non_central_beta.hpp
==============================================================================
--- sandbox/math_toolkit/boost/math/distributions/non_central_beta.hpp (original)
+++ sandbox/math_toolkit/boost/math/distributions/non_central_beta.hpp 2008-02-23 04:52:40 EST (Sat, 23 Feb 2008)
@@ -47,6 +47,8 @@
             int k = itrunc(l2);
             // Starting Poisson weight:
             T pois = gamma_p_derivative(T(k+1), l2, pol);
+ if(pois == 0)
+ return init_val;
             // Starting beta term:
             T beta = x < y
                ? ibeta(a + k, b, x, pol)
@@ -59,17 +61,22 @@
             T poisf(pois), betaf(beta), xtermf(xterm);
             T sum = init_val;
 
+ if((beta == 0) && (xterm == 0))
+ return init_val;
+
             //
             // Backwards recursion first, this is the stable
             // direction for recursion:
             //
             T last_term = 0;
+ boost::uintmax_t count = k;
             for(int i = k; i >= 0; --i)
             {
                T term = beta * pois;
                sum += term;
- if((fabs(term/sum) < errtol) && (last_term > term))
+ if((fabs(term/sum) < errtol) && (last_term >= term))
                {
+ count = k - i;
                   break;
                }
                pois *= i / l2;
@@ -77,7 +84,7 @@
                xterm *= (a + i - 1) / (x * (a + b + i - 2));
                last_term = term;
             }
- for(int i = k + 1; static_cast<boost::uintmax_t>(i - k) < max_iter; ++i)
+ for(int i = k + 1; ; ++i)
             {
                poisf *= l2 / i;
                xtermf *= (x * (a + b + i - 2)) / (a + i - 1);
@@ -89,6 +96,12 @@
                {
                   break;
                }
+ if(static_cast<boost::uintmax_t>(count + i - k) > max_iter)
+ {
+ return policies::raise_evaluation_error(
+ "cdf(non_central_beta_distribution<%1%>, %1%)",
+ "Series did not converge, closest value was %1%", sum, pol);
+ }
             }
             return sum;
          }
@@ -111,6 +124,8 @@
             int k = itrunc(l2);
             // Starting Poisson weight:
             T pois = gamma_p_derivative(T(k+1), l2, pol);
+ if(pois == 0)
+ return init_val;
             // Starting beta term:
             T beta = x < y
                ? ibetac(a + k, b, x, pol)
@@ -122,13 +137,16 @@
             xterm *= y / (a + b + k - 1);
             T poisf(pois), betaf(beta), xtermf(xterm);
             T sum = init_val;
+ if((beta == 0) && (xterm == 0))
+ return init_val;
             //
             // Forwards recursion first, this is the stable
             // direction for recursion, and the location
             // of the bulk of the sum:
             //
             T last_term = 0;
- for(int i = k + 1; static_cast<boost::uintmax_t>(i - k) < max_iter; ++i)
+ boost::uintmax_t count = 0;
+ for(int i = k + 1; ; ++i)
             {
                poisf *= l2 / i;
                xtermf *= (x * (a + b + i - 2)) / (a + i - 1);
@@ -138,8 +156,15 @@
                sum += term;
                if((fabs(term/sum) < errtol) && (last_term > term))
                {
+ count = i - k;
                   break;
                }
+ if(static_cast<boost::uintmax_t>(i - k) > max_iter)
+ {
+ return policies::raise_evaluation_error(
+ "cdf(non_central_beta_distribution<%1%>, %1%)",
+ "Series did not converge, closest value was %1%", sum, pol);
+ }
                last_term = term;
             }
             for(int i = k; i >= 0; --i)
@@ -150,6 +175,12 @@
                {
                   break;
                }
+ if(static_cast<boost::uintmax_t>(count + k - i) > max_iter)
+ {
+ return policies::raise_evaluation_error(
+ "cdf(non_central_beta_distribution<%1%>, %1%)",
+ "Series did not converge, closest value was %1%", sum, pol);
+ }
                pois *= i / l2;
                beta -= xterm;
                xterm *= (a + i - 1) / (x * (a + b + i - 2));
@@ -260,7 +291,10 @@
                while((boost::math::sign)(fb) == (boost::math::sign)(fa))
                {
                   if(count == 0)
- policies::raise_evaluation_error(function, "Unable to bracket root, last nearest value was %1%", b, pol);
+ {
+ b = policies::raise_evaluation_error(function, "Unable to bracket root, last nearest value was %1%", b, pol);
+ return std::make_pair(a, b);
+ }
                   //
                   // Heuristic: every 20 iterations we double the growth factor in case the
                   // initial guess was *really* bad !
@@ -295,7 +329,10 @@
                      return a > 0 ? std::make_pair(T(0), T(a)) : std::make_pair(T(a), T(0));
                   }
                   if(count == 0)
- policies::raise_evaluation_error(function, "Unable to bracket root, last nearest value was %1%", a, pol);
+ {
+ a = policies::raise_evaluation_error(function, "Unable to bracket root, last nearest value was %1%", a, pol);
+ return std::make_pair(a, b);
+ }
                   //
                   // Heuristic: every 20 iterations we double the growth factor in case the
                   // initial guess was *really* bad !
@@ -439,9 +476,12 @@
 
             if(max_iter >= policies::get_max_root_iterations<Policy>())
             {
- policies::raise_evaluation_error<value_type>(function, "Unable to locate solution in a reasonable time:"
+ return policies::raise_evaluation_error<RealType>(function, "Unable to locate solution in a reasonable time:"
                   " either there is no answer to quantile of the non central beta distribution"
- " or the answer is infinite. Current best guess is %1%", result, Policy());
+ " or the answer is infinite. Current best guess is %1%",
+ policies::checked_narrowing_cast<RealType, forwarding_policy>(
+ result,
+ function), Policy());
             }
             return policies::checked_narrowing_cast<RealType, forwarding_policy>(
                result,
@@ -477,18 +517,20 @@
             //
             // Stable backwards recursion first:
             //
+ boost::uintmax_t count = k;
             for(int i = k; i >= 0; --i)
             {
                T term = beta * pois;
                sum += term;
                if((fabs(term/sum) < errtol) || (term == 0))
                {
+ count = k - i;
                   break;
                }
                pois *= i / l2;
                beta *= (a + i - 1) / (x * (a + i + b - 1));
             }
- for(int i = k + 1; static_cast<boost::uintmax_t>(i - k) < max_iter; ++i)
+ for(int i = k + 1; ; ++i)
             {
                poisf *= l2 / i;
                betaf *= x * (a + b + i - 1) / (a + i - 1);
@@ -499,6 +541,12 @@
                {
                   break;
                }
+ if(static_cast<boost::uintmax_t>(count + i - k) > max_iter)
+ {
+ return policies::raise_evaluation_error(
+ "pdf(non_central_beta_distribution<%1%>, %1%)",
+ "Series did not converge, closest value was %1%", sum, pol);
+ }
             }
             return sum;
          }

Modified: sandbox/math_toolkit/boost/math/distributions/non_central_t.hpp
==============================================================================
--- sandbox/math_toolkit/boost/math/distributions/non_central_t.hpp (original)
+++ sandbox/math_toolkit/boost/math/distributions/non_central_t.hpp 2008-02-23 04:52:40 EST (Sat, 23 Feb 2008)
@@ -44,6 +44,8 @@
             T pois = gamma_p_derivative(T(k+1), d2, pol)
                * tgamma_delta_ratio(T(k + 1), T(0.5f))
                * delta / constants::root_two<T>();
+ if(pois == 0)
+ return init_val;
             // Starting beta term:
             T beta = x < y
                ? ibeta(T(k + 1), n / 2, x, pol)
@@ -55,12 +57,14 @@
             xterm *= y / (n / 2 + k);
             T poisf(pois), betaf(beta), xtermf(xterm);
             T sum = init_val;
+ if((xterm == 0) && (beta == 0))
+ return init_val;
 
             //
             // Backwards recursion first, this is the stable
             // direction for recursion:
             //
- int count = 0;
+ boost::uintmax_t count = 0;
             for(int i = k; i >= 0; --i)
             {
                T term = beta * pois;
@@ -72,7 +76,7 @@
                xterm *= (i) / (x * (n / 2 + i - 1));
                ++count;
             }
- for(int i = k + 1; i - k < max_iter; ++i)
+ for(int i = k + 1; ; ++i)
             {
                poisf *= d2 / (i + 0.5f);
                xtermf *= (x * (n / 2 + i - 1)) / (i);
@@ -82,6 +86,12 @@
                if(fabs(term/sum) < errtol)
                   break;
                ++count;
+ if(count > max_iter)
+ {
+ return policies::raise_evaluation_error(
+ "cdf(non_central_t_distribution<%1%>, %1%)",
+ "Series did not converge, closest value was %1%", sum, pol);
+ }
             }
             return sum;
          }
@@ -105,6 +115,8 @@
             T pois = gamma_p_derivative(T(k+1), d2, pol)
                * tgamma_delta_ratio(T(k + 1), T(0.5f))
                * delta / constants::root_two<T>();
+ if(pois == 0)
+ return init_val;
             // Starting beta term:
             T beta = x < y
                ? ibetac(T(k + 1), n / 2, x, pol)
@@ -116,12 +128,14 @@
             xterm *= y / (n / 2 + k);
             T poisf(pois), betaf(beta), xtermf(xterm);
             T sum = init_val;
+ if((xterm == 0) && (beta == 0))
+ return init_val;
 
             //
             // Forward recursion first, this is the stable direction:
             //
- int count = 0;
- for(int i = k + 1; i - k < max_iter; ++i)
+ boost::uintmax_t count = 0;
+ for(int i = k + 1; ; ++i)
             {
                poisf *= d2 / (i + 0.5f);
                xtermf *= (x * (n / 2 + i - 1)) / (i);
@@ -131,6 +145,12 @@
                sum += term;
                if(fabs(term/sum) < errtol)
                   break;
+ if(count > max_iter)
+ {
+ return policies::raise_evaluation_error(
+ "cdf(non_central_t_distribution<%1%>, %1%)",
+ "Series did not converge, closest value was %1%", sum, pol);
+ }
                ++count;
             }
             //
@@ -146,6 +166,12 @@
                beta -= xterm;
                xterm *= (i) / (x * (n / 2 + i - 1));
                ++count;
+ if(count > max_iter)
+ {
+ return policies::raise_evaluation_error(
+ "cdf(non_central_t_distribution<%1%>, %1%)",
+ "Series did not converge, closest value was %1%", sum, pol);
+ }
             }
             return sum;
          }
@@ -217,6 +243,7 @@
          template <class T, class Policy>
          T non_central_t_quantile(T v, T delta, T p, T q, const Policy&)
          {
+ BOOST_MATH_STD_USING
             static const char* function = "quantile(non_central_t_distribution<%1%>, %1%)";
             typedef typename policies::evaluation<T, Policy>::type value_type;
             typedef typename policies::normalise<
@@ -310,12 +337,14 @@
                : ibeta_derivative(n / 2, T(k + 1), y, pol);
             T poisf(pois), xtermf(xterm);
             T sum = init_val;
+ if((pois == 0) || (xterm == 0))
+ return init_val;
 
             //
             // Backwards recursion first, this is the stable
             // direction for recursion:
             //
- int count = 0;
+ boost::uintmax_t count = 0;
             for(int i = k; i >= 0; --i)
             {
                T term = xterm * pois;
@@ -325,8 +354,14 @@
                pois *= (i + 0.5f) / d2;
                xterm *= (i) / (x * (n / 2 + i));
                ++count;
+ if(count > max_iter)
+ {
+ return policies::raise_evaluation_error(
+ "pdf(non_central_t_distribution<%1%>, %1%)",
+ "Series did not converge, closest value was %1%", sum, pol);
+ }
             }
- for(int i = k + 1; i - k < max_iter; ++i)
+ for(int i = k + 1; ; ++i)
             {
                poisf *= d2 / (i + 0.5f);
                xtermf *= (x * (n / 2 + i)) / (i);
@@ -335,6 +370,12 @@
                if((fabs(term/sum) < errtol) || (term == 0))
                   break;
                ++count;
+ if(count > max_iter)
+ {
+ return policies::raise_evaluation_error(
+ "pdf(non_central_t_distribution<%1%>, %1%)",
+ "Series did not converge, closest value was %1%", sum, pol);
+ }
             }
             return sum;
          }
@@ -342,6 +383,7 @@
          template <class T, class Policy>
          T non_central_t_pdf(T n, T delta, T t, const Policy& pol)
          {
+ BOOST_MATH_STD_USING
             //
             // For t < 0 we have to use the reflection formula:
             //
@@ -379,19 +421,20 @@
             //
             // Calculate pdf:
             //
- T dt = 2 * n * t / (n * n + 2 * n * t * t + t * t * t * t);
+ T dt = n * t / (n * n + 2 * n * t * t + t * t * t * t);
             T result = non_central_beta_pdf(a, b, d2, x, y, pol);
- T tol = tools::epsilon<T>() * result * 10;
+ T tol = tools::epsilon<T>() * result * 500;
             result = non_central_t2_pdf(n, delta, x, y, pol, result);
             if(result <= tol)
                result = 0;
- result *= dt / 2;
+ result *= dt;
             return result;
          }
 
          template <class T, class Policy>
          T mean(T v, T delta, const Policy& pol)
          {
+ BOOST_MATH_STD_USING
             return delta * sqrt(v / 2) * tgamma_delta_ratio((v - 1) * 0.5f, T(0.5f), pol);
          }
 
@@ -407,6 +450,7 @@
          template <class T, class Policy>
          T skewness(T v, T delta, const Policy& pol)
          {
+ BOOST_MATH_STD_USING
             T mean = boost::math::detail::mean(v, delta, pol);
             T l2 = delta * delta;
             T var = ((l2 + 1) * v) / (v - 2) - mean * mean;
@@ -420,6 +464,7 @@
          template <class T, class Policy>
          T kurtosis_excess(T v, T delta, const Policy& pol)
          {
+ BOOST_MATH_STD_USING
             T mean = boost::math::detail::mean(v, delta, pol);
             T l2 = delta * delta;
             T var = ((l2 + 1) * v) / (v - 2) - mean * mean;
@@ -505,6 +550,8 @@
             Policy()))
                return (RealType)r;
 
+ BOOST_MATH_STD_USING
+
          RealType m = v < 3 ? 0 : detail::mean(v, l, Policy());
          RealType var = v < 4 ? 1 : detail::variance(v, l, Policy());
 
@@ -512,7 +559,7 @@
             dist,
             m,
             function,
- var);
+ sqrt(var));
       }
 
       template <class RealType, class Policy>

Modified: sandbox/math_toolkit/libs/math/doc/sf_and_dist/dist_reference.qbk
==============================================================================
--- sandbox/math_toolkit/libs/math/doc/sf_and_dist/dist_reference.qbk (original)
+++ sandbox/math_toolkit/libs/math/doc/sf_and_dist/dist_reference.qbk 2008-02-23 04:52:40 EST (Sat, 23 Feb 2008)
@@ -18,6 +18,7 @@
 [include distributions/nc_beta.qbk]
 [include distributions/nc_chi_squared.qbk]
 [include distributions/nc_f.qbk]
+[include distributions/nc_t.qbk]
 [include distributions/normal.qbk]
 [include distributions/pareto.qbk]
 [include distributions/poisson.qbk]

Added: sandbox/math_toolkit/libs/math/doc/sf_and_dist/distributions/nc_t.qbk
==============================================================================
--- (empty file)
+++ sandbox/math_toolkit/libs/math/doc/sf_and_dist/distributions/nc_t.qbk 2008-02-23 04:52:40 EST (Sat, 23 Feb 2008)
@@ -0,0 +1,189 @@
+[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]:
+
+[$../graphs/nc_t_pdf.png]
+
+[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].
+
+[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).
+]
+

Added: sandbox/math_toolkit/libs/math/doc/sf_and_dist/equations/nc_t_ref1.mml
==============================================================================
--- (empty file)
+++ sandbox/math_toolkit/libs/math/doc/sf_and_dist/equations/nc_t_ref1.mml 2008-02-23 04:52:40 EST (Sat, 23 Feb 2008)
@@ -0,0 +1,259 @@
+<?xml version='1.0'?>
+<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN'
+ 'http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd'
+ [<!ENTITY mathml 'http://www.w3.org/1998/Math/MathML'>]>
+<html xmlns='http://www.w3.org/1999/xhtml'>
+<head><title>nc_t_ref1</title>
+<!-- MathML created with MathCast Equation Editor version 0.88 -->
+</head>
+<body>
+<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
+ <mrow>
+ <mi>f</mi>
+ <mfenced>
+ <mrow>
+ <mi>x</mi>
+ <mo>;</mo>
+ <mi>&#x03BD;</mi>
+ <mo>;</mo>
+ <mi>&#x03B4;</mi>
+ </mrow>
+ </mfenced>
+ <mspace width="1em"/>
+ <mo>=</mo>
+ <mspace width="1em"/>
+ <mfrac>
+ <mrow>
+ <msup>
+ <mi>&#x03BD;</mi>
+ <mrow>
+ <mfrac>
+ <mi>&#x03BD;</mi>
+ <mn>2</mn>
+ </mfrac>
+ </mrow>
+ </msup>
+ <mi>&#x03BD;</mi>
+ <mo>!</mo>
+ </mrow>
+ <mrow>
+ <msup>
+ <mn>2</mn>
+ <mi>&#x03BD;</mi>
+ </msup>
+ <msup>
+ <mi>e</mi>
+ <mrow>
+ <mfrac>
+ <msup>
+ <mi>&#x03B4;</mi>
+ <mn>2</mn>
+ </msup>
+ <mn>2</mn>
+ </mfrac>
+ </mrow>
+ </msup>
+ <msup>
+ <mfenced>
+ <mrow>
+ <mi>&#x03BD;</mi>
+ <mo>+</mo>
+ <msup>
+ <mi>x</mi>
+ <mn>2</mn>
+ </msup>
+ </mrow>
+ </mfenced>
+ <mrow>
+ <mfrac>
+ <mi>&#x03BD;</mi>
+ <mn>2</mn>
+ </mfrac>
+ </mrow>
+ </msup>
+ <mi>&#x0393;</mi>
+ <mfenced>
+ <mrow>
+ <mfrac>
+ <mi>&#x03BD;</mi>
+ <mn>2</mn>
+ </mfrac>
+ </mrow>
+ </mfenced>
+ </mrow>
+ </mfrac>
+ <mfenced>
+ <mrow>
+ <mfrac>
+ <mrow>
+ <msqrt>
+ <mn>2</mn>
+ </msqrt>
+ <mi>&#x03B4;</mi>
+ <msub>
+ <mi>x</mi>
+ <mn>1</mn>
+ </msub>
+ <msub>
+ <mi>F</mi>
+ <mn>1</mn>
+ </msub>
+ <mfenced>
+ <mrow>
+ <mfrac>
+ <mi>n</mi>
+ <mn>2</mn>
+ </mfrac>
+ <mo>+</mo>
+ <mn>1</mn>
+ <mo>;</mo>
+ <mfrac>
+ <mn>3</mn>
+ <mn>2</mn>
+ </mfrac>
+ <mo>;</mo>
+ <mfrac>
+ <mrow>
+ <msup>
+ <mi>&#x03B4;</mi>
+ <mn>2</mn>
+ </msup>
+ <msup>
+ <mi>x</mi>
+ <mn>2</mn>
+ </msup>
+ </mrow>
+ <mrow>
+ <mn>2</mn>
+ <mfenced>
+ <mrow>
+ <mi>n</mi>
+ <mo>+</mo>
+ <msup>
+ <mi>x</mi>
+ <mn>2</mn>
+ </msup>
+ </mrow>
+ </mfenced>
+ </mrow>
+ </mfrac>
+ </mrow>
+ </mfenced>
+ </mrow>
+ <mrow>
+ <mfenced>
+ <mrow>
+ <mi>&#x03BD;</mi>
+ <mo>+</mo>
+ <msup>
+ <mi>x</mi>
+ <mn>2</mn>
+ </msup>
+ </mrow>
+ </mfenced>
+ <mi>&#x0393;</mi>
+ <mfenced>
+ <mrow>
+ <mfrac>
+ <mn>1</mn>
+ <mn>2</mn>
+ </mfrac>
+ <mfenced>
+ <mrow>
+ <mi>&#x03BD;</mi>
+ <mo>+</mo>
+ <mn>1</mn>
+ </mrow>
+ </mfenced>
+ </mrow>
+ </mfenced>
+ </mrow>
+ </mfrac>
+ <mo>+</mo>
+ <mfrac>
+ <mrow>
+ <msub>
+ <mi/>
+ <mn>1</mn>
+ </msub>
+ <msub>
+ <mi>F</mi>
+ <mn>1</mn>
+ </msub>
+ <mfenced>
+ <mrow>
+ <mfrac>
+ <mn>1</mn>
+ <mn>2</mn>
+ </mfrac>
+ <mfenced>
+ <mrow>
+ <mi>n</mi>
+ <mo>+</mo>
+ <mn>1</mn>
+ </mrow>
+ </mfenced>
+ <mo>;</mo>
+ <mfrac>
+ <mn>1</mn>
+ <mn>2</mn>
+ </mfrac>
+ <mo>;</mo>
+ <mfrac>
+ <mrow>
+ <msup>
+ <mi>&#x03B4;</mi>
+ <mn>2</mn>
+ </msup>
+ <msup>
+ <mi>x</mi>
+ <mn>2</mn>
+ </msup>
+ </mrow>
+ <mrow>
+ <mn>2</mn>
+ <mfenced>
+ <mrow>
+ <mi>&#x03BD;</mi>
+ <mo>+</mo>
+ <msup>
+ <mi>x</mi>
+ <mn>2</mn>
+ </msup>
+ </mrow>
+ </mfenced>
+ </mrow>
+ </mfrac>
+ </mrow>
+ </mfenced>
+ </mrow>
+ <mrow>
+ <msqrt>
+ <mrow>
+ <mi>&#x03BD;</mi>
+ <mo>+</mo>
+ <msup>
+ <mi>x</mi>
+ <mn>2</mn>
+ </msup>
+ </mrow>
+ </msqrt>
+ <mi>&#x0393;</mi>
+ <mfenced>
+ <mrow>
+ <mfrac>
+ <mi>&#x03BD;</mi>
+ <mn>2</mn>
+ </mfrac>
+ <mo>+</mo>
+ <mn>1</mn>
+ </mrow>
+ </mfenced>
+ </mrow>
+ </mfrac>
+ </mrow>
+ </mfenced>
+ </mrow>
+</math>
+</body>
+</html>

Added: sandbox/math_toolkit/libs/math/doc/sf_and_dist/equations/nc_t_ref1.png
==============================================================================
Binary file. No diff available.

Added: sandbox/math_toolkit/libs/math/doc/sf_and_dist/equations/nc_t_ref1.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_toolkit/libs/math/doc/sf_and_dist/equations/nc_t_ref2.mml
==============================================================================
--- (empty file)
+++ sandbox/math_toolkit/libs/math/doc/sf_and_dist/equations/nc_t_ref2.mml 2008-02-23 04:52:40 EST (Sat, 23 Feb 2008)
@@ -0,0 +1,231 @@
+<?xml version='1.0'?>
+<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN'
+ 'http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd'
+ [<!ENTITY mathml 'http://www.w3.org/1998/Math/MathML'>]>
+<html xmlns='http://www.w3.org/1999/xhtml'>
+<head><title>nc_t_ref2</title>
+<!-- MathML created with MathCast Equation Editor version 0.88 -->
+</head>
+<body>
+<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
+ <mrow>
+ <mtable>
+ <mtr>
+ <mtd>
+ <mi>P</mi>
+ <mfenced>
+ <mrow>
+ <mi>t</mi>
+ <mo>;</mo>
+ <mi>&#x03BD;</mi>
+ <mo>;</mo>
+ <mi>&#x03B4;</mi>
+ </mrow>
+ </mfenced>
+ <mspace width="1em"/>
+ <mo>=</mo>
+ <mspace width="1em"/>
+ <mi>&#x03A6;</mi>
+ <mfenced>
+ <mrow>
+ <mo>&#x2212;</mo>
+ <mi>&#x03B4;</mi>
+ </mrow>
+ </mfenced>
+ <mo>+</mo>
+ <mfrac>
+ <mn>1</mn>
+ <mn>2</mn>
+ </mfrac>
+ <munderover>
+ <mo>&#x2211;</mo>
+ <mrow>
+ <mi>i</mi>
+ <mo>=</mo>
+ <mn>0</mn>
+ </mrow>
+ <mi>&#x221E;</mi>
+ </munderover>
+ <mfenced>
+ <mrow>
+ <msub>
+ <mi>P</mi>
+ <mi>i</mi>
+ </msub>
+ <msub>
+ <mi>I</mi>
+ <mi>x</mi>
+ </msub>
+ <mfenced>
+ <mrow>
+ <mrow>
+ <mi>i</mi>
+ <mo>+</mo>
+ <mfrac>
+ <mn>1</mn>
+ <mn>2</mn>
+ </mfrac>
+ </mrow>
+ <mo>,</mo>
+ <mfrac>
+ <mi>&#x03BD;</mi>
+ <mn>2</mn>
+ </mfrac>
+ </mrow>
+ </mfenced>
+ <mo>+</mo>
+ <mfrac>
+ <mi>&#x03B4;</mi>
+ <mrow>
+ <msqrt>
+ <mn>2</mn>
+ </msqrt>
+ </mrow>
+ </mfrac>
+ <msub>
+ <mi>Q</mi>
+ <mi>i</mi>
+ </msub>
+ <msub>
+ <mi>I</mi>
+ <mi>x</mi>
+ </msub>
+ <mfenced>
+ <mrow>
+ <mi>i</mi>
+ <mo>+</mo>
+ <mn>1,</mn>
+ <mfrac>
+ <mi>&#x03BD;</mi>
+ <mn>2</mn>
+ </mfrac>
+ </mrow>
+ </mfenced>
+ </mrow>
+ </mfenced>
+ </mtd>
+ </mtr>
+ <mtr>
+ <mtd>
+ <msub>
+ <mi>P</mi>
+ <mi>i</mi>
+ </msub>
+ <mo>=</mo>
+ <msup>
+ <mi>e</mi>
+ <mrow>
+ <mo>&#x2212;</mo>
+ <mfrac>
+ <mrow>
+ <msup>
+ <mi>&#x03B4;</mi>
+ <mn>2</mn>
+ </msup>
+ </mrow>
+ <mn>2</mn>
+ </mfrac>
+ </mrow>
+ </msup>
+ <mfrac>
+ <msup>
+ <mfenced>
+ <mrow>
+ <mfrac>
+ <msup>
+ <mi>&#x03B4;</mi>
+ <mn>2</mn>
+ </msup>
+ <mn>2</mn>
+ </mfrac>
+ </mrow>
+ </mfenced>
+ <mi>i</mi>
+ </msup>
+ <mrow>
+ <mi>i</mi>
+ <mo>!</mo>
+ </mrow>
+ </mfrac>
+ <mspace width="1em"/>
+ <mo>,</mo>
+ <mspace width="1em"/>
+ <msub>
+ <mi>Q</mi>
+ <mi>i</mi>
+ </msub>
+ <mo>=</mo>
+ <msup>
+ <mi>e</mi>
+ <mrow>
+ <mo>&#x2212;</mo>
+ <mfrac>
+ <mrow>
+ <msup>
+ <mi>&#x03B4;</mi>
+ <mn>2</mn>
+ </msup>
+ </mrow>
+ <mn>2</mn>
+ </mfrac>
+ </mrow>
+ </msup>
+ <mfrac>
+ <msup>
+ <mfenced>
+ <mrow>
+ <mfrac>
+ <msup>
+ <mi>&#x03B4;</mi>
+ <mn>2</mn>
+ </msup>
+ <mn>2</mn>
+ </mfrac>
+ </mrow>
+ </mfenced>
+ <mi>i</mi>
+ </msup>
+ <mrow>
+ <mi>&#x0393;</mi>
+ <mfenced>
+ <mrow>
+ <mi>i</mi>
+ <mo>+</mo>
+ <mfrac>
+ <mn>3</mn>
+ <mn>2</mn>
+ </mfrac>
+ </mrow>
+ </mfenced>
+ </mrow>
+ </mfrac>
+ <mspace width="1em"/>
+ <mo>,</mo>
+ <mspace width="1em"/>
+ <mi>x</mi>
+ <mo>=</mo>
+ <mfrac>
+ <mrow>
+ <msup>
+ <mi>t</mi>
+ <mn>2</mn>
+ </msup>
+ </mrow>
+ <mfenced>
+ <mrow>
+ <mi>&#x03BD;</mi>
+ <mo>+</mo>
+ <msup>
+ <mi>t</mi>
+ <mn>2</mn>
+ </msup>
+ </mrow>
+ </mfenced>
+ </mfrac>
+ </mtd>
+ </mtr>
+ </mtable>
+ </mrow>
+</math>
+</body>
+</html>

Added: sandbox/math_toolkit/libs/math/doc/sf_and_dist/equations/nc_t_ref2.png
==============================================================================
Binary file. No diff available.

Added: sandbox/math_toolkit/libs/math/doc/sf_and_dist/equations/nc_t_ref2.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_toolkit/libs/math/doc/sf_and_dist/equations/nc_t_ref3.mml
==============================================================================
--- (empty file)
+++ sandbox/math_toolkit/libs/math/doc/sf_and_dist/equations/nc_t_ref3.mml 2008-02-23 04:52:40 EST (Sat, 23 Feb 2008)
@@ -0,0 +1,70 @@
+<?xml version='1.0'?>
+<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN'
+ 'http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd'
+ [<!ENTITY mathml 'http://www.w3.org/1998/Math/MathML'>]>
+<html xmlns='http://www.w3.org/1999/xhtml'>
+<head><title>nc_t_ref3</title>
+<!-- MathML created with MathCast Equation Editor version 0.88 -->
+</head>
+<body>
+<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
+ <mrow>
+ <mi>P</mi>
+ <mfenced>
+ <mrow>
+ <mi>&#x221E;</mi>
+ <mo>;</mo>
+ <mi>&#x03BD;</mi>
+ <mo>;</mo>
+ <mi>&#x03B4;</mi>
+ </mrow>
+ </mfenced>
+ <mo>=</mo>
+ <mn>1</mn>
+ <mo>=</mo>
+ <mi>&#x03A6;</mi>
+ <mfenced>
+ <mrow>
+ <mo>&#x2212;</mo>
+ <mi>&#x03B4;</mi>
+ </mrow>
+ </mfenced>
+ <mo>+</mo>
+ <mfrac>
+ <mn>1</mn>
+ <mn>2</mn>
+ </mfrac>
+ <munderover>
+ <mo>&#x2211;</mo>
+ <mrow>
+ <mi>i</mi>
+ <mo>=</mo>
+ <mn>0</mn>
+ </mrow>
+ <mi>&#x221E;</mi>
+ </munderover>
+ <mfenced>
+ <mrow>
+ <msub>
+ <mi>P</mi>
+ <mi>i</mi>
+ </msub>
+ <mo>+</mo>
+ <mfrac>
+ <mi>&#x03B4;</mi>
+ <mrow>
+ <msqrt>
+ <mn>2</mn>
+ </msqrt>
+ </mrow>
+ </mfrac>
+ <msub>
+ <mi>Q</mi>
+ <mi>i</mi>
+ </msub>
+ </mrow>
+ </mfenced>
+ </mrow>
+</math>
+</body>
+</html>

Added: sandbox/math_toolkit/libs/math/doc/sf_and_dist/equations/nc_t_ref3.png
==============================================================================
Binary file. No diff available.

Added: sandbox/math_toolkit/libs/math/doc/sf_and_dist/equations/nc_t_ref3.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_toolkit/libs/math/doc/sf_and_dist/equations/nc_t_ref4.mml
==============================================================================
--- (empty file)
+++ sandbox/math_toolkit/libs/math/doc/sf_and_dist/equations/nc_t_ref4.mml 2008-02-23 04:52:40 EST (Sat, 23 Feb 2008)
@@ -0,0 +1,125 @@
+<?xml version='1.0'?>
+<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN'
+ 'http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd'
+ [<!ENTITY mathml 'http://www.w3.org/1998/Math/MathML'>]>
+<html xmlns='http://www.w3.org/1999/xhtml'>
+<head><title>nc_t_ref4</title>
+<!-- MathML created with MathCast Equation Editor version 0.88 -->
+</head>
+<body>
+<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
+ <mrow>
+ <mn>1</mn>
+ <mo>&#x2212;</mo>
+ <mi>P</mi>
+ <mfenced>
+ <mrow>
+ <mi>t</mi>
+ <mo>;</mo>
+ <mi>&#x03BD;</mi>
+ <mo>;</mo>
+ <mi>&#x03B4;</mi>
+ </mrow>
+ </mfenced>
+ <mspace width="1em"/>
+ <mo>=</mo>
+ <mspace width="1em"/>
+ <mfrac>
+ <mn>1</mn>
+ <mn>2</mn>
+ </mfrac>
+ <munderover>
+ <mo>&#x2211;</mo>
+ <mrow>
+ <mi>i</mi>
+ <mo>=</mo>
+ <mn>0</mn>
+ </mrow>
+ <mi>&#x221E;</mi>
+ </munderover>
+ <mfenced>
+ <mrow>
+ <msub>
+ <mi>P</mi>
+ <mi>i</mi>
+ </msub>
+ <msub>
+ <mi>I</mi>
+ <mi>y</mi>
+ </msub>
+ <mfenced>
+ <mrow>
+ <mrow>
+ <mfrac>
+ <mi>&#x03BD;</mi>
+ <mn>2</mn>
+ </mfrac>
+ </mrow>
+ <mo>,</mo>
+ <mrow>
+ <mi>i</mi>
+ <mo>+</mo>
+ <mfrac>
+ <mn>1</mn>
+ <mn>2</mn>
+ </mfrac>
+ </mrow>
+ </mrow>
+ </mfenced>
+ <mo>+</mo>
+ <mfrac>
+ <mi>&#x03B4;</mi>
+ <mrow>
+ <msqrt>
+ <mn>2</mn>
+ </msqrt>
+ </mrow>
+ </mfrac>
+ <msub>
+ <mi>Q</mi>
+ <mi>i</mi>
+ </msub>
+ <msub>
+ <mi>I</mi>
+ <mi>y</mi>
+ </msub>
+ <mfenced>
+ <mrow>
+ <mrow>
+ <mfrac>
+ <mi>&#x03BD;</mi>
+ <mn>2</mn>
+ </mfrac>
+ </mrow>
+ <mo>,</mo>
+ <mi>i</mi>
+ <mo>+</mo>
+ <mn>1</mn>
+ </mrow>
+ </mfenced>
+ </mrow>
+ </mfenced>
+ <mspace width="1em"/>
+ <mo>;</mo>
+ <mspace width="1em"/>
+ <mi>y</mi>
+ <mo>=</mo>
+ <mn>1</mn>
+ <mo>&#x2212;</mo>
+ <mi>x</mi>
+ <mo>=</mo>
+ <mfrac>
+ <mi>&#x03BD;</mi>
+ <mrow>
+ <mi>&#x03BD;</mi>
+ <mo>+</mo>
+ <msup>
+ <mi>t</mi>
+ <mn>2</mn>
+ </msup>
+ </mrow>
+ </mfrac>
+ </mrow>
+</math>
+</body>
+</html>

Added: sandbox/math_toolkit/libs/math/doc/sf_and_dist/equations/nc_t_ref4.png
==============================================================================
Binary file. No diff available.

Added: sandbox/math_toolkit/libs/math/doc/sf_and_dist/equations/nc_t_ref4.svg
==============================================================================
Binary file. No diff available.

Added: sandbox/math_toolkit/libs/math/doc/sf_and_dist/equations/nc_t_ref5.mml
==============================================================================
--- (empty file)
+++ sandbox/math_toolkit/libs/math/doc/sf_and_dist/equations/nc_t_ref5.mml 2008-02-23 04:52:40 EST (Sat, 23 Feb 2008)
@@ -0,0 +1,128 @@
+<?xml version='1.0'?>
+<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN'
+ 'http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd'
+ [<!ENTITY mathml 'http://www.w3.org/1998/Math/MathML'>]>
+<html xmlns='http://www.w3.org/1999/xhtml'>
+<head><title>nc_t_ref5</title>
+<!-- MathML created with MathCast Equation Editor version 0.88 -->
+</head>
+<body>
+<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
+ <mrow>
+ <mi>f</mi>
+ <mfenced>
+ <mrow>
+ <mi>t</mi>
+ <mo>;</mo>
+ <mi>&#x03BD;</mi>
+ <mo>;</mo>
+ <mi>&#x03B4;</mi>
+ </mrow>
+ </mfenced>
+ <mspace width="1em"/>
+ <mo>=</mo>
+ <mspace width="1em"/>
+ <mfrac>
+ <mrow>
+ <mi>&#x03BD;</mi>
+ <mi>t</mi>
+ </mrow>
+ <mrow>
+ <msup>
+ <mi>&#x03BD;</mi>
+ <mn>2</mn>
+ </msup>
+ <mo>+</mo>
+ <mn>2</mn>
+ <mi>&#x03BD;</mi>
+ <msup>
+ <mi>t</mi>
+ <mn>2</mn>
+ </msup>
+ <mo>+</mo>
+ <msup>
+ <mi>t</mi>
+ <mn>4</mn>
+ </msup>
+ </mrow>
+ </mfrac>
+ <munderover>
+ <mo>&#x2211;</mo>
+ <mrow>
+ <mi>i</mi>
+ <mo>=</mo>
+ <mn>0</mn>
+ </mrow>
+ <mi>&#x221E;</mi>
+ </munderover>
+ <mfenced>
+ <mrow>
+ <msub>
+ <mi>P</mi>
+ <mi>i</mi>
+ </msub>
+ <msubsup>
+ <mi>I</mi>
+ <mrow>
+ <mi>x</mi>
+ </mrow>
+ <mo>&#x2032;</mo>
+ </msubsup>
+ <mfenced>
+ <mrow>
+ <mrow>
+ <mi>i</mi>
+ <mo>+</mo>
+ <mfrac>
+ <mn>1</mn>
+ <mn>2</mn>
+ </mfrac>
+ </mrow>
+ <mo>,</mo>
+ <mrow>
+ <mfrac>
+ <mi>&#x03BD;</mi>
+ <mn>2</mn>
+ </mfrac>
+ </mrow>
+ </mrow>
+ </mfenced>
+ <mo>+</mo>
+ <mfrac>
+ <mi>&#x03B4;</mi>
+ <mrow>
+ <msqrt>
+ <mn>2</mn>
+ </msqrt>
+ </mrow>
+ </mfrac>
+ <msub>
+ <mi>Q</mi>
+ <mi>i</mi>
+ </msub>
+ <msubsup>
+ <mi>I</mi>
+ <mrow>
+ <mi>x</mi>
+ </mrow>
+ <mo>&#x2032;</mo>
+ </msubsup>
+ <mfenced>
+ <mrow>
+ <mi>i</mi>
+ <mo>+</mo>
+ <mn>1,</mn>
+ <mrow>
+ <mfrac>
+ <mi>&#x03BD;</mi>
+ <mn>2</mn>
+ </mfrac>
+ </mrow>
+ </mrow>
+ </mfenced>
+ </mrow>
+ </mfenced>
+ </mrow>
+</math>
+</body>
+</html>

Added: sandbox/math_toolkit/libs/math/doc/sf_and_dist/equations/nc_t_ref5.png
==============================================================================
Binary file. No diff available.

Added: sandbox/math_toolkit/libs/math/doc/sf_and_dist/equations/nc_t_ref5.svg
==============================================================================
Binary file. No diff available.

Modified: sandbox/math_toolkit/libs/math/test/Jamfile.v2
==============================================================================
--- sandbox/math_toolkit/libs/math/test/Jamfile.v2 (original)
+++ sandbox/math_toolkit/libs/math/test/Jamfile.v2 2008-02-23 04:52:40 EST (Sat, 23 Feb 2008)
@@ -296,6 +296,30 @@
               <define>TEST_REAL_CONCEPT
         : test_nc_beta_real_concept ;
 run test_nc_f.cpp ;
+run test_nc_t.cpp
+ : # command line
+ : # input files
+ : # requirements
+ <define>TEST_FLOAT
+ : test_nc_t_float ;
+run test_nc_t.cpp
+ : # command line
+ : # input files
+ : # requirements
+ <define>TEST_DOUBLE
+ : test_nc_t_double ;
+run test_nc_t.cpp
+ : # command line
+ : # input files
+ : # requirements
+ <define>TEST_LDOUBLE
+ : test_nc_t_long_double ;
+run test_nc_t.cpp
+ : # command line
+ : # input files
+ : # requirements
+ <define>TEST_REAL_CONCEPT
+ : test_nc_t_real_concept ;
 run test_normal.cpp ;
 run test_pareto.cpp ;
 run test_poisson.cpp
@@ -448,3 +472,4 @@
 
 
 
+

Modified: sandbox/math_toolkit/libs/math/test/compile_test/instantiate.hpp
==============================================================================
--- sandbox/math_toolkit/libs/math/test/compile_test/instantiate.hpp (original)
+++ sandbox/math_toolkit/libs/math/test/compile_test/instantiate.hpp 2008-02-23 04:52:40 EST (Sat, 23 Feb 2008)
@@ -30,6 +30,25 @@
 
 }
 
+namespace boost{ namespace math{
+//
+// The non central beta doesn't define some properties,
+// define some stub methods here so that we can concept
+// check everything else:
+//
+template <class T, class Policy>
+inline T mean(const non_central_beta_distribution<T, Policy>&){ return 0; }
+template <class T, class Policy>
+inline T variance(const non_central_beta_distribution<T, Policy>&){ return 0; }
+template <class T, class Policy>
+inline T skewness(const non_central_beta_distribution<T, Policy>&){ return 0; }
+template <class T, class Policy>
+inline T kurtosis_excess(const non_central_beta_distribution<T, Policy>&){ return 0; }
+template <class T, class Policy>
+inline T kurtosis(const non_central_beta_distribution<T, Policy>&){ return 0; }
+
+}} // namespaces
+
 template <class RealType>
 void instantiate(RealType)
 {
@@ -56,6 +75,10 @@
    function_requires<DistributionConcept<triangular_distribution<RealType> > >();
    function_requires<DistributionConcept<uniform_distribution<RealType> > >();
    function_requires<DistributionConcept<weibull_distribution<RealType> > >();
+ function_requires<DistributionConcept<non_central_chi_squared_distribution<RealType> > >();
+ function_requires<DistributionConcept<non_central_beta_distribution<RealType> > >();
+ function_requires<DistributionConcept<non_central_f_distribution<RealType> > >();
+ function_requires<DistributionConcept<non_central_t_distribution<RealType> > >();
 
    function_requires<DistributionConcept<bernoulli_distribution<RealType, test_policy> > >();
    function_requires<DistributionConcept<beta_distribution<RealType, test_policy> > >();
@@ -77,6 +100,10 @@
    function_requires<DistributionConcept<triangular_distribution<RealType, test_policy> > >();
    function_requires<DistributionConcept<uniform_distribution<RealType, test_policy> > >();
    function_requires<DistributionConcept<weibull_distribution<RealType, test_policy> > >();
+ function_requires<DistributionConcept<non_central_chi_squared_distribution<RealType, test_policy> > >();
+ function_requires<DistributionConcept<non_central_beta_distribution<RealType, test_policy> > >();
+ function_requires<DistributionConcept<non_central_f_distribution<RealType, test_policy> > >();
+ function_requires<DistributionConcept<non_central_t_distribution<RealType, test_policy> > >();
 
    function_requires<DistributionConcept<dist_test::bernoulli > >();
    function_requires<DistributionConcept<dist_test::beta > >();
@@ -97,6 +124,10 @@
    function_requires<DistributionConcept<dist_test::triangular > >();
    function_requires<DistributionConcept<dist_test::uniform > >();
    function_requires<DistributionConcept<dist_test::weibull > >();
+ function_requires<DistributionConcept<dist_test::non_central_chi_squared > >();
+ function_requires<DistributionConcept<dist_test::non_central_beta > >();
+ function_requires<DistributionConcept<dist_test::non_central_f > >();
+ function_requires<DistributionConcept<dist_test::non_central_t > >();
 
    int i;
    RealType v1(0.5), v2(0.5), v3(0.5);

Modified: sandbox/math_toolkit/libs/math/test/nct.ipp
==============================================================================
--- sandbox/math_toolkit/libs/math/test/nct.ipp (original)
+++ sandbox/math_toolkit/libs/math/test/nct.ipp 2008-02-23 04:52:40 EST (Sat, 23 Feb 2008)
@@ -1,3 +1,10 @@
+// Copyright John Maddock 2008.
+
+// Use, modification and distribution are subject to 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)
+
 #define SC_(x) static_cast<T>(BOOST_JOIN(x, L))
    static const boost::array<boost::array<T, 5>, 209-7> nct = {{
       { SC_(5.637862086296081542968750000000000000000e-1), SC_(-5.074075460433959960937500000000000000000e-1), SC_(-3.162277862429618835449218750000000000000e-2), SC_(6.862274577179818450132372470056769938949e-1), SC_(3.137725422820181549867627529943230061051e-1) },
@@ -203,6 +210,11 @@
       { SC_(2.322846374511718750000000000000000000000e2), SC_(3.484269409179687500000000000000000000000e2), SC_(3.660482482910156250000000000000000000000e2), SC_(8.445224219835303698101085035756072755625e-1), SC_(1.554775780164696301898914964243927244375e-1) },
       { SC_(2.906821289062500000000000000000000000000e2), SC_(5.813642578125000000000000000000000000000e2), SC_(6.095877075195312500000000000000000000000e2), SC_(8.635682877769042305180745412047783757853e-1), SC_(1.364317122230957694819254587952216242147e-1) },
       /*
+ //
+ // These last few values are commented out, the complexity of the implementation
+ // depends upon the square of the non-centrality parameter, so these both take
+ // a long time to evaluate and are rather hard to evaluate accurately also.
+ //
       { SC_(9.757655029296875000000000000000000000000e2), SC_(-2.927296386718750000000000000000000000000e3), SC_(-3.009226074218750000000000000000000000000e3), SC_(1.164317566424995639445047413284130115370e-1), SC_(8.835682433575004360554952586715869884630e-1) },
       { SC_(1.879048828125000000000000000000000000000e3), SC_(7.516195312500000000000000000000000000000e3), SC_(7.678772949218750000000000000000000000000e3), SC_(9.017566036730798342611358387622429767684e-1), SC_(9.824339632692016573886416123775702323164e-2) },
       { SC_(2.308069091796875000000000000000000000000e3), SC_(-1.154034570312500000000000000000000000000e4), SC_(-1.179905078125000000000000000000000000000e4), SC_(6.872608129209766834994044970484572985093e-2), SC_(9.312739187079023316500595502951542701491e-1) },

Modified: sandbox/math_toolkit/libs/math/test/test_nc_t.cpp
==============================================================================
--- sandbox/math_toolkit/libs/math/test/test_nc_t.cpp (original)
+++ sandbox/math_toolkit/libs/math/test/test_nc_t.cpp 2008-02-23 04:52:40 EST (Sat, 23 Feb 2008)
@@ -85,9 +85,16 @@
       "[^|]*", // compiler
       "[^|]*", // stdlib
       "[^|]*", // platform
+ "real_concept", // test type(s)
+ "[^|]*", // test data group
+ "[^|]*", 300000, 100000); // test function
+ add_expected_result(
+ "[^|]*", // compiler
+ "[^|]*", // stdlib
+ "[^|]*", // platform
       largest_type, // test type(s)
       "[^|]*", // test data group
- "[^|]*", 150, 50); // test function
+ "[^|]*", 250, 50); // test function
 
    //
    // Finish off by printing out the compiler/stdlib/platform names,


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk