bugGNU Octave - Bugs: bug #56453, [octave forge] (statistics)...

 
 

bug #56453: [octave forge] (statistics) chi2inv, gaminv inaccurate for small 1st argument

Submitter:  None
Submitted:  Thu 06 Jun 2019 08:39:08 PM UTC
   
 
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Inaccurate Result
Status:  Fixed Assigned to:  None
Originator Name:  Jerry W. Lewis Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 4.4.1
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Wed 28 Sep 2022 10:02:42 AM UTC, comment #10: 

The issue in gaminv has been fixed, hence the chi2inv as well which relies on gaminv. Additional BISTs have been added to test fo small 1st arguments. Changes pushed at https://github.com/gnu-octave/statistics/commit/030eaac98131b5bdcead2238cf40e05ba77eb6e4
This can be closed.

Andreas Bertsatos <pr0m1th3as>
Sat 14 Sep 2019 06:15:54 PM UTC, comment #9: 

I applied the patch for gammaincinv from comment #2 here (https://hg.savannah.gnu.org/hgweb/octave/rev/9a946e34553c).

The remaining two functions are part of the statistics package on Octave Forge.  I have re-categorized the bug and marked the issue as confirmed.


Rik <rik5>
Group administrator
  Spam posted by _148912
  Spam posted by _148921
  Spam posted by _148912
  Spam posted by _148912
  Spam posted by _148912
  Spam posted by _148563
Fri 07 Jun 2019 11:45:41 AM UTC, comment #2: 

The attached patch seems to solve the problem for gammaincinv. Maybe a similar fix can be applied to the other two functions?

(file #47051)

Marco Caliari <caliari>
Group Member
Fri 07 Jun 2019 02:49:09 AM UTC, comment #1: 

Likely the issue is in part a poor starting value from which Newton's method either diverges or converges very slowly.

It follows from Abramowitz & Stegun 26.4.6 that as p approaches zero,
chi2inv(p,df) approaches 2*[p*gamma(1+df/2)]^(2/df)

Jerry W. Lewis <jlewis>
Thu 06 Jun 2019 08:39:08 PM UTC, original submission:  

The following should be analytically true
  chi2inv(p,df) == gaminv(p,df/2,1)*2 == gammaincinv(p,df/2)*2

Consider chi2inv(p,2), which converges to 2*p as p approaches zero.

chi2inv(1e-15,2) returns 2.000000000000001e-15 for essentially machine accuracy;
gaminv(1e-15,1,1)*2 returns 1.900000018803639e-15 for 1 figure accuracy; and
gammaincinv(1e-15,1)*2 returns 1.998401444325283e-15 for 3 figure accuracy.

chi2inv(p,2) for p<=1e-16 returns 1.490116119384766e-09 instead of 2*p;
gaminv(p,1,1)*2 for p<=1e-16 returns 2.980232238769531e-09 == chi2inv(p,2)*2 instead of 2*p; and
gammaincinv(1e-16,1)*2 returns 2.220446049250313e-16 for almost 1 figure accuracy.

gammaincinv(p,1)*2 for p<=1e-17 returns -0 instead of 2*p.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #47051:  gammaincinv.diff added by caliari (6KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by nrjank (Updated the item)
  • -email is unavailable- added by pr0m1th3as (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by _148921 (Posted a comment)
  • -email is unavailable- added by _148912 (Posted a comment)
  • -email is unavailable- added by _148563 (Posted a comment)
  • -email is unavailable- added by caliari (Updated the item)
  • -email is unavailable- added by jlewis (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 9 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-09-28 nrjank StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2020-05-29 mtmiller Summary[Octave-Forge] chi2inv, gaminv inaccurate for small 1st argument [octave forge] (statistics) chi2inv, gaminv inaccurate for small 1st argument
    2019-09-14 rik5 CategoryOctave Function Octave Package
        StatusPatch Submitted Confirmed
        Operating SystemMicrosoft Windows Any
        Summarychi2inv, gaminv, gammaincinv inaccurate for small 1st argument [Octave-Forge] chi2inv, gaminv inaccurate for small 1st argument
    2019-06-07 caliari Attached File- Added gammaincinv.diff, #47051
        StatusNone Patch Submitted

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code