Z-test¶
So here is a handcoded function for Z-Test
In [4]:
def twoSampZ(X1, X2, mudiff, sd1, sd2, n1, n2):
from numpy import sqrt, abs, round
from scipy.stats import norm
pooledSE = sqrt(sd1**2/n1 + sd2**2/n2)
z = ((X1 - X2) - mudiff)/pooledSE
pval = 2*(1 - norm.cdf(abs(z)))
return round(z, 3), round(pval, 4)
X1bar = X1, X2bar2 = X2, mudiff = u1-u2, sd1 = standard dev of 1st sample, sd2 = standard deviation of 2nd sample, n1 =1st sample size, n2 = 2nd sample size...
For Example¶
In [3]:
z, p = twoSampZ(28, 33, 0, 14.1, 9.5, 75, 50)
print (z, p)
No comments:
Post a Comment