Re: [WP34S] Bug in Inverse CDF for Fdistribution Message #8 Posted by Dieter on 15 Apr 2012, 9:53 a.m., in response to message #7 by Paul Dale
Pauli,
I am not sure how the F quantile function finally was implemented, and for this distribution I only found some tests for an initial guess. However, my results are different. Please note that the probability here is given by q = 1p instead of p. This is also important because the F guess may include the guess for the normal quantile which has to carry the correct sign here!
Here are my results:
q = 0.05, n1 = 5, n2 = 10 => f_guess = 3.30
q = 0.95, n1 = 10, n2 = 5 => f_guess = 0.30 (= 1/3.30)
That's quite close to the exact value, isn't it ?)
Regarding the divergent Newton steps: you may want to check if the CDF returns results with sufficient accuracy. Then, I remember we had a discussion on a similar problem with another distribution. The simple and effective solution was limiting the correction to a maximum possible amount. Which here could be the correction applied in the previous iteration.
Addendum: I wrote a short program for the 34s emulator and tried the given example (0.05; 10; 5) with the initial guess based on the wrong probability 1p (iteration starts at 4,7 or 3,3 instead of 0.2 or 0.3). The program threw exactly the same domain error as it tried to evaluate the PDF for a large negative x. ;)
Then I tried the example with the correct initial guess 0.30 and the iteration converged to 34 digits (DBLON) within 5 or 6 Newton steps. :)
Maybe we tracked down the error. If we did, the whole F quantile should even get evaluated faster than before. Pauli, please check how the current implementation works if you replace 0.95 by 0.05 and vice versa and/or n1 and n2 are swapped. Also the guess for the normal quantile has to carry the correct sign.
Dieter
Edited: 15 Apr 2012, 12:26 p.m.
