How can I get the P value of the two-tail Student's test when I know the T value and Degree of Freedom?

17 views (last 30 days)
I have already known the T and Degree of Freedom. I try to calculate the P value with tpdf and tcdf. They output the different answers. I would like to konw which one is right. Thank you!
  2 Comments
the cyclist
the cyclist on 10 Mar 2023
Can you share your parameters and the code that you used to calculate the P value? (You can use the paper clip icon in the INSERT section of the toolbar.)
I would expect you are going to need the cdf, not the pdf, to calculate the P value.
Murong Qi
Murong Qi on 10 Mar 2023
Edited: Murong Qi on 10 Mar 2023
This is an example of my code:
%eg:t-value:10 ; Degree of freedom: 20
%[method 1]:tpdf
p1 = tpdf(10,20);
%[method 2]:tcdf
p2 = 2*tcdf(-abs(10),20);

Sign in to comment.

Accepted Answer

the cyclist
the cyclist on 10 Mar 2023
Sorry for the delayed response. I did not get a notification that you had replied.
Your second method is the correct one (assuming you want 2-tailed P value):
t = 10;
DOF = 20;
twoTailedPValue = 2*tcdf(-t,DOF)
twoTailedPValue = 3.1638e-09
I verified the P values at this site (using a smaller value of t, that site won't calculate such a small P value exactly).
I'm not sure why you think your first method would be correct. The pdf value is not directly relevant; you need the integral under the pdf (which is of course the cdf).

More Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!