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?
Solved! Go to Solution.
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
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?
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.
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?
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.