Inferential Statistics Statistics Data Analysis 28 min read Updated September 13, 2026
BY: Statistics Fundamentals Team
Reviewed By: Minsa A (Senior Statistics Editor)

Hypothesis Testing in Statistics: The Complete Guide to Steps, Types & Examples

Hypothesis testing is a statistical procedure used to decide whether sample data provides enough evidence to reject a claim about a population.

It is the foundation of inferential statistics β€” the tool researchers, data scientists, and analysts use every time they need to separate a real signal from random noise.

This guide covers every element: the logic behind hypothesis testing, the 5-step procedure, p-values and significance levels, every major test type (including Tukey HSD post-hoc), Type I and II errors, statistical power, statistical vs. practical significance, worked examples with Python code, and the relationship between hypothesis tests and confidence intervals.

What Is Hypothesis Testing?

Hypothesis testing is a formal statistical procedure for evaluating whether sample data supports or contradicts a claim about a population. You start with a specific claim β€” the null hypothesis β€” and use probability to decide whether the data is consistent with that claim or whether the evidence against it is strong enough to reject it.

Think of it like a trial. The null hypothesis is the presumption of innocence: the defendant is innocent until the evidence proves otherwise beyond a reasonable doubt. In hypothesis testing, "beyond a reasonable doubt" is defined by a probability threshold called the significance level.

πŸ’‘
The Core Question

Every hypothesis test answers the same question: "If the null hypothesis were true, how likely is it that we would observe data at least this extreme?" The p-value gives that probability. The reference distribution β€” the probability distribution of the test statistic under Hβ‚€ β€” is what makes this calculation possible.

πŸ”‘ Key Takeaways

The most important ideas every student and analyst should understand before running a hypothesis test.

●

The null hypothesis is always what you test. You never directly test the alternative hypothesis β€” you test whether the null is consistent with your data.

●

You never "accept" the null hypothesis. You either reject it or "fail to reject" it β€” absence of evidence is not evidence of absence.

●

Statistical significance is not practical significance. A result can be statistically significant with a tiny, meaningless effect size when the sample is very large. Always report effect size alongside the p-value.

●

Set Ξ± before collecting data. Choosing the significance level after seeing the results β€” "p-hacking" β€” inflates false positive rates.

●

The test statistic quantifies the gap between observed and expected. The larger it is, the less likely the data fits the null hypothesis.

●

Choosing the wrong test type invalidates results. The choice between z, t, chi-square, and ANOVA depends on data type, sample size, and number of groups.

Null and Alternative Hypotheses

Every hypothesis test begins with two competing statements about a population parameter.

The Null Hypothesis (Hβ‚€)

The null hypothesis is the default claim β€” it asserts that there is no effect, no difference, or no relationship in the population. It is the statement you are testing. Common formulations:

  • Hβ‚€: ΞΌ = ΞΌβ‚€ (the population mean equals a specific value)
  • Hβ‚€: μ₁ = ΞΌβ‚‚ (two group means are equal)
  • Hβ‚€: p = pβ‚€ (a proportion equals a specific value)
  • Hβ‚€: variables X and Y are independent
⚠️
Critical wording distinction

Say "fail to reject Hβ‚€," never "accept Hβ‚€." When a test finds no significant result, it means the data didn't provide enough evidence to rule out the null β€” not that the null is proven true. The difference matters in research and in exams.

The Alternative Hypothesis (H₁ or Hₐ)

The alternative hypothesis is the research claim β€” the effect or difference you expect to find. It is what you gather evidence for. It must be the logical complement of Hβ‚€, and it can be directional or non-directional:

β¬…οΈβž‘οΈ

Two-tailed

H₁: ΞΌ β‰  ΞΌβ‚€
Tests for any difference, in either direction. Use this as your default unless you have a strong directional prediction made before data collection.

➑️

Right-tailed

H₁: ΞΌ > ΞΌβ‚€
Tests specifically for an increase above the null value.

⬅️

Left-tailed

H₁: ΞΌ < ΞΌβ‚€
Tests specifically for a decrease below the null value.

πŸ“
One-tailed vs. two-tailed: the practical difference

A two-tailed test at Ξ± = 0.05 splits the rejection region between both tails (2.5% each), requiring a critical z of Β±1.96. A one-tailed test concentrates all 5% in one tail, requiring only z = 1.645. One-tailed tests are more powerful in the predicted direction but give no protection against an effect in the opposite direction β€” which is why two-tailed tests are the standard default.

β†’ Deep dive: Null and Alternative Hypotheses β†’ Deep dive: One- vs. Two-Tailed Tests

Real-World Example

Testing a New Blood Pressure Drug

A pharmaceutical company wants to know whether a new drug reduces systolic blood pressure compared to a placebo. The hypotheses are:

Hβ‚€: The drug has no effect on blood pressure (ΞΌdrug = ΞΌplacebo)
H₁: The drug reduces blood pressure (ΞΌdrug < ΞΌplacebo) β€” left-tailed

