Unknown Standard Deviations
Solution
import scipy.stats
t = ((100-105)-(0))/(5**2/50+10**2/75)**.5
print(t)
print(scipy.stats.norm.cdf(t)*2)
print(scipy.stats.norm.cdf(t))
If we instead don’t know the standard deviations, the equation becomes….
Equation
When we compute this t value, the degrees of freedom equals min(N
1
-1,N
2
-1). We only need to do this with low sample sizes, otherwise the t score converges to the z score.
Let’s do an example…
dist1 = scipy.stats.norm(300,100)
dist2 = scipy.stats.norm(400,100)
pts1 = dist1.rvs(25,random_state=1)
pts2 = dist2.rvs(26,random_state=2)
So now we have two random samples, let’s get our t score.
import numpy as np
sd1 = np.std(pts1)
sd2 = np.std(pts2)
mean1 = np.mean(pts1)
mean2 = np.mean(pts2)
t = ((mean1-mean2)-(0))/(sd1**2/25+sd2**2/26)**.5
print(t)
print(scipy.stats.t.cdf(t,25-1)*2)
The chance that the two distributions are the same is small! We would expect this though, we set up two distributions that have a difference in means of 100! What if we had a hunch that our samples should have a difference of 100? This would meanH
0
: μ
1
+100 = μ
2
.
import numpy as np
sd1 = np.std(pts1)
sd2 = np.std(pts2)
mean1 = np.mean(pts1)
mean2 = np.mean(pts2)
t = ((mean1-mean2)-(-40))/(sd1**2/25+sd2**2/26)**.5
print(t)
print(scipy.stats.t.cdf(t,25-1)*2)
Now, we do not have a significant value!