Physics articles and information
RSS icon Home icon
  • chi2cdf

    Posted on February 8th, 2010 admin No comments

    If you’re a luddite like me (all my analysis code these days is written in octave-2.1.73 and octave-3.0 (better octave-forge support)) and you have a propensity o,  you may have encountered this error:

    </code>
    
    octave:1> chi2cdf(4000,4000)
     ***MESSAGE FROM ROUTINE D9LGIT IN LIBRARY SLATEC.
     ***FATAL ERROR, PROG ABORTED, TRACEBACK REQUESTED
     *  NO CONVERGENCE IN 200 TERMS OF CONTINUED FRACTION
     *  ERROR NUMBER = 3
     *
     ***END OF MESSAGE
    
     ***JOB ABORT DUE TO FATAL ERROR.
    0          ERROR MESSAGE SUMMARY
     LIBRARY    SUBROUTINE MESSAGE START             NERR     LEVEL     COUNT
     SLATEC     D9LGIT     NO CONVERGENCE IN 20         3         2         2
    
    error: exception encountered in Fortran subroutine xgammainc_
    error: evaluating assignment expression near line 54, column 15
    error: evaluating if command near line 53, column 5
    error: evaluating if command near line 52, column 3
    error: called from `gamcdf' in file `/usr/share/octave/3.0.1/m/statistics/distributions/gamcdf.m'
    error: evaluating assignment expression near line 42, column 7
    error: called from `chi2cdf' in file `/usr/share/octave/3.0.1/m/statistics/distributions/chi2cdf.m'
    
    <code>

    This is related (as above) to the library D9LGIT. Certainly in my case, and probably in general, there is another way to solve the problem. The gamma functions that underpin all of it will probably have nice asymptotics in any regime that triggers the error.  There’s scuttlebutt that this problem is better handled by the GSL library with hooks to Octave – it may be implemented “upstream” in the current Octave 3.2.

    In the case of

    chi2cdf

    , for k sufficiently large (look here to determine “large” for yourself),

    chi2cdf(x,k) and normcdf(x,k,sqrt(2*k))

    will generate essentially equivalent results. The absence of  incomplete gamma functions in

    normcdf

    make it more general (and inapplicable for small k).

    • Digg
    • Sphinn
    • del.icio.us
    • Facebook
    • Mixx
    • Google Bookmarks
    • De.lirio.us
    • Furl
    • MySpace
    • Ping.fm
    • Reddit
    • Spurl
    • StumbleUpon
    • Technorati
    • Tumblr
    • TwitThis
    • Yahoo! Buzz

    Leave a reply