Boost C++ Libraries: Ticket #2877: Approximation error in the non central chi square distribution https://svn.boost.org/trac10/ticket/2877 <p> Hi, </p> <p> I'll like inform you about an error of approximation on the non central chi square distribution. </p> <p> When the freedom degree is equal to 3, the distribution calls the modified bessel function of the first kind. </p> <p> In this case, I0.5(x) = sqrt(2 / πx) * sinh(x) ( see <a href="http://www.boost.org/doc/libs/1_36_0/libs/math/doc/sf_and_dist/html/math_toolkit/special/bessel/mbessel.html">http://www.boost.org/doc/libs/1_36_0/libs/math/doc/sf_and_dist/html/math_toolkit/special/bessel/mbessel.html</a> ) </p> <p> Nonetheless, it seems that you use yet the Berton and Krishnamoorthy method and their recurrence, and that imply an error approximation. </p> <p> For example, i compute the method with R. let x = 5.0, freedom degree = 3.0 and the non-centrality parameter = 1.5 then dchisq(5.0,3,1.5) = 0.0972573 (See the wikipedia example) </p> <p> When i use I0.5(x) = sqrt(2 / πx) * sinh(x) to compute the chi square distribution, i find the same result. </p> <p> conversely, when i use the boost library non_central_chi_squared.hpp, my result is 0.0976656. </p> <p> Note in the other cases, the deviation between the two results can be greater </p> <p> best regards, Cédric Naud </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2877 Trac 1.4.3 John Maddock Sat, 21 Mar 2009 10:21:54 GMT status changed https://svn.boost.org/trac10/ticket/2877#comment:1 https://svn.boost.org/trac10/ticket/2877#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> <p> Confirmed as a bug, I just can't spot the error at present... </p> Ticket John Maddock Sat, 21 Mar 2009 18:30:11 GMT attachment set https://svn.boost.org/trac10/ticket/2877 https://svn.boost.org/trac10/ticket/2877 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">bessel.patch</span> </li> </ul> Ticket John Maddock Sat, 21 Mar 2009 18:31:03 GMT <link>https://svn.boost.org/trac10/ticket/2877#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2877#comment:2</guid> <description> <p> It's a bug in cyl_bessel_i that's causing the issue - a patch is attached to this ticket, will be in SVN shortly. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Sat, 21 Mar 2009 18:44:38 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/2877#comment:3 https://svn.boost.org/trac10/ticket/2877#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/51890" title="Fix bug in cyl_bessel_i that hits when v=0.5 and x is small. Fix ...">[51890]</a>) Fix bug in cyl_bessel_i that hits when v=0.5 and x is small. Fix return type of signbit to match C99 std. Update and regenerate docs. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2877" title="#2877: Bugs: Approximation error in the non central chi square distribution (closed: fixed)">#2877</a>. </p> Ticket