Post Reply 
[WP34s] Regularized incomplete Beta function
05-09-2014, 09:06 PM (This post was last modified: 05-09-2014 09:09 PM by Dieter.)
Post: #42
RE: [WP34s] Regularized incomplete Beta function
(05-08-2014 11:29 PM)Paul Dale Wrote:  The series expansion for the incomplete gamma function (as opposed to the continued fraction variation) isn't converging in 500 iterations for x around the degrees of freedom.
...
Perhaps I got the threshold for switching between the continued fraction and the series expansion wrong.

I am not very good at finding the code of a particular 34s function on Sourceforge, so this is what I assume: the incomplete Gamma function may use the two "classic" series resp. CF representations as suggested e.g. in Numerical Recipies, chapter 6-2. Here, the recommended threshold for IΓ(a, x) is the point where x equals 1+a. For lower x the series is used, for higher x it's the continued fraction method. This would also explain why the Normal CDF requires significantly more time for x>√3, since the CDF is evaluated as IΓ(0.5, x²/2) so that the switch between both methods occurs here: 1 + 0.5 = (√3)²/2. If this really is the way IΓ works, you got the threshold right.

Quote:This might also explain the gradual loss of digits you are seeing at time. That would match the behaviour of the continued fraction path which attempts to return something based on the best guess. The series code just returns zero when its iteration count expires.

So does the code in the NR book. ;-)

I assume the CF is evaluated by some kind of Lentz's method. I do not know how fast this is in C, but in user code I prefer a different approach (not only) for speed reasons: estimate the number of required terms and evaluate the CF from right to left. I did this with the Normal CDF in a user code program for the 34s and it works very well and, most important, it's fast. I even think that this provides somewhat better accuracy. ;-)

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: [WP34s] Regularized incomplete Beta function - Dieter - 05-09-2014 09:06 PM



User(s) browsing this thread: 1 Guest(s)