A two-sample t-test is run. If p < 0.05, the evidence is strong enough to reject Hβ‚€ and conclude the drug has a statistically significant effect.

The 5 Steps of Hypothesis Testing

Every hypothesis test β€” regardless of the test statistic used β€” follows the same five-step procedure. The arithmetic changes; the logic does not.

1

State the null and alternative hypotheses

Write Hβ‚€ (the claim to be tested, containing equality) and H₁ (the research claim, specifying direction if appropriate). Both must be stated before looking at any data.

2

Choose the significance level (Ξ±)

Set Ξ± before data collection β€” typically 0.05 for most research, 0.01 for medical or safety-critical decisions. This is the maximum tolerable probability of a false positive (Type I error).

3

Select the appropriate test and compute the test statistic

Choose the test based on data type, number of groups, and whether population parameters are known (see Types of Tests below). Calculate the test statistic (z, t, F, or χ²) from your sample data using the relevant formula.

4

Find the p-value or compare to the critical value

P-value approach: Calculate the probability of observing a test statistic at least as extreme as yours, assuming Hβ‚€ is true. If p ≀ Ξ±, reject Hβ‚€.
Critical value approach: Find the boundary value at Ξ± from statistical tables. If your test statistic exceeds it, reject Hβ‚€.

5

Draw a conclusion in context β€” and report effect size

