How to get p_value 0.0407?

import numpy as np
from scipy.stats import t
import math

n = 10
sigma = 3
x_bar = 68.442
mu = 66.7
t_value = (x_bar - mu) / (sigma / np.sqrt(n))
degrees_of_freedom = n-1
p_value = 1 - t.cdf(t_value, df=degrees_of_freedom)

I got p_value is 0.04975307053715594, not is 0.0407 .
How can I get p_value is 0.0407?

p-value

Apparently the results in the slides are incorrect.
A ticket has been submitted to the course staff to update the slides.

1 Like

Hi @Haiyun_Hu. As @TMosh mentioned it was a mistake on the slides, and it is being fixed.
However, I did want to point out that in the code you attached you seem to be using the t distribution to compute the probability. That’s the case when the variance (or standard deviation) is unknown. In this particular example the standard deviation has a value of 3, so the statistic actually follows a Gaussian distribution, and not a t.

2 Likes

Thank you @magdalena.bouza , for replying me.
for Gaussian distribution ,

import numpy as np
from scipy.stats import norm
import math

n = 10
sigma = 3
x_bar = 68.442
mu = 66.7
z_value = (x_bar - mu) / (sigma / np.sqrt(n))
p_value = 1 - norm.cdf(z_value)

(p_value : 0.03316188082855842)

Am I right?

Thank you

Yes, this is correct! Sorry again for the confusion

1 Like