This project has moved and is read-only. For the latest updates, please go here.

P Value from t-stat in VB.net

Mar 11, 2014 at 10:51 PM
Forgive me as I have no clue what I am doing.... I am neither a computer programmer nor a statistician! I just dabble in both!

I have a t-stat in some VB code. I want to translate that into a p value (similar to excel 2007 function tdist, where I can supply the t stat, the degrees of freedom, and the number of tails (in my case 1).

I referenced meta numerics add in, but now I am lost. I just need to feed it those three variables and return the p value (probability).

Thanks in advance for any help!
Mar 12, 2014 at 6:37 PM
Here is the code you want:
    public static double StudentRightTailProbability (double degreesOfFreedom, double tValue) {
        StudentDistribution distribution = new StudentDistribution(degreesOfFreedom);
        double rightTailProbability = distribution.RightProbability(tValue);
        return(rightTailProbability);
    }
For example, StudentRightTailProbability(3, 2.0) returns 0.06966298... The Student distribution (and a lot of other distributions) are classes in the Meta.Numerics.Statistics.Distibutions namespace. For any distribution, you can find its right tail probability using the RightProbability method. For a symmetric distribution such as Student's t, the two-tailed probability will just be twice as big.
Mar 17, 2014 at 9:10 PM
Thank you! I will give that a try!