State whether you reject or fail to reject Hβ‚€, then translate that decision into a plain-language conclusion about the original research question. Report the test statistic, degrees of freedom, p-value, and an effect size measure (Cohen's d, Ξ·Β², or r) in your write-up.

The P-value Explained

The p-value is the probability of obtaining a test statistic at least as extreme as the one calculated from your sample, assuming the null hypothesis is true. It is the most widely reported measure of evidence against Hβ‚€.

The P-value Formula

The p-value is derived from the reference distribution β€” the probability distribution of the test statistic under Hβ‚€. For each test type:

P-value formulas by test type Two-tailed z-test: p = 2 Γ— P(Z > |z|) where Z ~ N(0,1) One-tailed (right): p = P(Z > z) One-tailed (left): p = P(Z < z) Two-tailed t-test: p = 2 Γ— P(T > |t|) with df = n βˆ’ 1 Chi-square: p = P(χ² > χ²_observed) with df = (rβˆ’1)(cβˆ’1) F-test (ANOVA): p = P(F > F_observed) with df₁, dfβ‚‚
Python: calculating p-values with scipy.stats from scipy import stats # Two-tailed z-test p-value z = 1.848 p_z = 2 * (1 - stats.norm.cdf(abs(z))) # β†’ 0.0647 # Two-tailed t-test p-value t, df = 1.848, 24 p_t = stats.t.sf(abs(t), df) * 2 # β†’ 0.077 # Chi-square p-value chi2_stat, df_chi = 12.0, 1 p_chi = 1 - stats.chi2.cdf(chi2_stat, df_chi) # β†’ 0.0005

How to Interpret the P-value

P-value Evidence Against Hβ‚€ Decision at Ξ± = 0.05
p > 0.10Weak or noneFail to reject Hβ‚€
0.05 < p ≀ 0.10Marginal / suggestiveFail to reject Hβ‚€
0.01 < p ≀ 0.05ModerateReject Hβ‚€
0.001 < p ≀ 0.01StrongReject Hβ‚€
p ≀ 0.001Very strongReject Hβ‚€
⚠️
What the p-value does NOT mean

The p-value is not the probability that Hβ‚€ is true. It is not the probability that the result was due to chance. And p < 0.05 does not prove that your hypothesis is correct β€” it only means the data is unlikely under the null. Effect size and confidence intervals carry equally important information.

Significance Level (Ξ±) vs P-value

The significance level Ξ± is chosen before the test. The p-value is calculated after the test. The decision rule is simple: if the p-value falls at or below Ξ±, reject Hβ‚€. If not, fail to reject it.

0.05
Standard Ξ± in most research disciplines
0.01
Stricter Ξ± used in medical and safety contexts
5 Γ— 10⁻⁷
Ξ± threshold used in particle physics (five-sigma rule)
β†’ Deep dive: P-values in Detail β†’ Deep dive: Significance Level

Test Statistic and Critical Value

The test statistic is a single number calculated from sample data that measures how far the observed result deviates from what Hβ‚€ predicts. The further it falls from the center of the null distribution, the stronger the evidence against Hβ‚€.

General form of a test statistic Test Statistic = (Observed Value βˆ’ Null Value) Γ· Standard Error

The critical value is the threshold the test statistic must exceed to reject Hβ‚€ at the chosen Ξ± level. It is read from a statistical table (z-table, t-table, chi-square table, or F-table) based on Ξ± and the degrees of freedom β€” the number of values in the data that are free to vary once certain constraints are applied.

Test Statistic Distribution Used Common Use Case Key Input
ZStandard normalMean or proportion, large n or known ΟƒPopulation Οƒ known
tt-distributionMean, small n or unknown ΟƒDegrees of freedom = n βˆ’ 1
χ² (chi-square)Chi-square distributionCategorical data, goodness-of-fit, independencedf = (rowsβˆ’1)(colsβˆ’1)
FF-distributionComparing 3+ group means (ANOVA), variancesdf between and within groups

For one- and two-tailed z-tests, the most commonly referenced critical values at Ξ± = 0.05 are Β±1.96 (two-tailed) and 1.645 (one-tailed right) or βˆ’1.645 (one-tailed left). See the Z-table and T-distribution table for full critical value reference.

β†’ Deep dive: Degrees of Freedom β†’ Deep dive: Decision Rule

Types of Hypothesis Tests

Choosing the right test is as important as running it correctly. The decision depends on: how many groups you are comparing, the data type (continuous vs. categorical), whether the population variance is known, and whether the samples are independent.

Z-test

Used to test a population mean or proportion when the population standard deviation (Οƒ) is known, or when the sample size is large enough (n β‰₯ 30) for the central limit theorem to apply.

Z-test for a mean z = (xΜ„ βˆ’ ΞΌβ‚€) Γ· (Οƒ Γ· √n)
β†’ Deep dive: One-Sample Z-test β†’ Z-test vs. T-test

T-test

The most common test for comparing means. Used when the population standard deviation is unknown and estimated from the sample. Three main forms:

One-sample t-test

When to use

Comparing a single sample mean to a known or hypothesized population value. Example: does the average delivery time differ from the advertised 5 days?

Two-sample (independent) t-test

When to use

Comparing means from two separate, independent groups. Example: do men and women differ in average resting heart rate?

Paired t-test

When to use

Comparing means from matched pairs or the same subjects measured twice. Example: does a training program improve test scores (before vs. after)?

One-sample t-test statistic t = (xΜ„ βˆ’ ΞΌβ‚€) Γ· (s Γ· √n) df = n βˆ’ 1
β†’ One-sample vs. two-sample t-test β†’ Equal vs. unequal variance

Chi-Square Test

Used for categorical data. Two main applications: the goodness-of-fit test (does an observed frequency distribution match an expected one?) and the test of independence (are two categorical variables related?).

Chi-square test statistic χ² = Ξ£ [(Observed βˆ’ Expected)Β² Γ· Expected] df = (rows βˆ’ 1)(cols βˆ’ 1)

The null hypothesis for a chi-square test of independence states that the two variables are not related. The null hypothesis for a goodness-of-fit test states that the observed frequencies match the expected distribution. Reference the chi-square table for critical values.

β†’ Deep dive: Chi-Square Test

ANOVA (Analysis of Variance)

ANOVA tests whether three or more group means differ, using the F-statistic. It partitions total variance into between-group variance and within-group variance. A significant F-statistic tells you that at least one group differs β€” but it does not tell you which pairs differ. That requires a post-hoc test.

F-statistic for one-way ANOVA F = Mean Square Between (MSB) Γ· Mean Square Within (MSW) MSB = SS_between Γ· df_between df_between = k βˆ’ 1 MSW = SS_within Γ· df_within df_within = N βˆ’ k

The null hypothesis for ANOVA is Hβ‚€: μ₁ = ΞΌβ‚‚ = ... = ΞΌβ‚– (all group means are equal). See the F-table and the F-distribution guide for critical values.

Tukey's HSD Post-Hoc Test

πŸ” When ANOVA is significant β€” which groups actually differ?

A significant ANOVA result only confirms that at least one group mean is different. To identify which specific pairs of groups differ while controlling the family-wise error rate, run a post-hoc test. Tukey's Honestly Significant Difference (HSD) is the most widely used choice when group sizes are equal or approximately equal.

Tukey's HSD formula HSD = q Γ— √(MSW Γ· n) where: q = studentized range statistic (from Tukey's q-table, df_within, k groups) MSW = mean square within (from the ANOVA table) n = sample size per group

Two group means are significantly different if their absolute difference exceeds the HSD value. Tukey's test is more powerful than Bonferroni when you need all pairwise comparisons, and more conservative than Fisher's LSD to guard against inflated false positives.

Example: An ANOVA comparing test scores across three teaching methods (A, B, C) yields F(2, 27) = 5.4, p = 0.011. Tukey HSD reveals Method A vs. C is significant (p = 0.009) while A vs. B and B vs. C are not β€” the significant F was driven entirely by the A–C gap.

β†’ Deep dive: Tukey HSD Test (with worked example and q-table) β†’ Deep dive: ANOVA

Proportion Test (Z-test for Proportions)

Tests whether a sample proportion differs from a hypothesized value, or whether two sample proportions differ from each other. Based on the normal approximation to the binomial, valid when np β‰₯ 5 and n(1βˆ’p) β‰₯ 5.

