09-16-2020 12:33 PM
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.
09-17-2020 05:30 PM
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
09-18-2020 09:24 AM
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?
09-18-2020 12:29 PM
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.
09-18-2020 02:23 PM
This is perfect! I'd started creating a lookup table, but this is much more efficient. Thank you so much!
09-18-2020 03:14 PM
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?
09-18-2020 03:47 PM - edited 09-18-2020 03:49 PM
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.
09-18-2020 04:21 PM
That worked! Thanks again.