
I'm trying to replicate the following
R code using Meta Numerics:
t.val = qt(0.9, 2)
Using the StudentDistribution class, I'm doing this...
var dist = new StudentDistribution(2);
... and then I want to get the value for a Avalue of 0.9 (from
here this should be 2.920). I'm not a stats guy, so I'm totally lost... HELP!



The code you want is:
double A = dist.InverseLeftProbability(0.95);
which assigns the value 2.91998... to A.
Here's what's going on: R's qt function maps a probability value to a tvalue. The probability value it expects as input is a central probability, the area under the probability distribution from t to +t. You give it that central probability, which I'll call
C, and it will give you back t. Meta.Numerics InverseLeftProbability metods expect a left probability, the area under the probability distribution from Infinity to t. You give it that left probability, which I'll call L, and it will give you back t. If you
sketch this on a piece of paper, you'll see that given a central area C, the left and right tails must each have area (1C)/2, so the left area must be L=(1+C)/2. Plug C=0.90 into that equation and you will get L=0.95, which is where the 0.95 above came from.
If you want a complete reimplementation of R's qt function in Meta.Numerics, here it is:
public static double qt (double C, double n) {
StudentDistribution s = new StudentDistribution(n);
double L = (1.0 + C) / 2.0;
return (s.InverseLeftProbability(L));
}



Many thanks ichbin, exactly what I needed!