Z-test for one proportion z = (pΜ‚ βˆ’ pβ‚€) Γ· √[pβ‚€(1 βˆ’ pβ‚€) Γ· n]
β†’ Deep dive: Proportion Hypothesis Testing

Which Test Should You Use?

Scenario Data Type Groups Use This Test
Compare one mean to a value, Οƒ known or n β‰₯ 30Continuous1Z-test
Compare one mean to a value, Οƒ unknownContinuous1One-sample t-test
Compare two independent group meansContinuous2Two-sample t-test
Compare before/after or matched pairsContinuous2 (matched)Paired t-test
Compare 3+ group meansContinuous3+One-way ANOVA
Identify which pairs differ after significant ANOVAContinuous3+Tukey's HSD (post-hoc)
Test association between two categorical variablesCategoricalβ€”Chi-square independence test
Test whether frequencies match a distributionCategoricalβ€”Chi-square goodness-of-fit
Compare one proportion to a valueProportion1One-sample z-test for proportions
Compare two proportionsProportion2Two-sample z-test for proportions
β†’ Interactive: Statistical Test Selector

Type I and Type II Errors

Because hypothesis tests use probability, they can lead to two kinds of incorrect conclusions. Understanding these errors β€” and what controls them β€” is central to interpreting statistical results correctly.

