Boost C++ Libraries: Ticket #11557: cdf error with non-central chi-squared with ncp = 0 https://svn.boost.org/trac10/ticket/11557 <p> The complement of the cdf of the non-central chi-squared distribution with non-centrality parameter = 0 should return the same value as the standard (i.e. central) chi-squared distribution. For ncp very small, this happens, but when ncp = 0 it returns the negative of the (non-complement) cdf. Example code: </p> <pre class="wiki">#include &lt;iostream&gt; #include &lt;boost/math/distributions.hpp&gt; using std::cout; using std::cin; using std::endl; using boost::math::chi_squared; int main(int argc, char *argv[]) { double df = 4, quantile = 12; cout &lt;&lt; "df = " &lt;&lt; df &lt;&lt; endl; cout &lt;&lt; "quantile = " &lt;&lt; quantile &lt;&lt; endl; chi_squared chi(df); cout &lt;&lt; "chi.df = " &lt;&lt; chi.degrees_of_freedom() &lt;&lt; endl; cout &lt;&lt; "P(X &lt;= " &lt;&lt; quantile &lt;&lt; ") = " &lt;&lt; cdf(chi, quantile) &lt;&lt; endl; cout &lt;&lt; "P(X &gt; " &lt;&lt; quantile &lt;&lt; ") = " &lt;&lt; cdf(complement(chi, quantile)) &lt;&lt; endl; double ncp1 = 1e-300; double ncp2 = 0; boost::math::non_central_chi_squared nchi1(df, ncp1); boost::math::non_central_chi_squared nchi2(df, ncp2); cout &lt;&lt; "nchi1.df = " &lt;&lt; nchi1.degrees_of_freedom() &lt;&lt; "; nchi1.ncp = " &lt;&lt; nchi1.non_centrality() &lt;&lt; endl; cout &lt;&lt; "P(X &lt;= " &lt;&lt; quantile &lt;&lt; ") = " &lt;&lt; cdf(nchi1, quantile) &lt;&lt; endl; cout &lt;&lt; "P(X &gt; " &lt;&lt; quantile &lt;&lt; ") = " &lt;&lt; cdf(complement(nchi1, quantile)) &lt;&lt; endl; cout &lt;&lt; "nchi2.df = " &lt;&lt; nchi2.degrees_of_freedom() &lt;&lt; "; nchi2.ncp = " &lt;&lt; nchi2.non_centrality() &lt;&lt; endl; cout &lt;&lt; "P(X &lt;= " &lt;&lt; quantile &lt;&lt; ") = " &lt;&lt; cdf(nchi2, quantile) &lt;&lt; endl; cout &lt;&lt; "P(X &gt; " &lt;&lt; quantile &lt;&lt; ") = " &lt;&lt; cdf(complement(nchi2, quantile)) &lt;&lt; endl; return 0; } </pre><p> Note the output lines P(X &gt; 12), which should all be equal. In the first two cases this is correct, but in the last one P(X &gt; 12) = - P(X &lt;= 12), which is necessarily wrong. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11557 Trac 1.4.3 Mark Abney <maabney@…> Wed, 19 Aug 2015 19:13:56 GMT component changed; owner set https://svn.boost.org/trac10/ticket/11557#comment:1 https://svn.boost.org/trac10/ticket/11557#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">John Maddock</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">math</span> </li> </ul> Ticket Mark Abney <maabney@…> Wed, 19 Aug 2015 19:15:31 GMT version changed https://svn.boost.org/trac10/ticket/11557#comment:2 https://svn.boost.org/trac10/ticket/11557#comment:2 <ul> <li><strong>version</strong> <span class="trac-field-old">Boost 1.57.0</span> → <span class="trac-field-new">Boost 1.59.0</span> </li> </ul> Ticket John Maddock Thu, 20 Aug 2015 08:10:57 GMT <link>https://svn.boost.org/trac10/ticket/11557#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11557#comment:3</guid> <description> <p> Will investigate, thanks for the report. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Fri, 04 Sep 2015 08:41:17 GMT</pubDate> <title>status, milestone changed; resolution set https://svn.boost.org/trac10/ticket/11557#comment:4 https://svn.boost.org/trac10/ticket/11557#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.60.0</span> </li> </ul> <p> Fixed in <a class="ext-link" href="https://github.com/boostorg/math/commit/a0f0b969210e94a446d615499f32d5d21dee0a9b"><span class="icon">​</span>https://github.com/boostorg/math/commit/a0f0b969210e94a446d615499f32d5d21dee0a9b</a> </p> Ticket