# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution
Highlighted

## Inverse CDF for noncentral t distribution

I'd like to create a VI that calculates the confidence interval for the p-th percentile of a normally distributed variable using the Lawless method, as described here. This requires computing the inverse cumulative distribution function (CDF) for a noncentral t distribution.

I'm familiar with the "Continuous Inverse CDF.vi", but there's no option for a noncentral t distribution in that VI.

Is there a way to compute the inverse CDF for a noncentral t distribution in LabVIEW?

Message 1 of 8
(215 Views)
Highlighted

## Re: Inverse CDF for noncentral t distribution

Wikipedia or a good applied statistics book has the series you need for the CDF.  Instead of brute-forcing it I factored the components so that each term in the series can be found from the previous value.  Matches the central distribution when delta = 0 and gives me 10+ digit matches for the values I checked by hand.  Double check for bugs since I just kind of tossed this together. Saved for LV14

Message 2 of 8
(157 Views)
Highlighted

## Re: Inverse CDF for noncentral t distribution

Thanks Darin. I'm actually looking to compute the inverse CDF - i.e. the p-value is my input and the noncentral t-value is my output. It doesn't look like there's a nice analytical formula, so would I have to just use a lookup table after generating a bunch of data from the CDF?

Message 3 of 8
(133 Views)
Highlighted
Solution
Accepted by topic author jrdwight

## Re: Inverse CDF for noncentral t distribution

I knew that when I started and then forgot when I finished the CDF VI.  If you are using the same parameters (delta, DOF) it may be worthwhile to create a lookup table and interpolate.  What I normally do is use a root finding routine, and I find Ridder's to be a good choice in situations where I am approximating the function.

I have attached a wrapper so the CDF function can be called from the built-in root finder VI, and a VI which brackets the desired value and then calls the root finder to locate the inverse.

Message 4 of 8
(126 Views)
Highlighted

## Re: Inverse CDF for noncentral t distribution

This is perfect! I'd started creating a lookup table, but this is much more efficient. Thank you so much!

Message 5 of 8
(117 Views)
Highlighted

## Re: Inverse CDF for noncentral t distribution

Sorry, one problem I just noticed: it seems to run indefinitely for negative values of delta (noncentrality parameter). I tried making the "max error" something much smaller, like 1E-03, but it still runs indefinitely. (Granted, I've only waited maybe 15-20 seconds.)

Any idea what might be causing this? Is there a property of the noncentral t-distribution that would let me calculate the t-value at a positive gamma, then convert the t-value to the corresponding negative gamma value?

Message 6 of 8
(111 Views)
Highlighted
Solution
Accepted by topic author jrdwight

## Re: Inverse CDF for noncentral t distribution

My bad, you need to feed abs(delta) into the Upper Bound and Lower Bound While loops instead of delta.   I use delta as sort of a natural step size when finding the bounds.

I'll post a picture if you need it.  Just insert the Abs(x) node into the branch that feeds the two while loops.

Message 7 of 8
(100 Views)
Highlighted

## Re: Inverse CDF for noncentral t distribution

That worked! Thanks again.

Message 8 of 8
(91 Views)