A quick way to keep them straight: Type I is a false alarm (you cried wolf when there was none). Type II is a missed signal (the wolf came but you didn't notice).

Type I Error (False Positive)

Rejecting Hβ‚€ when Hβ‚€ is actually true. You conclude there is an effect, but in reality there isn't one.

Probability: Equal to the significance level Ξ±.

Example: Concluding a drug works when the improvement was due to chance.

Controlled by setting Ξ± before the test

Type II Error (False Negative)

Failing to reject Hβ‚€ when Hβ‚€ is actually false. You miss a real effect because the evidence wasn't strong enough to detect it.

Probability: Called Ξ². Reduced by increasing sample size and effect size.

Example: Concluding a drug doesn't work when it actually does β€” the study was just underpowered.

Controlled by increasing statistical power (1 βˆ’ Ξ²)
Decision \ Reality Hβ‚€ is True Hβ‚€ is False
Reject Hβ‚€ Type I Error (Ξ±) Correct (Power = 1 βˆ’ Ξ²)
Fail to reject Hβ‚€ Correct (1 βˆ’ Ξ±) Type II Error (Ξ²)
βš–οΈ
The Error Trade-off

Reducing Ξ± (making it harder to reject Hβ‚€) decreases Type I errors but increases Type II errors, because a stricter threshold makes it harder to detect real effects. The two error types are inversely related at a fixed sample size. The solution is to increase sample size β€” this reduces both errors simultaneously.

β†’ Deep dive: Type I and Type II Errors

Statistical Power of a Hypothesis Test

Statistical power is the probability that a test correctly rejects a false null hypothesis. It equals 1 βˆ’ Ξ². A power of 0.80 means an 80% chance of detecting a real effect when one exists β€” the conventional minimum in behavioral and social research.

Statistical power formula Power = 1 βˆ’ Ξ² = P(Reject Hβ‚€ | Hβ‚€ is false) For a one-sample z-test: Power = P(Z > z_crit βˆ’ Ξ΄) + P(Z < βˆ’z_crit βˆ’ Ξ΄) [two-tailed] where Ξ΄ = (μ₁ βˆ’ ΞΌβ‚€) Γ· (Οƒ Γ· √n) is the non-centrality parameter

Power must be calculated before data collection, not after. Running a study without a power calculation risks wasting resources on a test too weak to detect the effect of interest. A "non-significant" result in an underpowered study cannot be interpreted as evidence of no effect.

πŸ“

Sample size

The single most controllable driver of power. Doubling n substantially increases power. Calculate the minimum n required before starting.

πŸ“

Effect size

Larger true differences are easier to detect. Small effects require much larger samples. Use Cohen's d for means, r for correlations, and Cohen's w for chi-square tests.

🎯

Significance level (Ξ±)

A higher Ξ± (e.g., 0.10 vs. 0.05) increases power but also raises the false positive rate. This tradeoff must be justified by the context.

πŸ“Š

Variability

Less variability in the outcome makes it easier to detect true effects. Tighter measurement instruments and standardized conditions improve power.

0.80
Conventional minimum power threshold in most research fields
>50%
Type II error rate in many underpowered clinical trials
4Γ—
Approximate increase in n needed to halve the effect size detectable
β†’ Deep dive: Power of a Test β†’ Sample Size Calculator

Statistical Significance vs. Practical Significance

A statistically significant result only means the observed effect is unlikely to have arisen by chance. It says nothing about whether the effect is large enough to matter. With a sufficiently large sample, even a trivially small difference will yield p < 0.05.

Statistical Significance

Determined by the p-value relative to Ξ±. A result is statistically significant if p ≀ Ξ± β€” meaning the data is unlikely under Hβ‚€.

Driven by: Sample size, effect size, variability, and Ξ± level.

Can be misleading when: n is very large β€” even a 0.3-point difference on a 100-point scale becomes "significant."

Practical Significance

Determined by effect size β€” the magnitude of the difference in real-world units. An effect can be statistically significant but practically irrelevant.

Measured by: Cohen's d (means), Ξ·Β² (ANOVA), r (correlations), odds ratio (proportions).

Cohen's d benchmarks: Small β‰ˆ 0.2, Medium β‰ˆ 0.5, Large β‰ˆ 0.8.

Illustrative Example

When statistical significance misleads

A study of 50,000 employees finds that workers who drink coffee score 0.4 points higher on a 100-point productivity scale than those who don't (p < 0.0001). The result is highly statistically significant, but Cohen's d = 0.04 β€” a negligible effect. No manager should restructure the office coffee policy on this basis. Always ask: even if this is real, is it large enough to act on?

βœ…
Best Practice

Report the test result (p-value, test statistic, df), the effect size (Cohen's d, Ξ·Β², or r), and the confidence interval. Together these tell readers whether an effect was detected, how large it is, and how precisely it has been estimated β€” far more informative than a p-value alone.

β†’ Deep dive: Effect Size β†’ Deep dive: Cohen's d

Confidence Intervals and Hypothesis Testing

Hypothesis tests and confidence intervals are two sides of the same coin β€” they draw on the same mathematical framework and reach equivalent conclusions.

A 95% confidence interval gives the range of population parameter values consistent with your sample at Ξ± = 0.05. The hypothesis test at Ξ± = 0.05 asks whether the null value falls inside that range:

  • If the null hypothesis value falls outside the 95% CI β†’ the two-tailed test rejects Hβ‚€ at Ξ± = 0.05.
  • If the null hypothesis value falls inside the 95% CI β†’ the test fails to reject Hβ‚€ at Ξ± = 0.05.
Feature Hypothesis Test Confidence Interval
OutputBinary: reject or fail to reject Hβ‚€Range of plausible parameter values
Information providedWhether an effect existsDirection and magnitude of the effect
Linked to Ξ±Directly β€” Ξ± sets the decision boundaryConfidence level = 1 βˆ’ Ξ± (e.g., 95% CI for Ξ± = 0.05)
Preferred whenSimple yes/no decision neededEffect size and precision are important
Equivalent?Yes β€” at Ξ± = 0.05, a two-tailed test and 95% CI always agree on the reject/fail-to-reject decision
β†’ Deep dive: Confidence Intervals

Hypothesis Testing: Worked Examples

Example 1: One-Sample T-test

Worked Example

Do students score differently from the national average?

A school reports that the national average on a standardized exam is 75 points. A sample of 25 students from one school scored a mean of 78.4 with a standard deviation of 9.2. Test at Ξ± = 0.05 whether this school's students perform differently from the national average.

1

State hypotheses: Hβ‚€: ΞΌ = 75 (school mean equals national average)  |  H₁: ΞΌ β‰  75 (two-tailed, because "differently" means either direction)

2

Significance level: Ξ± = 0.05. Two-tailed test β†’ each tail = 0.025.

3

Calculate t: t = (78.4 βˆ’ 75) Γ· (9.2 Γ· √25) = 3.4 Γ· 1.84 = 1.848. Degrees of freedom = 25 βˆ’ 1 = 24.

4

Critical value: From the t-distribution table at df = 24 and Ξ±/2 = 0.025, the critical value is Β±2.064. Since |1.848| < 2.064, the test statistic does not fall in the rejection region. The p-value β‰ˆ 0.077.

5

Decision: p = 0.077 > Ξ± = 0.05. Fail to reject Hβ‚€. Effect size: Cohen's d = (78.4 βˆ’ 75) Γ· 9.2 = 0.37 (small-to-medium).

At the 5% significance level, there is not enough evidence to conclude that students at this school perform differently from the national average (t(24) = 1.848, p = 0.077, d = 0.37). Note: the effect size is not negligible β€” a larger sample might detect a real difference.

Python implementation from scipy import stats import numpy as np sample_mean = 78.4 pop_mean = 75 std_dev = 9.2 n = 25 t_stat = (sample_mean - pop_mean) / (std_dev / np.sqrt(n)) p_val = stats.t.sf(abs(t_stat), df=n-1) * 2 # two-tailed cohens_d = (sample_mean - pop_mean) / std_dev print(f"t = {t_stat:.3f}, p = {p_val:.3f}, d = {cohens_d:.2f}") # β†’ t = 1.848, p = 0.077, d = 0.37 (fail to reject Hβ‚€)

Example 2: Chi-Square Test of Independence

Worked Example

Is there an association between exercise frequency and sleep quality?

A survey of 200 adults cross-tabulates exercise frequency (regular / irregular) against reported sleep quality (good / poor). The observed counts are: regular/good = 72, regular/poor = 28, irregular/good = 48, irregular/poor = 52. Test at Ξ± = 0.05 whether exercise and sleep quality are independent.

1

State hypotheses: Hβ‚€: Exercise frequency and sleep quality are independent. H₁: They are not independent.

2

Significance level: Ξ± = 0.05. df = (2βˆ’1)(2βˆ’1) = 1. Critical value from the chi-square table = 3.841.

3

Calculate expected frequencies: Row totals: regular = 100, irregular = 100. Column totals: good = 120, poor = 80. Expected: reg/good = 60, reg/poor = 40, irreg/good = 60, irreg/poor = 40.

4

Calculate χ²: = (72βˆ’60)Β²/60 + (28βˆ’40)Β²/40 + (48βˆ’60)Β²/60 + (52βˆ’40)Β²/40 = 2.4 + 3.6 + 2.4 + 3.6 = 12.0. p-value < 0.001.

5

Decision: χ² = 12.0 > critical value 3.841, and p < 0.001 < Ξ±. Reject Hβ‚€. Effect size (CramΓ©r's V) = √(12.0 / 200) = 0.245 (small-to-medium).

There is statistically significant evidence that exercise frequency and sleep quality are associated (χ²(1) = 12.0, p < 0.001, V = 0.245). Regular exercisers reported better sleep more often than would be expected by chance. This is an association, not causation.

Python implementation from scipy.stats import chi2_contingency import numpy as np observed = np.array([[72, 28], [48, 52]]) chi2, p, dof, expected = chi2_contingency(observed) cramers_v = np.sqrt(chi2 / (observed.sum() * (min(observed.shape)-1))) print(f"chi2 = {chi2:.1f}, df = {dof}, p = {p:.4f}, V = {cramers_v:.3f}") # β†’ chi2 = 12.0, df = 1, p = 0.0005, V = 0.245

Example 3: Z-test for Proportions

Worked Example

Did a new website design improve the conversion rate?

A company's old website had a 12% conversion rate. After redesigning the site, 84 out of 600 visitors converted (14%). Test at Ξ± = 0.05 whether the new design has a higher conversion rate than the old one.

1

State hypotheses: Hβ‚€: p = 0.12 (conversion rate is unchanged). H₁: p > 0.12 (conversion rate increased) β€” right-tailed test.

2

Significance level: Ξ± = 0.05. Critical z = 1.645 (right-tailed).

3

Calculate z: pΜ‚ = 84/600 = 0.14. z = (0.14 βˆ’ 0.12) Γ· √[0.12 Γ— 0.88 Γ· 600] = 0.02 Γ· 0.01321 = 1.514.

4

Compare: z = 1.514 < 1.645. p-value β‰ˆ 0.065.

5

Decision: p = 0.065 > Ξ± = 0.05. Fail to reject Hβ‚€.

At the 5% level, the data does not provide sufficient evidence to conclude that the new design increased the conversion rate (z = 1.514, p = 0.065). The observed 2-percentage-point gain is not statistically significant at this sample size. A power calculation suggests approximately 900 visitors per variant would be needed to detect a 2pp lift with 80% power.

Python implementation from statsmodels.stats.proportion import proportions_ztest import numpy as np conversions = 84 n = 600 p0 = 0.12 z_stat, p_val = proportions_ztest(conversions, n, value=p0, alternative='larger') print(f"z = {z_stat:.3f}, p = {p_val:.3f}") # β†’ z = 1.514, p = 0.065 (fail to reject Hβ‚€)
β†’ More worked examples: Hypothesis Testing Examples & Solutions

Advanced Topics in Hypothesis Testing

Multiple Hypothesis Testing

When you run many tests simultaneously β€” for example, comparing 10 biomarkers across two groups β€” the probability of at least one false positive increases rapidly. With 20 independent tests at Ξ± = 0.05, you expect at least one false positive by chance alone.

The Bonferroni correction addresses this by dividing Ξ± by the number of tests. If you run k tests, use Ξ±* = Ξ±/k as the threshold for each individual test.

Bonferroni correction Adjusted significance level: Ξ±* = Ξ± Γ· k Example: 5 simultaneous tests at Ξ± = 0.05 Ξ±* = 0.05 Γ· 5 = 0.01 β†’ each test must reach p ≀ 0.01 to be declared significant

The Bonferroni correction is conservative. More powerful alternatives include the Benjamini-Hochberg procedure, which controls the false discovery rate (the expected proportion of false positives among rejected tests) rather than the family-wise error rate. It is preferred when many simultaneous tests are run β€” for example, in genomics or neuroimaging studies.

β†’ Deep dive: Bonferroni Correction

Bayesian Hypothesis Testing

Classical (frequentist) hypothesis testing answers: "If Hβ‚€ is true, how likely is this data?" Bayesian hypothesis testing answers a different question: "Given this data, how likely is Hβ‚€ relative to H₁?" The Bayes factor is the ratio of these likelihoods.

Bayesian methods require specifying prior beliefs about the parameters, which can be an advantage (they incorporate existing knowledge) or a subject of debate (the prior choice influences conclusions). For routine research, frequentist methods remain standard; Bayesian approaches are particularly useful when prior information is strong or sequential testing is needed.

Hypothesis Testing in Regression Analysis

In linear regression, hypothesis tests evaluate whether individual predictors significantly explain variance in the outcome. The null hypothesis for each coefficient is Hβ‚€: Ξ² = 0 (the predictor has no effect on Y, holding others constant). The t-statistic = coefficient Γ· standard error, compared against a t-distribution. The overall model fit is tested with an F-test (Hβ‚€: all slopes = 0 simultaneously).

Bootstrap Hypothesis Testing

Bootstrap tests make no distributional assumptions. They estimate the null distribution by resampling from the observed data thousands of times and measuring how often the resampled statistic exceeds the observed one. Useful when sample sizes are small or the test statistic does not follow a known distribution.

Limitations of Hypothesis Testing

Hypothesis testing is one of the most widely used tools in statistics, but it has real limitations that every analyst should understand before interpreting results.

Binary decisions oversimplify

Reducing a continuous body of evidence to "reject / fail to reject" discards nuance. A p-value of 0.049 and one of 0.051 represent nearly identical evidence β€” yet one crosses the threshold and one doesn't.

P-hacking inflates false positives

Choosing Ξ± after seeing results, running multiple comparisons without adjustment, or stopping data collection when p crosses 0.05 all inflate the false positive rate well beyond the nominal Ξ± level.

Garbage in, garbage out

Results are only as valid as the data quality. Poor sampling, measurement error, and confounding variables invalidate conclusions regardless of how correctly the test is applied.

Significance β‰  causation

A statistically significant association between X and Y does not mean X causes Y. Establishing causation requires experimental design (randomisation, controls), not just a p-value.

Publication bias

Studies that fail to reject Hβ‚€ are less likely to be published. This "file drawer problem" distorts the literature toward apparent effects that may not replicate.

Assumptions are rarely checked

Every parametric test assumes something β€” normality, equal variances, independence. Violating these assumptions invalidates the p-value. Always check assumptions before interpreting results.

πŸ”¬
The solution is not to abandon hypothesis testing

These limitations point toward better practice: pre-register your hypotheses and Ξ±, report effect sizes and confidence intervals alongside p-values, perform power calculations before data collection, and check test assumptions explicitly. Used carefully, hypothesis testing remains indispensable for making principled decisions from data.

β†’ Statistical Test Assumptions

Hypothesis Testing at a Glance

Concept Definition Key Point
Hβ‚€ (Null hypothesis)The claim of no effect or no differenceAlways contains equality; never "accepted," only failed to reject
H₁ (Alternative)The research claim β€” what you expect to findCan be one-tailed or two-tailed; default is two-tailed
Significance level (Ξ±)Threshold for rejecting Hβ‚€Set before data collection; usually 0.05
Test statisticMeasured deviation from the null valueZ, t, χ², or F depending on test type
P-value formulaProbability of this data (or more extreme) if Hβ‚€ were trueTwo-tailed z: p = 2 Γ— P(Z > |z|)
Type I errorRejecting a true Hβ‚€Probability = Ξ±
Type II errorFailing to reject a false Hβ‚€Probability = Ξ²; reduced by larger n
Statistical powerProbability of detecting a real effectPower = 1 βˆ’ Ξ²; target β‰₯ 0.80
Effect sizeMagnitude of the difference in real-world termsCohen's d, Ξ·Β², r; required alongside p-value
Tukey's HSDPost-hoc test for pairwise comparisons after ANOVAHSD = q Γ— √(MSW/n); controls family-wise error rate

Conclusion

Hypothesis testing gives you a principled, repeatable method for making decisions from data under uncertainty. The procedure is consistent across every test type: state the hypotheses, set Ξ±, calculate the test statistic, find the p-value, and draw a conclusion in context.

Getting it right means more than following the steps. It means choosing the correct test for your data, setting Ξ± before you look at results, running Tukey HSD (or another post-hoc test) when ANOVA is significant, reporting effect sizes alongside p-values, and interpreting "fail to reject" as absence of evidence β€” not as proof the null is true.

Statistical significance and practical significance are different things. A large sample can make a trivial difference statistically significant. Always pair your test result with a confidence interval and a measure of effect size β€” Cohen's d for means, CramΓ©r's V for chi-square, Ξ·Β² for ANOVA. That combination tells readers what they need to know: whether an effect was detected, and how large it might plausibly be.

Read More on Statistics Fundamentals

Null and Alternative Hypotheses

How to write Hβ‚€ and H₁ correctly β€” with examples across every test type and common mistakes to avoid.

Read More β†’

P-values in Detail

What the p-value formula actually computes, common misinterpretations, and how to report p-values in research write-ups.

Read More β†’

Type I and Type II Errors

A complete breakdown of false positives and false negatives β€” with real-world examples and strategies for controlling each error type.

Read More β†’

Tukey's HSD Test

Step-by-step guide to running Tukey's Honestly Significant Difference test after ANOVA β€” with the q-table and a full worked example.

Read More β†’

Effect Size (Cohen's d, Ξ·Β², r)

How to calculate and interpret effect sizes β€” and why they're essential for communicating the real-world importance of your findings.

Read More β†’

Statistical Power of a Test

How to calculate power before a study, choose the right sample size, and interpret non-significant results from underpowered tests.

Read More β†’

Z-table (Standard Normal)

Look up critical values and probabilities for z-tests and two-tailed hypothesis tests at common significance levels.

View Z-table β†’

Hypothesis Testing Examples & Solutions

20+ worked examples across every test type β€” t-test, chi-square, ANOVA, z-test for proportions β€” with step-by-step solutions.

View Examples β†’

FAQs About Hypothesis Testing

Hypothesis testing is a statistical procedure used to decide whether sample data provides enough evidence to reject a claim about a population parameter. You compare observed data to what would be expected if the null hypothesis were true, using the p-value or a critical value to guide the decision.

The p-value is the probability of observing a test statistic at least as extreme as the one calculated from your sample, assuming the null hypothesis is true. It is not the probability that Hβ‚€ is true. A p-value ≀ Ξ± (typically 0.05) leads to rejecting Hβ‚€.

The p-value is calculated from the reference distribution of the test statistic under Hβ‚€. For a two-tailed z-test: p = 2 Γ— P(Z > |z|), where Z follows the standard normal distribution. For a two-tailed t-test: p = 2 Γ— P(T > |t|) with degrees of freedom = n βˆ’ 1. In Python: from scipy import stats; p = stats.t.sf(abs(t), df)*2 for a t-test.

Reject the null hypothesis when the p-value is less than or equal to the pre-set significance level Ξ± (usually 0.05). Equivalently, reject Hβ‚€ when the calculated test statistic exceeds the critical value at the chosen Ξ±. Both approaches give the same decision.

A Type I error (false positive) is rejecting a null hypothesis that is actually true. Its probability equals Ξ±, the significance level. A Type II error (false negative) is failing to reject a null hypothesis that is actually false. Its probability is Ξ². Statistical power = 1 βˆ’ Ξ². Reducing Ξ± increases Ξ², and vice versa, at a fixed sample size.

A two-tailed test checks for a difference in either direction (H₁: ΞΌ β‰  ΞΌβ‚€) and splits Ξ± between both tails of the distribution. A one-tailed test checks only one direction β€” either H₁: ΞΌ > ΞΌβ‚€ (right-tailed) or H₁: ΞΌ < ΞΌβ‚€ (left-tailed) β€” and concentrates all of Ξ± in one tail. Two-tailed tests are the default unless you have a strong directional prediction established before data collection.

Use a z-test when the population standard deviation (Οƒ) is known, or when the sample is large (n β‰₯ 30) and the central limit theorem applies. Use a t-test when Οƒ is unknown and must be estimated from the sample β€” which is the situation in the vast majority of real research. As sample size grows, the t-distribution approaches the normal distribution, so the distinction matters most in small samples.

Statistical power (1 βˆ’ Ξ²) is the probability that a test will detect a real effect when one exists. A power of 0.80 means an 80% chance of a true positive. Underpowered studies β€” those with insufficient sample sizes β€” frequently produce false negatives and waste research resources. Power should be calculated before data collection to determine the minimum sample size required.

Statistical significance (p ≀ Ξ±) means the observed result is unlikely under Hβ‚€. Practical significance means the effect is large enough to matter in the real world. With large samples, even tiny, trivial differences can be statistically significant. Always report an effect size (Cohen's d, Ξ·Β², CramΓ©r's V) alongside the p-value to convey practical importance. A result that is statistically significant but has a negligible effect size may not justify any real-world action.

Tukey's Honestly Significant Difference (HSD) test is a post-hoc test run after a statistically significant one-way ANOVA. It compares all possible pairs of group means to determine which specific groups differ from each other, while controlling the family-wise error rate. The formula is HSD = q Γ— √(MSW / n), where q is the studentized range statistic from the Tukey q-table. Use Tukey's HSD when group sizes are equal or approximately equal and you want to make all pairwise comparisons.

Hypothesis testing produces a binary decision: reject or fail to reject Hβ‚€. A confidence interval gives a range of plausible values for the population parameter, providing information about the magnitude and direction of the effect. The two are mathematically equivalent at the same Ξ± level: if a 95% CI excludes the null value, the two-tailed test at Ξ± = 0.05 will reject Hβ‚€, and vice versa. Reporting both is best practice.