Re: Good algorithm for Inverse of cumulative Student's t?




Schizoid Man wrote:
Hi,

I'm trying to set up a credit risk model that employees a Student t
copula. For this purpose, I need algorithms for:

a. the cumulative distribution function of the Student t
b. the inverse of the cumulative distribution function of the Student t

I nicked the CDF from Numerical Recipes and it seems to do the job quite
well, but I have not had much luck with the inverse algorithm.

I also needed to setup a Gaussian copula for which I used Excel's
built-in NORMSDIST() for the CDF which was good enough, and P.J.
Acklam's inverse algorithm, since NORMSINV() is meant to be quite horrible.

Thanks,
Schiz

You could use the inv_tdist code in
http://members.aol.com/iandjmsmith/Examples.xls (VBA code only in
http://members.aol.com/iandjmsmith/Examples.txt)

It requires a accurate algorithm for the cdf of the t-distribution and
a function to invert the normal distribution.

The accuracy of the cdf of the t-distribution from NR is not very high
so you will have to reduce the accuracy to which the code for inv_tdist
works.

If you wish an algorithm rather than code

Choose a decent starting approximation. I use the one given in
Abramowitz & Stegun (26.7.5)
For probabilities <= 0.5 use Newton Raphson to solve
log(cdf(tapprox,df)) = log(prob)
which is done using

new tapprox = tapprox -
log(cdf(tapprox,df)/prob).cdf(tapprox,df)/pdf(tapprox,df)

if prob and cdf(tapprox,df) are not close together or

new tapprox = tapprox -
log1p((cdf(tapprox,df)-prob)/prob).cdf(tapprox,df)/pdf(tapprox,df)

if prob and cdf(tapprox,df) are close together. log1p(x) is a function
which evaluates log(1+x) accurately for small x.

For probabilities > 0.5 use -inv_tdist(1-prob,df)

If you want a more accurate function for the cdf of the t-distribution
use cdf_tdist from the same source.

Ian Smith

.



Relevant Pages

  • Good algorithm for Inverse of cumulative Students t?
    ... I'm trying to set up a credit risk model that employees a Student t copula. ... the inverse of the cumulative distribution function of the Student t ... I also needed to setup a Gaussian copula for which I used Excel's built-in NORMSDISTfor the CDF which was good enough, and P.J. Acklam's inverse algorithm, since NORMSINVis meant to be quite horrible. ...
    (sci.stat.math)
  • Re: Applying Poisson methods
    ... It is certainly not your algorithm. ... use of an inverse CDF and mine. ... CDF as you show, so long as it does not break. ... Take the square root of 75, to save as a constant M. ...
    (sci.stat.math)
  • Re: PRINTING DIAMOND SHAPE WITH LOOPS!
    ... Okay, Paul, et al., ... > falsely not to be a student, while explaining what kind of student you are. ... > of place in a simple, deterministic algorithm like this. ...
    (comp.lang.java.programmer)
  • Re: Why NP Problem is Important and Practical Examples
    ... there is a poly-time algorithm to verify a particular solution. ... My student was working as a software developer and he was meeting ...
    (comp.theory)
  • Re: PRINTING DIAMOND SHAPE WITH LOOPS!
    ... > stereotypes. ... Neither unfair nor a stereotype. ... falsely not to be a student, while explaining what kind of student you are. ... deterministic algorithm like this. ...
    (comp.lang.java.programmer)