2
0
mirror of https://github.com/boostorg/math.git synced 2026-01-25 06:22:09 +00:00

Merge branch 'develop' of https://github.com/boostorg/math into develop

This commit is contained in:
jzmaddock
2016-08-10 18:52:48 +01:00
16 changed files with 107 additions and 61 deletions

View File

@@ -2,9 +2,9 @@
``#include <boost/math/distributions/non_central_chi_squared.hpp>``
namespace boost{ namespace math{
namespace boost{ namespace math{
template <class RealType = double,
template <class RealType = double,
class ``__Policy`` = ``__policy_class`` >
class non_central_chi_squared_distribution;
@@ -30,26 +30,26 @@
static RealType find_degrees_of_freedom(RealType lambda, RealType x, RealType p);
template <class A, class B, class C>
static RealType find_degrees_of_freedom(const complemented3_type<A,B,C>& c);
static RealType find_non_centrality(RealType v, RealType x, RealType p);
template <class A, class B, class C>
static RealType find_non_centrality(const complemented3_type<A,B,C>& c);
};
}} // namespaces
The noncentral chi-squared distribution is a generalization of the
__chi_squared_distrib. If X[sub i] are [nu] independent, normally
distributed random variables with means [mu][sub i] and variances
The noncentral chi-squared distribution is a generalization of the
__chi_squared_distrib. If X[sub i] are [nu] independent, normally
distributed random variables with means [mu][sub i] and variances
[sigma][sub i][super 2], then the random variable
[equation nc_chi_squ_ref1]
is distributed according to the noncentral chi-squared distribution.
is distributed according to the noncentral chi-squared distribution.
The noncentral chi-squared distribution has two parameters:
[nu] which specifies the number of degrees of freedom
(i.e. the number of X[sub i]), and [lambda] which is related to the
The noncentral chi-squared distribution has two parameters:
[nu] which specifies the number of degrees of freedom
(i.e. the number of X[sub i]), and [lambda] which is related to the
mean of the random variables X[sub i] by:
[equation nc_chi_squ_ref2]
@@ -60,7 +60,7 @@ This leads to a PDF of:
[equation nc_chi_squ_ref3]
where ['f(x;k)] is the central chi-squared distribution PDF, and
where ['f(x;k)] is the central chi-squared distribution PDF, and
['I[sub v](x)] is a modified Bessel function of the first kind.
The following graph illustrates how the distribution changes
@@ -71,18 +71,18 @@ for different values of [lambda]:
[h4 Member Functions]
non_central_chi_squared_distribution(RealType v, RealType lambda);
Constructs a Chi-Squared distribution with /v/ degrees of freedom
and non-centrality parameter /lambda/.
Requires v > 0 and lambda >= 0, 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 parameter /lambda/ from which this object was constructed.
@@ -93,14 +93,14 @@ This function returns the number of degrees of freedom /v/ such that:
template <class A, class B, class C>
static RealType find_degrees_of_freedom(const complemented3_type<A,B,C>& c);
When called with argument `boost::math::complement(lambda, x, q)`
When called with argument `boost::math::complement(lambda, x, q)`
this function returns the number of degrees of freedom /v/ such that:
`cdf(complement(non_central_chi_squared<RealType, Policy>(v, lambda), x)) == q`.
static RealType find_non_centrality(RealType v, RealType x, RealType p);
This function returns the non centrality parameter /lambda/ such that:
`cdf(non_central_chi_squared<RealType, Policy>(v, lambda), x) == p`
@@ -122,8 +122,8 @@ The domain of the random variable is \[0, +[infin]\].
[h4 Examples]
There is a
[link math_toolkit.stat_tut.weg.nccs_eg worked example]
There is a
[link math_toolkit.stat_tut.weg.nccs_eg worked example]
for the noncentral chi-squared distribution.
[h4 Accuracy]
@@ -140,9 +140,9 @@ than the one shown will have __zero_error.
[table_non_central_chi_squared_CDF_complement]
Error rates for the quantile
Error rates for the quantile
functions are broadly similar. Special mention should go to
the `mode` function: there is no closed form for this function,
the `mode` function: there is no closed form for this function,
so it is evaluated numerically by finding the maxima of the PDF:
in principal this can not produce an accuracy greater than the
square root of the machine epsilon.
@@ -151,10 +151,10 @@ square root of the machine epsilon.
There are two sets of test data used to verify this implementation:
firstly we can compare with published data, for example with
Table 6 of "Self-Validating Computations of Probabilities for
Table 6 of "Self-Validating Computations of Probabilities for
Selected Central and Noncentral Univariate Probability Functions",
Morgan C. Wang and William J. Kennedy,
Journal of the American Statistical Association,
Journal of the American Statistical Association,
Vol. 89, No. 427. (Sep., 1994), pp. 878-887.
Secondly, we have tables of test data, computed with this
implementation and using interval arithmetic - this data should
@@ -180,8 +180,8 @@ is then subtracted from 1 to give the desired result (the CDF or its
complement).
For small values of the non centrality parameter, the CDF is computed
using the method of Ding (see "Algorithm AS 275: Computing the Non-Central
#2 Distribution Function", Cherng G. Ding, Applied Statistics, Vol. 41,
using the method of Ding (see "Algorithm AS 275: Computing the Non-Central
#2 Distribution Function", Cherng G. Ding, Applied Statistics, Vol. 41,
No. 2. (1992), pp. 478-482). This uses the following series representation:
[equation nc_chi_squ_ref4]
@@ -195,10 +195,10 @@ the largest term is not the first term, so in extreme cases the first term may
be zero, leading to a zero result, even though the true value may be non-zero.
Therefore, when the non-centrality parameter is greater than 200, the method due
to Krishnamoorthy (see "Computing discrete mixtures of continuous distributions:
noncentral chisquare, noncentral t and the distribution of the
square of the sample multiple correlation coefficient",
Denise Benton and K. Krishnamoorthy, Computational Statistics &
to Krishnamoorthy (see "Computing discrete mixtures of continuous distributions:
noncentral chisquare, noncentral t and the distribution of the
square of the sample multiple correlation coefficient",
Denise Benton and K. Krishnamoorthy, Computational Statistics &
Data Analysis, 43, (2003), 249-267) is used.
This method uses the well known sum:
@@ -232,16 +232,19 @@ The PDF is computed directly using the relation:
[equation nc_chi_squ_ref3]
Where ['f(x; v)] is the PDF of the central __chi_squared_distrib and
['I[sub v](x)] is a modified Bessel function, see __cyl_bessel_i.
Where ['f(x; v)] is the PDF of the central __chi_squared_distrib and
['I[sub v](x)] is a modified Bessel function, see __cyl_bessel_i.
For small values of the
non-centrality parameter the relation in terms of __cyl_bessel_i
is used. However, this method fails for large values of the
non-centrality parameter, so in that case the infinite sum is
evaluated using the method of Benton and Krishnamoorthy, and
non-centrality parameter, so in that case the infinite sum is
evaluated using the method of Benton and Krishnamoorthy, and
the usual recurrence relations for successive terms.
The quantile functions are computed by numeric inversion of the CDF.
An improve starting quess is from
Thomas Luu,
[@http://discovery.ucl.ac.uk/1482128/, Fast and accurate parallel computation of quantile functions for random number generation, Doctorial Thesis, 2016].
There is no [@http://en.wikipedia.org/wiki/Closed_form closed form]
for the mode of the noncentral chi-squared

View File

@@ -116,7 +116,7 @@ This manual is also available in <a href="http://sourceforge.net/projects/boost/
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"><p><small>Last revised: August 03, 2016 at 18:01:01 GMT</small></p></td>
<td align="left"><p><small>Last revised: August 09, 2016 at 14:52:49 GMT</small></p></td>
<td align="right"><div class="copyright-footer"></div></td>
</tr></table>
<hr>

View File

@@ -24,7 +24,7 @@
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="id1816252"></a>Function Index</h2></div></div></div>
<a name="id1822442"></a>Function Index</h2></div></div></div>
<p><a class="link" href="s01.html#idx_id_0">2</a> <a class="link" href="s01.html#idx_id_1">4</a> <a class="link" href="s01.html#idx_id_2">A</a> <a class="link" href="s01.html#idx_id_3">B</a> <a class="link" href="s01.html#idx_id_4">C</a> <a class="link" href="s01.html#idx_id_5">D</a> <a class="link" href="s01.html#idx_id_6">E</a> <a class="link" href="s01.html#idx_id_7">F</a> <a class="link" href="s01.html#idx_id_8">G</a> <a class="link" href="s01.html#idx_id_9">H</a> <a class="link" href="s01.html#idx_id_10">I</a> <a class="link" href="s01.html#idx_id_11">J</a> <a class="link" href="s01.html#idx_id_12">K</a> <a class="link" href="s01.html#idx_id_13">L</a> <a class="link" href="s01.html#idx_id_14">M</a> <a class="link" href="s01.html#idx_id_15">N</a> <a class="link" href="s01.html#idx_id_16">O</a> <a class="link" href="s01.html#idx_id_17">P</a> <a class="link" href="s01.html#idx_id_18">Q</a> <a class="link" href="s01.html#idx_id_19">R</a> <a class="link" href="s01.html#idx_id_20">S</a> <a class="link" href="s01.html#idx_id_21">T</a> <a class="link" href="s01.html#idx_id_22">U</a> <a class="link" href="s01.html#idx_id_23">V</a> <a class="link" href="s01.html#idx_id_25">X</a> <a class="link" href="s01.html#idx_id_26">Y</a> <a class="link" href="s01.html#idx_id_27">Z</a></p>
<div class="variablelist"><dl class="variablelist">
<dt>

View File

@@ -24,7 +24,7 @@
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="id1839780"></a>Class Index</h2></div></div></div>
<a name="id1846212"></a>Class Index</h2></div></div></div>
<p><a class="link" href="s02.html#idx_id_30">A</a> <a class="link" href="s02.html#idx_id_31">B</a> <a class="link" href="s02.html#idx_id_32">C</a> <a class="link" href="s02.html#idx_id_33">D</a> <a class="link" href="s02.html#idx_id_34">E</a> <a class="link" href="s02.html#idx_id_35">F</a> <a class="link" href="s02.html#idx_id_36">G</a> <a class="link" href="s02.html#idx_id_37">H</a> <a class="link" href="s02.html#idx_id_38">I</a> <a class="link" href="s02.html#idx_id_41">L</a> <a class="link" href="s02.html#idx_id_42">M</a> <a class="link" href="s02.html#idx_id_43">N</a> <a class="link" href="s02.html#idx_id_44">O</a> <a class="link" href="s02.html#idx_id_45">P</a> <a class="link" href="s02.html#idx_id_46">Q</a> <a class="link" href="s02.html#idx_id_47">R</a> <a class="link" href="s02.html#idx_id_48">S</a> <a class="link" href="s02.html#idx_id_49">T</a> <a class="link" href="s02.html#idx_id_50">U</a> <a class="link" href="s02.html#idx_id_52">W</a></p>
<div class="variablelist"><dl class="variablelist">
<dt>

View File

@@ -24,7 +24,7 @@
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="id1840857"></a>Typedef Index</h2></div></div></div>
<a name="id1845036"></a>Typedef Index</h2></div></div></div>
<p><a class="link" href="s03.html#idx_id_58">A</a> <a class="link" href="s03.html#idx_id_59">B</a> <a class="link" href="s03.html#idx_id_60">C</a> <a class="link" href="s03.html#idx_id_61">D</a> <a class="link" href="s03.html#idx_id_62">E</a> <a class="link" href="s03.html#idx_id_63">F</a> <a class="link" href="s03.html#idx_id_64">G</a> <a class="link" href="s03.html#idx_id_65">H</a> <a class="link" href="s03.html#idx_id_66">I</a> <a class="link" href="s03.html#idx_id_69">L</a> <a class="link" href="s03.html#idx_id_71">N</a> <a class="link" href="s03.html#idx_id_72">O</a> <a class="link" href="s03.html#idx_id_73">P</a> <a class="link" href="s03.html#idx_id_75">R</a> <a class="link" href="s03.html#idx_id_76">S</a> <a class="link" href="s03.html#idx_id_77">T</a> <a class="link" href="s03.html#idx_id_78">U</a> <a class="link" href="s03.html#idx_id_79">V</a> <a class="link" href="s03.html#idx_id_80">W</a></p>
<div class="variablelist"><dl class="variablelist">
<dt>

View File

@@ -24,7 +24,7 @@
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="id1845633"></a>Macro Index</h2></div></div></div>
<a name="id1849730"></a>Macro Index</h2></div></div></div>
<p><a class="link" href="s04.html#idx_id_87">B</a> <a class="link" href="s04.html#idx_id_91">F</a></p>
<div class="variablelist"><dl class="variablelist">
<dt>

View File

@@ -23,7 +23,7 @@
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="id1846977"></a>Index</h2></div></div></div>
<a name="id1854128"></a>Index</h2></div></div></div>
<p><a class="link" href="s05.html#idx_id_112">2</a> <a class="link" href="s05.html#idx_id_113">4</a> <a class="link" href="s05.html#idx_id_114">A</a> <a class="link" href="s05.html#idx_id_115">B</a> <a class="link" href="s05.html#idx_id_116">C</a> <a class="link" href="s05.html#idx_id_117">D</a> <a class="link" href="s05.html#idx_id_118">E</a> <a class="link" href="s05.html#idx_id_119">F</a> <a class="link" href="s05.html#idx_id_120">G</a> <a class="link" href="s05.html#idx_id_121">H</a> <a class="link" href="s05.html#idx_id_122">I</a> <a class="link" href="s05.html#idx_id_123">J</a> <a class="link" href="s05.html#idx_id_124">K</a> <a class="link" href="s05.html#idx_id_125">L</a> <a class="link" href="s05.html#idx_id_126">M</a> <a class="link" href="s05.html#idx_id_127">N</a> <a class="link" href="s05.html#idx_id_128">O</a> <a class="link" href="s05.html#idx_id_129">P</a> <a class="link" href="s05.html#idx_id_130">Q</a> <a class="link" href="s05.html#idx_id_131">R</a> <a class="link" href="s05.html#idx_id_132">S</a> <a class="link" href="s05.html#idx_id_133">T</a> <a class="link" href="s05.html#idx_id_134">U</a> <a class="link" href="s05.html#idx_id_135">V</a> <a class="link" href="s05.html#idx_id_136">W</a> <a class="link" href="s05.html#idx_id_137">X</a> <a class="link" href="s05.html#idx_id_138">Y</a> <a class="link" href="s05.html#idx_id_139">Z</a></p>
<div class="variablelist"><dl class="variablelist">
<dt>

View File

@@ -27,7 +27,7 @@
<a name="math_toolkit.conventions"></a><a class="link" href="conventions.html" title="Document Conventions">Document Conventions</a>
</h2></div></div></div>
<p>
<a class="indexterm" name="id985119"></a>
<a class="indexterm" name="id994455"></a>
</p>
<p>
This documentation aims to use of the following naming and formatting conventions.

View File

@@ -153,6 +153,23 @@
<p>
Jeremy William Murphy added polynomial arithmetic tools.
</p>
<p>
Thomas Luu provided improvements to the quantile of the non-central chi squared
distribution quantile. and his thesis * <a href="http://discovery.ucl.ac.uk/1482128/" target="_top">Fast
and accurate parallel computation of quantile functions for random number generation,
2016</a>.
</p>
<p>
and his paper
</p>
<p>
Luu, Thomas; (2015), Efficient and Accurate Parallel Inversion of the Gamma
Distribution, SIAM Journal on Scientific Computing , 37 (1) C122 - C141, <a href="http://dx.doi.org/10.1137/14095875X" target="_top">http://dx.doi.org/10.1137/14095875X</a>.
</p>
<p>
These also promise to help improve algorithms for computation of quantile of
several disitributions, especially for parallel computation using GPUs.
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>

View File

@@ -527,7 +527,10 @@
and Krishnamoorthy, and the usual recurrence relations for successive terms.
</p>
<p>
The quantile functions are computed by numeric inversion of the CDF.
The quantile functions are computed by numeric inversion of the CDF. An
improve starting quess is from Thomas Luu, <a href="http://discovery.ucl.ac.uk/1482128/%2c" target="_top">Fast
and accurate parallel computation of quantile functions for random number
generation, Doctorial Thesis, 2016</a>.
</p>
<p>
There is no <a href="http://en.wikipedia.org/wiki/Closed_form" target="_top">closed

View File

@@ -419,15 +419,18 @@
over/underflow.
</li>
<li class="listitem">
<p class="simpara">
Add improvement to non-central chi squared distribution quantile due to
Thomas Luu.
</li>
</ul></div>
Thomas Luu, <a href="http://discovery.ucl.ac.uk/1482128/" target="_top">Fast and accurate
parallel computation of quantile functions for random number generation,
Doctorial Thesis 2016</a>. <a href="http://discovery.ucl.ac.uk/1463470/" target="_top">Efficient
and Accurate Parallel Inversion of the Gamma Distribution, Thomas Luu</a>
</p>
<h5>
<a name="math_toolkit.history1.h10"></a>
<span class="phrase"><a name="math_toolkit.history1.boost_1_54"></a></span><a class="link" href="history1.html#math_toolkit.history1.boost_1_54">Boost-1.54</a>
</h5>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<span class="phrase"><a name="math_toolkit.history1.boost_1_54"></a></span><a class="link" href="history1.html#math_toolkit.history1.boost_1_54">Boost-1.54</a>
</h5>
</li>
<li class="listitem">
Major reorganization to incorporate other Boost.Math like Integer Utilities
Integer Utilities (Greatest Common Divisor and Least Common Multiple),

View File

@@ -419,15 +419,18 @@
over/underflow.
</li>
<li class="listitem">
<p class="simpara">
Add improvement to non-central chi squared distribution quantile due to
Thomas Luu.
</li>
</ul></div>
Thomas Luu, <a href="http://discovery.ucl.ac.uk/1482128/" target="_top">Fast and accurate
parallel computation of quantile functions for random number generation,
Doctorial Thesis 2016</a>. <a href="http://discovery.ucl.ac.uk/1463470/" target="_top">Efficient
and Accurate Parallel Inversion of the Gamma Distribution, Thomas Luu</a>
</p>
<h5>
<a name="math_toolkit.history2.h10"></a>
<span class="phrase"><a name="math_toolkit.history2.boost_1_54"></a></span><a class="link" href="history2.html#math_toolkit.history2.boost_1_54">Boost-1.54</a>
</h5>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<span class="phrase"><a name="math_toolkit.history2.boost_1_54"></a></span><a class="link" href="history2.html#math_toolkit.history2.boost_1_54">Boost-1.54</a>
</h5>
</li>
<li class="listitem">
Major reorganization to incorporate other Boost.Math like Integer Utilities
Integer Utilities (Greatest Common Divisor and Least Common Multiple),

View File

@@ -27,7 +27,7 @@
<a name="math_toolkit.navigation"></a><a class="link" href="navigation.html" title="Navigation">Navigation</a>
</h2></div></div></div>
<p>
<a class="indexterm" name="id985015"></a>
<a class="indexterm" name="id994329"></a>
</p>
<p>
Boost.Math documentation is provided in both HTML and PDF formats.

View File

@@ -110,10 +110,23 @@ special functions code to near destruction!
Jeremy William Murphy added polynomial arithmetic tools.
Thomas Luu provided improvements to the quantile of the non-central chi squared distribution quantile.
and his thesis
* [@http://discovery.ucl.ac.uk/1482128/ Fast and accurate parallel computation of quantile functions for random number generation, 2016].
and his paper
Luu, Thomas; (2015), Efficient and Accurate Parallel Inversion of the Gamma Distribution,
SIAM Journal on Scientific Computing , 37 (1) C122 - C141,
[@http://dx.doi.org/10.1137/14095875X].
These also promise to help improve algorithms for computation of quantile of several disitributions,
especially for parallel computation using GPUs.
[endsect] [/section:credits Credits and Acknowledgements]
[/
Copyright 2006, 2007, 2008, 2009, 2010, 2012, 2013, 2015 John Maddock and Paul A. Bristow.
Copyright 2006, 2007, 2008, 2009, 2010, 2012, 2013, 2015, 2016 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).

View File

@@ -142,8 +142,9 @@ Random variate can now be infinite.
* Improve consistency of argument reduction in the elliptic integrals [@https://svn.boost.org/trac/boost/ticket/9104 #9104].
* Fix bug in inverse incomplete beta that results in cancellation errors when the beta function is really an arcsine or Student's T distribution.
* Fix issue in Bessel I and K function continued fractions that causes spurious over/underflow.
* Add improvement to non-central chi squared distribution quantile due to Thomas Luu.
* Add improvement to non-central chi squared distribution quantile due to Thomas Luu,
[@http://discovery.ucl.ac.uk/1482128/ Fast and accurate parallel computation of quantile functions for random number generation, Doctorial Thesis 2016].
[@http://discovery.ucl.ac.uk/1463470/ Efficient and Accurate Parallel Inversion of the Gamma Distribution, Thomas Luu]
[h4 Boost-1.54]
* Major reorganization to incorporate other Boost.Math like Integer Utilities Integer Utilities (Greatest Common Divisor and Least Common Multiple), quaternions and octonions.

View File

@@ -438,7 +438,7 @@ namespace boost
return comp ? 0 : policies::raise_overflow_error<RealType>(function, 0, Policy());
//
// This is Pearson's approximation to the quantile, see
// Pearson, E. S. (1959) "Note on an approximation to the distribution of
// Pearson, E. S. (1959) "Note on an approximation to the distribution of
// noncentral chi squared", Biometrika 46: 364.
// See also:
// "A comparison of approximations to percentiles of the noncentral chi2-distribution",
@@ -460,10 +460,13 @@ namespace boost
//
// Sometimes guess goes very small or negative, in that case we have
// to do something else for the initial guess, this approximation
// was provided in a private communication from Thomas Luu, PhD candidate,
// was provided in a private communication from Thomas Luu, PhD candidate,
// University College London. It's an asymptotic expansion for the
// quantile which usually gets us within an order of magnitude of the
// correct answer.
// Fast and accurate parallel computation of quantile functions for random number generation,
// Thomas LuuDoctorial Thesis 2016
// http://discovery.ucl.ac.uk/1482128/
//
if(guess < 0.005)
{