AI Wiki中文/EN

Hypothesis testing

假设检验

Calculate an exact binomial p-value, distinguish error rates from posterior probabilities, and report effects alongside decisions.

On this pageIntuitionMathematics & methodImplementationLimitationsExercisesResearch connections

Ten wins out of twelve: unusual under which model?

Two methods are compared in twelve independent trials with no ties. Method A wins ten. Before observing results, you specify a null model in which A has win probability one half on every trial, and a one-sided alternative that A wins more often.

The question is not “what is the probability that the null is true?” It is “if this null model generated the trials, how often would the chosen statistic be at least this favorable to A?” The distinction determines what a p-value can say.

Specify the null, alternative, statistic, and rule

Let XX be the number of A wins. Under the stated independent Bernoulli null, XX has a binomial distribution. For observed value xx, the upper-tail p-value is:

PH0(X=k)=(nk)2−n,pupper=PH0(X≥x)=∑k=xn(nk)2−n.P_{H_0}(X=k)=\binom nk2^{-n},\qquad p_{\mathrm{upper}}=P_{H_0}(X\ge x)=\sum_{k=x}^n\binom nk2^{-n}.

For n=12,x=10n=12,x=10, this is (66+12+1)/4096=79/4096≈0.01929(66+12+1)/4096=79/4096\approx0.01929. We counted outcomes at least as extreme in the prespecified direction, including the observed one. The result concerns the complete sampling model, including independence and the win definition. NIST, statistical tests

A level-α\alpha procedure limits its probability of rejecting a true null to at most α\alpha under the null’s assumptions. Here rejecting when the upper-tail p-value is at most 0.05 means rejecting at ten or more wins. Its actual null rejection probability is about 0.01929, below 0.05 because the statistic is discrete. With nine wins, the tail probability is 299/4096≈0.07300299/4096\approx0.07300.

Type I error means rejecting a true null. Type II error means failing to reject a false null; its probability β\beta depends on the particular alternative and sample size. Power is 1−β1-\beta. These are repeated-sampling properties of a procedure, not posterior probabilities attached to this experiment’s hypothesis.

For a two-sided alternative under this symmetric fair-win null, an exact absolute-deviation statistic gives:

ptwo=PH0(∣X−n/2∣≥∣x−n/2∣).p_{\mathrm{two}}=P_{H_0}(|X-n/2|\ge|x-n/2|).

Ten wins then gives 158/4096≈0.03857158/4096\approx0.03857. Do not choose the one-sided direction after seeing which method wins. Other discrete null models and definitions of two-sided extremeness can yield different conventions; “double a tail” is not a universal recipe.

Enumerate the rejection probability

This complete program uses exact rational arithmetic for the small fair-win test. It checks both tails and enumerates the procedure’s actual false-positive probability rather than assuming it equals 0.05. It also calculates power when A’s true win probability is 0.75.

from math import comb
from fractions import Fraction

def fair_tail(n, wins, two_sided=False):
    if type(n) is not int or type(wins) is not int or n < 1 or not 0 <= wins <= n:
        raise ValueError("positive integer trial count and valid wins required")
    selected = [k for k in range(n+1)
                if (abs(2*k-n) >= abs(2*wins-n) if two_sided else k >= wins)]
    return sum((Fraction(comb(n,k),2**n) for k in selected),Fraction(0))

assert fair_tail(12,10) == Fraction(79,4096)
assert fair_tail(12,9) == Fraction(299,4096)
assert fair_tail(12,10,True) == Fraction(158,4096)
assert fair_tail(12,6,True) == 1
assert fair_tail(12,0) == 1
rejection = [k for k in range(13) if fair_tail(12,k) <= Fraction(1,20)]
assert rejection == [10,11,12]
false_positive = sum(Fraction(comb(12,k),2**12) for k in rejection)
assert false_positive == Fraction(79,4096) < Fraction(1,20)
q = Fraction(3,4)
power = sum(comb(12,k)*q**k*(1-q)**(12-k) for k in rejection)
assert Fraction(39,100) < power < Fraction(40,100)
try:
    fair_tail(12,13)
