Numerical Recipes Forum  

Go Back   Numerical Recipes Forum > Numerical Recipes Official Announcements > Official Bug Reports (NR3, the Third Edition)

Reply
 
Thread Tools Display Modes
  #1  
Old 11-28-2008, 01:17 PM
Bill Press Bill Press is offline
Numerical Recipes Author
 
Join Date: Dec 2001
Posts: 227
incgammabeta.h: bug in Gamma (fixed in V3.04)

In versions 3.02 and earlier, there is a bug in Gamma. For (unusually) large values of a and x, and with x << a, so that gammp should be 0, gammq should be 1, incorrect values (that swap 1 and 0) can be returned.

The bug is in gammpapprox(). To fix the bug, the line
Code:
return (psig?(ans>0.0? 1.0-ans:-ans):(ans>=0.0? ans:1.0+ans));
should be replaced by
Code:
return (psig?(x>a1? 1.0-ans:-ans):(x>a1? ans:1.0+ans));
This bug is also responsible for Poissondist::cdf(n) throwing exceptions in unusual cases, see here
Reply With Quote
  #2  
Old 08-31-2010, 05:38 PM
emilpohl emilpohl is offline
Registered User
 
Join Date: Sep 2009
Posts: 6
Bug reported, but NR3 hosted by the ICTP didn't change the code.

Hi!

I'm using NR3 hosted by the International Centre for Theoretical Physics. I've noticed that the code:

return (psig?(ans>0.0? 1.0-ans:-ans):(ans>=0.0? ans:1.0+ans));

wasn't changed after the Bug report. Is there a reason for this?

best regards,

Carlos
Reply With Quote
  #3  
Old 08-31-2010, 08:19 PM
Bill Press Bill Press is offline
Numerical Recipes Author
 
Join Date: Dec 2001
Posts: 227
Good call, Carlos. In general, we only change the code distributions when we change the version numbers (often corresponding to new printings of the book) when many bugs are fixed at one time. We don't change the distributions after each individual bug.
Cheers,
Bill P.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 11:59 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.