Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / math / doc / html / math_toolkit / dist_ref / dists / nc_chi_squared_dist.html
1 <html>
2 <head>
3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>Noncentral Chi-Squared Distribution</title>
5 <link rel="stylesheet" href="../../../math.css" type="text/css">
6 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7 <link rel="home" href="../../../index.html" title="Math Toolkit 2.11.0">
8 <link rel="up" href="../dists.html" title="Distributions">
9 <link rel="prev" href="nc_beta_dist.html" title="Noncentral Beta Distribution">
10 <link rel="next" href="nc_f_dist.html" title="Noncentral F Distribution">
11 </head>
12 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13 <table cellpadding="2" width="100%"><tr>
14 <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
15 <td align="center"><a href="../../../../../../../index.html">Home</a></td>
16 <td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
17 <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18 <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19 <td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
20 </tr></table>
21 <hr>
22 <div class="spirit-nav">
23 <a accesskey="p" href="nc_beta_dist.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../dists.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="nc_f_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
24 </div>
25 <div class="section">
26 <div class="titlepage"><div><div><h4 class="title">
27 <a name="math_toolkit.dist_ref.dists.nc_chi_squared_dist"></a><a class="link" href="nc_chi_squared_dist.html" title="Noncentral Chi-Squared Distribution">Noncentral
28         Chi-Squared Distribution</a>
29 </h4></div></div></div>
30 <pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">distributions</span><span class="special">/</span><span class="identifier">non_central_chi_squared</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></pre>
31 <pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">math</span><span class="special">{</span>
32
33 <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">RealType</span> <span class="special">=</span> <span class="keyword">double</span><span class="special">,</span>
34           <span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter&#160;20.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a>   <span class="special">=</span> <a class="link" href="../../pol_ref/pol_ref_ref.html" title="Policy Class Reference">policies::policy&lt;&gt;</a> <span class="special">&gt;</span>
35 <span class="keyword">class</span> <span class="identifier">non_central_chi_squared_distribution</span><span class="special">;</span>
36
37 <span class="keyword">typedef</span> <span class="identifier">non_central_chi_squared_distribution</span><span class="special">&lt;&gt;</span> <span class="identifier">non_central_chi_squared</span><span class="special">;</span>
38
39 <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">RealType</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter&#160;20.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
40 <span class="keyword">class</span> <span class="identifier">non_central_chi_squared_distribution</span>
41 <span class="special">{</span>
42 <span class="keyword">public</span><span class="special">:</span>
43    <span class="keyword">typedef</span> <span class="identifier">RealType</span>  <span class="identifier">value_type</span><span class="special">;</span>
44    <span class="keyword">typedef</span> <span class="identifier">Policy</span>    <span class="identifier">policy_type</span><span class="special">;</span>
45
46    <span class="comment">// Constructor:</span>
47    <span class="identifier">non_central_chi_squared_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">v</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">lambda</span><span class="special">);</span>
48
49    <span class="comment">// Accessor to degrees of freedom parameter v:</span>
50    <span class="identifier">RealType</span> <span class="identifier">degrees_of_freedom</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
51
52    <span class="comment">// Accessor to non centrality parameter lambda:</span>
53    <span class="identifier">RealType</span> <span class="identifier">non_centrality</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
54
55    <span class="comment">// Parameter finders:</span>
56    <span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_degrees_of_freedom</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">lambda</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">p</span><span class="special">);</span>
57    <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">A</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">B</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">C</span><span class="special">&gt;</span>
58    <span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_degrees_of_freedom</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">complemented3_type</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">,</span><span class="identifier">C</span><span class="special">&gt;&amp;</span> <span class="identifier">c</span><span class="special">);</span>
59
60    <span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_non_centrality</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">v</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">p</span><span class="special">);</span>
61    <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">A</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">B</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">C</span><span class="special">&gt;</span>
62    <span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_non_centrality</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">complemented3_type</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">,</span><span class="identifier">C</span><span class="special">&gt;&amp;</span> <span class="identifier">c</span><span class="special">);</span>
63 <span class="special">};</span>
64
65 <span class="special">}}</span> <span class="comment">// namespaces</span>
66 </pre>
67 <p>
68           The noncentral chi-squared distribution is a generalization of the <a class="link" href="chi_squared_dist.html" title="Chi Squared Distribution">Chi Squared Distribution</a>.
69           If <span class="emphasis"><em>X<sub>i</sub></em></span> are /&#957;/ independent, normally distributed random
70           variables with means /&#956;<sub>i</sub>/ and variances <span class="emphasis"><em>&#963;<sub>i</sub><sup>2</sup></em></span>, then the
71           random variable
72         </p>
73 <div class="blockquote"><blockquote class="blockquote"><p>
74             <span class="inlinemediaobject"><img src="../../../../equations/nc_chi_squ_ref1.svg"></span>
75
76           </p></blockquote></div>
77 <p>
78           is distributed according to the noncentral chi-squared distribution.
79         </p>
80 <p>
81           The noncentral chi-squared distribution has two parameters: /&#957;/ which specifies
82           the number of degrees of freedom (i.e. the number of <span class="emphasis"><em>X<sub>i</sub>)</em></span>,
83           and &#955; which is related to the mean of the random variables <span class="emphasis"><em>X<sub>i</sub></em></span>
84           by:
85         </p>
86 <div class="blockquote"><blockquote class="blockquote"><p>
87             <span class="inlinemediaobject"><img src="../../../../equations/nc_chi_squ_ref2.svg"></span>
88
89           </p></blockquote></div>
90 <p>
91           (Note that some references define &#955; as one half of the above sum).
92         </p>
93 <p>
94           This leads to a PDF of:
95         </p>
96 <div class="blockquote"><blockquote class="blockquote"><p>
97             <span class="inlinemediaobject"><img src="../../../../equations/nc_chi_squ_ref3.svg"></span>
98
99           </p></blockquote></div>
100 <p>
101           where <span class="emphasis"><em>f(x;k)</em></span> is the central chi-squared distribution
102           PDF, and <span class="emphasis"><em>I<sub>v</sub>(x)</em></span> is a modified Bessel function of the
103           first kind.
104         </p>
105 <p>
106           The following graph illustrates how the distribution changes for different
107           values of &#955;:
108         </p>
109 <div class="blockquote"><blockquote class="blockquote"><p>
110             <span class="inlinemediaobject"><img src="../../../../graphs/nccs_pdf.svg" align="middle"></span>
111
112           </p></blockquote></div>
113 <h5>
114 <a name="math_toolkit.dist_ref.dists.nc_chi_squared_dist.h0"></a>
115           <span class="phrase"><a name="math_toolkit.dist_ref.dists.nc_chi_squared_dist.member_functions"></a></span><a class="link" href="nc_chi_squared_dist.html#math_toolkit.dist_ref.dists.nc_chi_squared_dist.member_functions">Member
116           Functions</a>
117         </h5>
118 <pre class="programlisting"><span class="identifier">non_central_chi_squared_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">v</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">lambda</span><span class="special">);</span>
119 </pre>
120 <p>
121           Constructs a Chi-Squared distribution with <span class="emphasis"><em>v</em></span> degrees
122           of freedom and non-centrality parameter <span class="emphasis"><em>lambda</em></span>.
123         </p>
124 <p>
125           Requires v &gt; 0 and lambda &gt;= 0, otherwise calls <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>.
126         </p>
127 <pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">degrees_of_freedom</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
128 </pre>
129 <p>
130           Returns the parameter <span class="emphasis"><em>v</em></span> from which this object was
131           constructed.
132         </p>
133 <pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">non_centrality</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
134 </pre>
135 <p>
136           Returns the parameter <span class="emphasis"><em>lambda</em></span> from which this object
137           was constructed.
138         </p>
139 <pre class="programlisting"><span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_degrees_of_freedom</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">lambda</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">p</span><span class="special">);</span>
140 </pre>
141 <p>
142           This function returns the number of degrees of freedom <span class="emphasis"><em>v</em></span>
143           such that: <code class="computeroutput"><span class="identifier">cdf</span><span class="special">(</span><span class="identifier">non_central_chi_squared</span><span class="special">&lt;</span><span class="identifier">RealType</span><span class="special">,</span> <span class="identifier">Policy</span><span class="special">&gt;(</span><span class="identifier">v</span><span class="special">,</span> <span class="identifier">lambda</span><span class="special">),</span> <span class="identifier">x</span><span class="special">)</span> <span class="special">==</span> <span class="identifier">p</span></code>
144         </p>
145 <pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">A</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">B</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">C</span><span class="special">&gt;</span>
146 <span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_degrees_of_freedom</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">complemented3_type</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">,</span><span class="identifier">C</span><span class="special">&gt;&amp;</span> <span class="identifier">c</span><span class="special">);</span>
147 </pre>
148 <p>
149           When called with argument <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">complement</span><span class="special">(</span><span class="identifier">lambda</span><span class="special">,</span> <span class="identifier">x</span><span class="special">,</span>
150           <span class="identifier">q</span><span class="special">)</span></code>
151           this function returns the number of degrees of freedom <span class="emphasis"><em>v</em></span>
152           such that:
153         </p>
154 <p>
155           <code class="computeroutput"><span class="identifier">cdf</span><span class="special">(</span><span class="identifier">complement</span><span class="special">(</span><span class="identifier">non_central_chi_squared</span><span class="special">&lt;</span><span class="identifier">RealType</span><span class="special">,</span> <span class="identifier">Policy</span><span class="special">&gt;(</span><span class="identifier">v</span><span class="special">,</span> <span class="identifier">lambda</span><span class="special">),</span> <span class="identifier">x</span><span class="special">))</span> <span class="special">==</span> <span class="identifier">q</span></code>.
156         </p>
157 <pre class="programlisting"><span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_non_centrality</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">v</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">p</span><span class="special">);</span>
158 </pre>
159 <p>
160           This function returns the non centrality parameter <span class="emphasis"><em>lambda</em></span>
161           such that:
162         </p>
163 <p>
164           <code class="computeroutput"><span class="identifier">cdf</span><span class="special">(</span><span class="identifier">non_central_chi_squared</span><span class="special">&lt;</span><span class="identifier">RealType</span><span class="special">,</span> <span class="identifier">Policy</span><span class="special">&gt;(</span><span class="identifier">v</span><span class="special">,</span> <span class="identifier">lambda</span><span class="special">),</span> <span class="identifier">x</span><span class="special">)</span> <span class="special">==</span> <span class="identifier">p</span></code>
165         </p>
166 <pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">A</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">B</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">C</span><span class="special">&gt;</span>
167 <span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_non_centrality</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">complemented3_type</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">,</span><span class="identifier">C</span><span class="special">&gt;&amp;</span> <span class="identifier">c</span><span class="special">);</span>
168 </pre>
169 <p>
170           When called with argument <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">complement</span><span class="special">(</span><span class="identifier">v</span><span class="special">,</span>
171           <span class="identifier">x</span><span class="special">,</span>
172           <span class="identifier">q</span><span class="special">)</span></code>
173           this function returns the non centrality parameter <span class="emphasis"><em>lambda</em></span>
174           such that:
175         </p>
176 <p>
177           <code class="computeroutput"><span class="identifier">cdf</span><span class="special">(</span><span class="identifier">complement</span><span class="special">(</span><span class="identifier">non_central_chi_squared</span><span class="special">&lt;</span><span class="identifier">RealType</span><span class="special">,</span> <span class="identifier">Policy</span><span class="special">&gt;(</span><span class="identifier">v</span><span class="special">,</span> <span class="identifier">lambda</span><span class="special">),</span> <span class="identifier">x</span><span class="special">))</span> <span class="special">==</span> <span class="identifier">q</span></code>.
178         </p>
179 <h5>
180 <a name="math_toolkit.dist_ref.dists.nc_chi_squared_dist.h1"></a>
181           <span class="phrase"><a name="math_toolkit.dist_ref.dists.nc_chi_squared_dist.non_member_accessors"></a></span><a class="link" href="nc_chi_squared_dist.html#math_toolkit.dist_ref.dists.nc_chi_squared_dist.non_member_accessors">Non-member
182           Accessors</a>
183         </h5>
184 <p>
185           All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
186           functions</a> that are generic to all distributions are supported:
187           <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
188           <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
189           <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.quantile">Quantile</a>, <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.hazard">Hazard Function</a>, <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.chf">Cumulative Hazard Function</a>,
190           <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.mean">mean</a>, <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.median">median</a>,
191           <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.mode">mode</a>, <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.variance">variance</a>,
192           <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
193           <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.skewness">skewness</a>, <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.kurtosis">kurtosis</a>, <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.kurtosis_excess">kurtosis_excess</a>,
194           <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.range">range</a> and <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.support">support</a>.
195         </p>
196 <p>
197           The domain of the random variable is [0, +&#8734;].
198         </p>
199 <h5>
200 <a name="math_toolkit.dist_ref.dists.nc_chi_squared_dist.h2"></a>
201           <span class="phrase"><a name="math_toolkit.dist_ref.dists.nc_chi_squared_dist.examples"></a></span><a class="link" href="nc_chi_squared_dist.html#math_toolkit.dist_ref.dists.nc_chi_squared_dist.examples">Examples</a>
202         </h5>
203 <p>
204           There is a <a class="link" href="../../stat_tut/weg/nccs_eg.html" title="Non Central Chi Squared Example">worked example</a>
205           for the noncentral chi-squared distribution.
206         </p>
207 <h5>
208 <a name="math_toolkit.dist_ref.dists.nc_chi_squared_dist.h3"></a>
209           <span class="phrase"><a name="math_toolkit.dist_ref.dists.nc_chi_squared_dist.accuracy"></a></span><a class="link" href="nc_chi_squared_dist.html#math_toolkit.dist_ref.dists.nc_chi_squared_dist.accuracy">Accuracy</a>
210         </h5>
211 <p>
212           The following table shows the peak errors (in units of <a href="http://en.wikipedia.org/wiki/Machine_epsilon" target="_top">epsilon</a>)
213           found on various platforms with various floating point types. The failures
214           in the comparison to the <a href="http://www.r-project.org/" target="_top">R Math
215           library</a>, seem to be mostly in the corner cases when the probablity
216           would be very small. Unless otherwise specified any floating-point type
217           that is narrower than the one shown will have <a class="link" href="../../relative_error.html#math_toolkit.relative_error.zero_error">effectively
218           zero error</a>.
219         </p>
220 <div class="table">
221 <a name="math_toolkit.dist_ref.dists.nc_chi_squared_dist.table_non_central_chi_squared_CDF"></a><p class="title"><b>Table&#160;5.6.&#160;Error rates for non central chi squared CDF</b></p>
222 <div class="table-contents"><table class="table" summary="Error rates for non central chi squared CDF">
223 <colgroup>
224 <col>
225 <col>
226 <col>
227 <col>
228 <col>
229 </colgroup>
230 <thead><tr>
231 <th>
232                 </th>
233 <th>
234                   <p>
235                     GNU C++ version 7.1.0<br> linux<br> double
236                   </p>
237                 </th>
238 <th>
239                   <p>
240                     GNU C++ version 7.1.0<br> linux<br> long double
241                   </p>
242                 </th>
243 <th>
244                   <p>
245                     Sun compiler version 0x5150<br> Sun Solaris<br> long double
246                   </p>
247                 </th>
248 <th>
249                   <p>
250                     Microsoft Visual C++ version 14.1<br> Win32<br> double
251                   </p>
252                 </th>
253 </tr></thead>
254 <tbody>
255 <tr>
256 <td>
257                   <p>
258                     Non Central Chi Squared, medium parameters
259                   </p>
260                 </td>
261 <td>
262                   <p>
263                     <span class="blue">Max = 0.99&#949; (Mean = 0.0544&#949;)</span><br>
264                     <br> (<span class="emphasis"><em>Rmath 3.2.3:</em></span> Max = 727&#949; (Mean = 121&#949;))
265                   </p>
266                 </td>
267 <td>
268                   <p>
269                     <span class="blue">Max = 46.5&#949; (Mean = 10.3&#949;)</span>
270                   </p>
271                 </td>
272 <td>
273                   <p>
274                     <span class="blue">Max = 115&#949; (Mean = 13.9&#949;)</span>
275                   </p>
276                 </td>
277 <td>
278                   <p>
279                     <span class="blue">Max = 48.9&#949; (Mean = 10&#949;)</span>
280                   </p>
281                 </td>
282 </tr>
283 <tr>
284 <td>
285                   <p>
286                     Non Central Chi Squared, large parameters
287                   </p>
288                 </td>
289 <td>
290                   <p>
291                     <span class="blue">Max = 1.07&#949; (Mean = 0.102&#949;)</span><br>
292                     <br> (<span class="emphasis"><em>Rmath 3.2.3:</em></span> <span class="red">Max
293                     = 3.27e+08&#949; (Mean = 2.23e+07&#949;))</span>
294                   </p>
295                 </td>
296 <td>
297                   <p>
298                     <span class="blue">Max = 3.07e+03&#949; (Mean = 336&#949;)</span>
299                   </p>
300                 </td>
301 <td>
302                   <p>
303                     <span class="blue">Max = 6.17e+03&#949; (Mean = 677&#949;)</span>
304                   </p>
305                 </td>
306 <td>
307                   <p>
308                     <span class="blue">Max = 9.79e+03&#949; (Mean = 723&#949;)</span>
309                   </p>
310                 </td>
311 </tr>
312 </tbody>
313 </table></div>
314 </div>
315 <br class="table-break"><div class="table">
316 <a name="math_toolkit.dist_ref.dists.nc_chi_squared_dist.table_non_central_chi_squared_CDF_complement"></a><p class="title"><b>Table&#160;5.7.&#160;Error rates for non central chi squared CDF complement</b></p>
317 <div class="table-contents"><table class="table" summary="Error rates for non central chi squared CDF complement">
318 <colgroup>
319 <col>
320 <col>
321 <col>
322 <col>
323 <col>
324 </colgroup>
325 <thead><tr>
326 <th>
327                 </th>
328 <th>
329                   <p>
330                     GNU C++ version 7.1.0<br> linux<br> double
331                   </p>
332                 </th>
333 <th>
334                   <p>
335                     GNU C++ version 7.1.0<br> linux<br> long double
336                   </p>
337                 </th>
338 <th>
339                   <p>
340                     Sun compiler version 0x5150<br> Sun Solaris<br> long double
341                   </p>
342                 </th>
343 <th>
344                   <p>
345                     Microsoft Visual C++ version 14.1<br> Win32<br> double
346                   </p>
347                 </th>
348 </tr></thead>
349 <tbody>
350 <tr>
351 <td>
352                   <p>
353                     Non Central Chi Squared, medium parameters
354                   </p>
355                 </td>
356 <td>
357                   <p>
358                     <span class="blue">Max = 0.96&#949; (Mean = 0.0635&#949;)</span><br>
359                     <br> (<span class="emphasis"><em>Rmath 3.2.3:</em></span> <span class="red">Max
360                     = +INF&#949; (Mean = +INF&#949;) <a class="link" href="../../logs_and_tables/logs.html#errors_GNU_C_version_7_1_0_linux_double_non_central_chi_squared_CDF_complement_Rmath_3_2_3_Non_Central_Chi_Squared_medium_parameters">And
361                     other failures.</a>)</span>
362                   </p>
363                 </td>
364 <td>
365                   <p>
366                     <span class="blue">Max = 107&#949; (Mean = 17.2&#949;)</span>
367                   </p>
368                 </td>
369 <td>
370                   <p>
371                     <span class="blue">Max = 171&#949; (Mean = 22.8&#949;)</span>
372                   </p>
373                 </td>
374 <td>
375                   <p>
376                     <span class="blue">Max = 98.6&#949; (Mean = 15.8&#949;)</span>
377                   </p>
378                 </td>
379 </tr>
380 <tr>
381 <td>
382                   <p>
383                     Non Central Chi Squared, large parameters
384                   </p>
385                 </td>
386 <td>
387                   <p>
388                     <span class="blue">Max = 2.11&#949; (Mean = 0.278&#949;)</span><br>
389                     <br> (<span class="emphasis"><em>Rmath 3.2.3:</em></span> <span class="red">Max
390                     = +INF&#949; (Mean = +INF&#949;) <a class="link" href="../../logs_and_tables/logs.html#errors_GNU_C_version_7_1_0_linux_double_non_central_chi_squared_CDF_complement_Rmath_3_2_3_Non_Central_Chi_Squared_large_parameters">And
391                     other failures.</a>)</span>
392                   </p>
393                 </td>
394 <td>
395                   <p>
396                     <span class="blue">Max = 5.02e+03&#949; (Mean = 630&#949;)</span>
397                   </p>
398                 </td>
399 <td>
400                   <p>
401                     <span class="blue">Max = 5.1e+03&#949; (Mean = 577&#949;)</span>
402                   </p>
403                 </td>
404 <td>
405                   <p>
406                     <span class="blue">Max = 5.43e+03&#949; (Mean = 705&#949;)</span>
407                   </p>
408                 </td>
409 </tr>
410 </tbody>
411 </table></div>
412 </div>
413 <br class="table-break"><p>
414           Error rates for the quantile functions are broadly similar. Special mention
415           should go to the <code class="computeroutput"><span class="identifier">mode</span></code> function:
416           there is no closed form for this function, so it is evaluated numerically
417           by finding the maxima of the PDF: in principal this can not produce an
418           accuracy greater than the square root of the machine epsilon.
419         </p>
420 <h5>
421 <a name="math_toolkit.dist_ref.dists.nc_chi_squared_dist.h4"></a>
422           <span class="phrase"><a name="math_toolkit.dist_ref.dists.nc_chi_squared_dist.tests"></a></span><a class="link" href="nc_chi_squared_dist.html#math_toolkit.dist_ref.dists.nc_chi_squared_dist.tests">Tests</a>
423         </h5>
424 <p>
425           There are two sets of test data used to verify this implementation: firstly
426           we can compare with published data, for example with Table 6 of "Self-Validating
427           Computations of Probabilities for Selected Central and Noncentral Univariate
428           Probability Functions", Morgan C. Wang and William J. Kennedy, Journal
429           of the American Statistical Association, Vol. 89, No. 427. (Sep., 1994),
430           pp. 878-887. Secondly, we have tables of test data, computed with this
431           implementation and using interval arithmetic - this data should be accurate
432           to at least 50 decimal digits - and is the used for our accuracy tests.
433         </p>
434 <h5>
435 <a name="math_toolkit.dist_ref.dists.nc_chi_squared_dist.h5"></a>
436           <span class="phrase"><a name="math_toolkit.dist_ref.dists.nc_chi_squared_dist.implementation"></a></span><a class="link" href="nc_chi_squared_dist.html#math_toolkit.dist_ref.dists.nc_chi_squared_dist.implementation">Implementation</a>
437         </h5>
438 <p>
439           The CDF and its complement are evaluated as follows:
440         </p>
441 <p>
442           First we determine which of the two values (the CDF or its complement)
443           is likely to be the smaller: for this we can use the relation due to Temme
444           (see "Asymptotic and Numerical Aspects of the Noncentral Chi-Square
445           Distribution", N. M. Temme, Computers Math. Applic. Vol 25, No. 5,
446           55-63, 1993) that:
447         </p>
448 <p>
449           F(&#957;,&#955;;&#957;+&#955;) &#8776; 0.5
450         </p>
451 <p>
452           and so compute the CDF when the random variable is less than &#957;+&#955;, and its
453           complement when the random variable is greater than &#957;+&#955;. If necessary the
454           computed result is then subtracted from 1 to give the desired result (the
455           CDF or its complement).
456         </p>
457 <p>
458           For small values of the non centrality parameter, the CDF is computed using
459           the method of Ding (see "Algorithm AS 275: Computing the Non-Central
460           #2 Distribution Function", Cherng G. Ding, Applied Statistics, Vol.
461           41, No. 2. (1992), pp. 478-482). This uses the following series representation:
462         </p>
463 <div class="blockquote"><blockquote class="blockquote"><p>
464             <span class="inlinemediaobject"><img src="../../../../equations/nc_chi_squ_ref4.svg"></span>
465
466           </p></blockquote></div>
467 <p>
468           which requires just one call to <a class="link" href="../../sf_gamma/gamma_derivatives.html" title="Derivative of the Incomplete Gamma Function">gamma_p_derivative</a>
469           with the subsequent terms being computed by recursion as shown above.
470         </p>
471 <p>
472           For larger values of the non-centrality parameter, Ding's method can take
473           an unreasonable number of terms before convergence is achieved. Furthermore,
474           the largest term is not the first term, so in extreme cases the first term
475           may be zero, leading to a zero result, even though the true value may be
476           non-zero.
477         </p>
478 <p>
479           Therefore, when the non-centrality parameter is greater than 200, the method
480           due to Krishnamoorthy (see "Computing discrete mixtures of continuous
481           distributions: noncentral chisquare, noncentral t and the distribution
482           of the square of the sample multiple correlation coefficient", Denise
483           Benton and K. Krishnamoorthy, Computational Statistics &amp; Data Analysis,
484           43, (2003), 249-267) is used.
485         </p>
486 <p>
487           This method uses the well known sum:
488         </p>
489 <div class="blockquote"><blockquote class="blockquote"><p>
490             <span class="inlinemediaobject"><img src="../../../../equations/nc_chi_squ_ref5.svg"></span>
491
492           </p></blockquote></div>
493 <p>
494           Where <span class="emphasis"><em>P<sub>a</sub>(x)</em></span> is the incomplete gamma function.
495         </p>
496 <p>
497           The method starts at the &#955;th term, which is where the Poisson weighting
498           function achieves its maximum value, although this is not necessarily the
499           largest overall term. Subsequent terms are calculated via the normal recurrence
500           relations for the incomplete gamma function, and iteration proceeds both
501           forwards and backwards until sufficient precision has been achieved. It
502           should be noted that recurrence in the forwards direction of P<sub>a</sub>(x) is numerically
503           unstable. However, since we always start <span class="emphasis"><em>after</em></span> the
504           largest term in the series, numeric instability is introduced more slowly
505           than the series converges.
506         </p>
507 <p>
508           Computation of the complement of the CDF uses an extension of Krishnamoorthy's
509           method, given that:
510         </p>
511 <div class="blockquote"><blockquote class="blockquote"><p>
512             <span class="inlinemediaobject"><img src="../../../../equations/nc_chi_squ_ref6.svg"></span>
513
514           </p></blockquote></div>
515 <p>
516           we can again start at the &#955;'th term and proceed in both directions from
517           there until the required precision is achieved. This time it is backwards
518           recursion on the incomplete gamma function Q<sub>a</sub>(x) which is unstable. However,
519           as long as we start well <span class="emphasis"><em>before</em></span> the largest term,
520           this is not an issue in practice.
521         </p>
522 <p>
523           The PDF is computed directly using the relation:
524         </p>
525 <div class="blockquote"><blockquote class="blockquote"><p>
526             <span class="inlinemediaobject"><img src="../../../../equations/nc_chi_squ_ref3.svg"></span>
527
528           </p></blockquote></div>
529 <p>
530           Where <span class="emphasis"><em>f(x; v)</em></span> is the PDF of the central <a class="link" href="chi_squared_dist.html" title="Chi Squared Distribution">Chi
531           Squared Distribution</a> and <span class="emphasis"><em>I<sub>v</sub>(x)</em></span> is a modified
532           Bessel function, see <a class="link" href="../../bessel/mbessel.html" title="Modified Bessel Functions of the First and Second Kinds">cyl_bessel_i</a>.
533           For small values of the non-centrality parameter the relation in terms
534           of <a class="link" href="../../bessel/mbessel.html" title="Modified Bessel Functions of the First and Second Kinds">cyl_bessel_i</a> is used.
535           However, this method fails for large values of the non-centrality parameter,
536           so in that case the infinite sum is evaluated using the method of Benton
537           and Krishnamoorthy, and the usual recurrence relations for successive terms.
538         </p>
539 <p>
540           The quantile functions are computed by numeric inversion of the CDF. An
541           improve starting quess is from Thomas Luu, <a href="http://discovery.ucl.ac.uk/1482128/%2c" target="_top">Fast
542           and accurate parallel computation of quantile functions for random number
543           generation, Doctorial Thesis, 2016</a>.
544         </p>
545 <p>
546           There is no <a href="http://en.wikipedia.org/wiki/Closed_form" target="_top">closed
547           form</a> for the mode of the noncentral chi-squared distribution: it
548           is computed numerically by finding the maximum of the PDF. Likewise, the
549           median is computed numerically via the quantile.
550         </p>
551 <p>
552           The remaining non-member functions use the following formulas:
553         </p>
554 <div class="blockquote"><blockquote class="blockquote"><p>
555             <span class="inlinemediaobject"><img src="../../../../equations/nc_chi_squ_ref7.svg"></span>
556
557           </p></blockquote></div>
558 <p>
559           Some analytic properties of noncentral distributions (particularly unimodality,
560           and monotonicity of their modes) are surveyed and summarized by:
561         </p>
562 <p>
563           Andrea van Aubel &amp; Wolfgang Gawronski, Applied Mathematics and Computation,
564           141 (2003) 3-12.
565         </p>
566 </div>
567 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
568 <td align="left"></td>
569 <td align="right"><div class="copyright-footer">Copyright &#169; 2006-2019 Nikhar
570       Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
571       Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Matthew Pulver, Johan
572       R&#229;de, Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg,
573       Daryle Walker and Xiaogang Zhang<p>
574         Distributed under the Boost Software License, Version 1.0. (See accompanying
575         file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
576       </p>
577 </div></td>
578 </tr></table>
579 <hr>
580 <div class="spirit-nav">
581 <a accesskey="p" href="nc_beta_dist.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../dists.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="nc_f_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
582 </div>
583 </body>
584 </html>