Hi all, hi Pauli. ;-)
over the last weeks there has been some discussion on the normal distribution and its inverse (quantile). I think the 34s performs pretty well now. The CDF should be exact and there also is a good first estimate for the quantile. After this, the Halley method returns results with fast convergence to the exact value. So far, so good.
The second important distribution we should take a closer look at now is Student's t-distribution. I have been experimenting a while with several approaches, and I finally got a result that I think is fine as a first estimate. Use at your own risk, expect any error you can imagine, but try this:
- For df = 1 or 2 degrees of freedom the quantile can be determined directly.
This also is the case for n = 4, it only requires a bit care at very low t (close to zero) or p close to 0,5. - For other degrees of freedom, i.e. df >= 3, the following method provides a nice first estimate. As usual, p is assumed to be less than 0,5 and t > 0.
if -ln(p) < 1,7 * df then
x = guess_normal(p)
u = (x^3 + x) / 4 / df
v = (x^5 / 12 + x^3 / 4) / df^2
t = x + u + v
else
u = 2 * p * df * sqrt(Pi / (2*df - 1))
t = sqrt(df) / u^(1/df)
end if
This single estimate now can be used for a Newton-iteration - the first derivative simply is the Student PDF, so we get
tCDF(t) - pIf two guesses are required (e.g. for the 34s solver) we can simply use 1.1*t and 0.9*t (or something similar).
t_new = t - -----------
tPDF(t)
And now: try it and let me know about your results. ;-)
Dieter
Edit: tail formula now looks slighty more elegant ;-)
Edited: 27 Apr 2011, 4:01 p.m. after one or more responses were posted