except ValueError:
    pass
else:
    raise AssertionError("impossible win count accepted")

Computing one tail takes O(n)O(n) binomial terms, ignoring the increasing cost of large-integer arithmetic. Enumerating every possible observation with repeated tail calculations takes O(n2)O(n^2) terms here. This is a transparent small-sample implementation; production statistical libraries use more efficient and numerically appropriate distribution functions for large samples.

A small p-value does not measure the size of an improvement

The observed win fraction is 10/12≈0.83310/12\approx0.833, an effect estimate for this particular win-based outcome. It ignores the magnitude of wins and losses. A method can win slightly in many trials and fail severely in a few. Report the relevant effect size, uncertainty, trial count, and data-generating conditions alongside the p-value. The ASA’s 2016 statement explicitly distinguishes significance from effect size and rejects interpreting p-values as probabilities that hypotheses are true. ASA statement release, principles 2 and 5

Failing to reject is not proof of equality. A small study can have low power against improvements that matter. Conversely, a large study can detect effects too small to justify a deployment change. Equivalence and noninferiority questions require their own margins and procedures.

Trying many metrics or repeatedly checking results until significance appears changes the error rate unless the procedure accounts for it. Across mm independent level-0.05 tests whose null rejection probabilities are exactly 0.05, the chance of at least one false rejection is 1−0.95m1-0.95^m. The assumptions in that illustration matter; dependence and discrete tests change the calculation. Correction, preregistration, or sequential methods must match the actual analysis.

Translate the result without reversing the conditional

  1. Does p=0.01929p=0.01929 mean a 1.929% probability that the null is true? Answer: no. It is a tail probability assuming the null model.
  2. Does nine wins reject at the specified one-sided 0.05 rule? Answer: no; its p-value is about 0.073.
  3. Why is the false-positive rate below 0.05 here? Answer: only certain discrete tail probabilities are attainable, and the chosen cutoff is conservative.
  4. What must be reconsidered if all twelve trials share a strong common disturbance? Answer: independence and the binomial sampling model; twelve recorded outcomes may not supply twelve independent pieces of evidence.

Inference should serve the scientific question

Tests, confidence intervals, Bayesian analyses, and decision models answer related but different questions. Choose an estimand and sampling design first, then a method whose assumptions are defensible. Statistical significance alone does not establish reproducibility, a causal mechanism, practical usefulness, or immunity to selection bias.

Make a prediction, then check

What is the accurate interpretation of p=0.01929?

Choose one answer

Learning objectives

  • Calculate exact binomial p-values, rejection regions, and actual Type I error rates.
  • Distinguish one-sided/two-sided tests, power, effect size, and posterior hypothesis probabilities.

Prerequisites & connections

Explore related knowledge →

References

  1. NIST/SEMATECH e-Handbook — What are statistical tests?
    NIST and SEMATECH
  2. ASA release: Statement on Statistical Significance and P-Values
    American Statistical Association · 2016

Version1 · Editorial status: Recorded technical checks completed

View technical check record (AI)

Codex · 2026-09-05 · Codex technical check: cited-source comparison, re-derivation and recalculation, bilingual argument comparison, and executed Python assertions; no independent human peer review.

  • Enumerated all fair binary sequences for n=1 through 10 and checked both tails at every observation; exactly recalculated 79/4096, 299/4096, and 158/4096 at n=12.
  • Enumerated the rejection region, actual Type I error, and power at win probability 0.75; distinguished p-values, posterior probabilities, effects, and multiple-testing assumptions.
  • Compared bilingual arguments, conditions, examples, and exercise answers; structural checks separately compare formulas, code, sections, and references. No independent human peer review.

Source locations checked:

Related topics

No matches. Try a synonym or acronym.

0 results shown

Wrap the whole query in double quotes for a phrase match.