X1,X2,…XnμσH0:μ=μ0Ha:μ≠μ0Z=X¯−μ0σ/n√.GdyH0jest prawdziwe,Z∼Norm(0,1),więc odrzucamyH0na poziomie 5%, jeśli|Z|≥1.96.
Następnie „odwracając test”, mówimy, że 95% CI dla μ składa się z wartości μ0 , które nie prowadzą do odrzucenia - „wiarygodne” wartości μ.CI ma postać X¯±1.96σ/n−−√,gdzie±1.96prawdopodobieństwo odcięcia 0,025 odpowiednio od górnej i dolnej części ogona standardowego rozkładu normalnego.
Jeżeli odchylenie standardowe populacji σ jest nieznane i oszacowane przez próbne odchylenie standardowe S, wówczas używamy statystyki T=X¯−μ0S/n√.TnSσ.
T∼T(ν=n−1),n−1σX¯±t∗S/n−−√,±t∗T(n−1).
n>30,t∗≈2≈1.96.Sσσn>30,
Xnp^=X/np.H0:p=p0Ha:p≠p>0,Z=p^−p0p0(1−p0)/n√. Under H0, we know that Z∼aprxNorm(0,1). So we reject H0 if |Z|≥1.96.
If we seek to invert this test to get a 95% CI for p, we run into some difficulties. The 'easy' way to invert the test is to
start by writing p^±1.96p(1−p)n−−−−−√. But his is useless because the value of p under the square root is unknown. The traditional Wald CI assumes that, for sufficiently large n, it is OK to substitute p^ for unknown p. Thus the Wald CI is of the form p^±1.96p^(1−p^)n−−−−−√. [Unfortunately, the Wald interval works well only if the number of trials n is at least several hundred.]
More carefully, one can solve a somewhat messy quadratic inequality to 'invert the test'. The result is the Wilson interval. (See Wikipedia.) For a 95% confidence interval a somewhat simplified version of this result comes from
defining nˇ=n+4 and pˇ=(X+2)/nˇ and then computing the interval as pˇ±1.96pˇ(1−pˇ)nˇ−−−−−√.
This style of binomial confidence interval is widely known as the Agresti-Coull interval; it has been widely advocated in elementary textbooks for about the last 20 years.
In summary, one way to look at your question is that CIs for normal μ and binomial p can be viewed as inversions of tests.
(a) The t distribution provides an exact solution to the problem of needing to use S for σ when σ is unknown.
(b) Using p^ for p requires some care because the mean and variance of p^ both depend on p. The Agresti-Coull CI provides one serviceable way to get CIs for binomial p that are reasonably accurate even for moderately small n.