z-test of Null hypothesis that mean is equal to value.
The alternative hypothesis H1 is defined by the following ‘two-sided’: H1: mean not equal to value ‘larger’ : H1: mean larger than value ‘smaller’ : H1: mean smaller than value
value : float or array
alternative : string
tstat : float
pvalue : float
This uses the same degrees of freedom correction as the t-test in the calculation of the standard error of the mean, i.e it uses (sum_weights - 1) instead of sum_weights in the denominator. See Examples below for the difference.
z-test on a proportion, with 20 observations, 15 of those are our event
>>> x1 = [0, 1] >>> w1 = [5, 15] >>> d1 = smws.DescrStatsW(x1, w1) >>> d1.ztest_mean(0.5) (2.5166114784235836, 0.011848940928347452)
This differs from the proportions_ztest because of the degrees of freedom correction:
>>> smprop.proportions_ztest(15, 20., value=0.5) (2.5819888974716112, 0.009823274507519247).
We can replicate the results from proportions_ztest if we increase the weights to have artificially one more observation:
>>> smws.DescrStatsW(x1, np.array(w1)*21./20).ztest_mean(0.5) (2.5819888974716116, 0.0098232745075192366)