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