1

My question is:
How t-statistic and p value are calculated in formula stats.ttest_1samp() python ?
There is a gap between formula results and my manual calculation which cause to opposite answers.

example:
A claim, coin isn't fair.

observations = [1,1,1,1,1,1,1,1,0,0]
μ = 0.5
α = 0.05 (confidence level 95%)

H0 : p=0.5 ,coin is fair
H1: p != 0.5 , coin isn't fair

Formula:
input: stats.ttest_1samp(observations,0.5)
output: t_statistic = 2.25 , p_value = 0.051
t_critic = 2.26 (df=9, 2 side tail 95%)
result : (t_statistic < t_critic) & (p_value > α) => Accept H0

Manual calculation: input:
x= np.mean(observations) = 0.8
μ = 0.5
n=10
σ = np.std(observations) = 0.4
T_statistic = input: (x-μ)/(σ/√n) => (0.8-0.5)/(0.4/√10) => 2.37

output
t_statistic = 2.37, p_value = 0.0089 (p_value according Z table for 2.37)
t_critic = 2.26 (degree of freedom=9, 2 side tail 95%)
result : (t_statistic > t_critic) & (p_value < α) => Reject H0

0 Answers0