Data Science
Hypothesis Testing in Statistics: Steps, Types and Examples
Learn hypothesis testing in statistics step by step: H0 vs H1, p-values, errors, the right test to pick, 4 Python examples and a free practice pack.

Most students can recite "reject H0 if p is less than 0.05".
Far fewer can say which test to run, what the p-value actually means, or why a "significant" A/B test result can still be wrong.
This guide fixes that. You'll learn hypothesis testing in statistics the way analysts use it at work, with real code and real output.
Inside:
- The 7 steps, with one running example
- The 4-Question Test Picker for choosing the right test
- 4 worked examples in Python (SciPy and statsmodels)
- 4 common mistakes we simulated 5,000 to 10,000 times each
Let's get started.
Hypothesis testing in statistics is a method for deciding whether sample data gives enough evidence to reject a default claim about a population. You state a null hypothesis (no effect), compute a test statistic and p-value from your sample, and reject the null only if the result would be rare were the null true.
Quick answer: hypothesis testing in statistics (December 2026)
- A hypothesis test compares a null hypothesis (H0: no effect or no difference) with an alternative hypothesis (H1) using a test statistic and a p-value.
- The standard steps are: state H0 and H1, pick a significance level (usually α = 0.05), choose the test, check its assumptions, compute the statistic and p-value, decide, and report the effect size.
- The right test depends on four things: the outcome type, the number of groups, whether the samples are paired, and whether a t-test's assumptions hold.
- In our 10,000-run simulation, testing 20 metrics with no real effect produced at least one "significant" result 64.7% of the time; a Bonferroni correction cut that to 5.1%.
- Checking an A/B test every day for 14 days and stopping at the first p below 0.05 raised the false positive rate from 4.9% to 22.0% in our 5,000-run simulation.
What Is Hypothesis Testing in Statistics?
Hypothesis testing in statistics is a decision rule for separating real effects from random noise in sample data. You never see the whole population, so you assume "nothing is happening" and check whether your sample makes that assumption hard to believe.
The idea is old. In his 1925 book Statistical Methods for Research Workers, Ronald Fisher suggested treating a 1-in-20 chance (p = 0.05) as a convenient cut-off for calling a result significant (Fisher, 1925).
Think of a courtroom:
- The null hypothesis (H0) is "the accused is innocent". It is the default.
- The alternative hypothesis (H1) is "the accused is guilty".
- The evidence is your sample. If it is strong enough, you reject H0.
- If it isn't, you "fail to reject" H0. That is not the same as proving innocence.
That last point trips up a lot of interview candidates. A non-significant result means "not enough evidence", not "no effect".
Hypothesis Testing in Statistics: Key Terms You Need First
Every hypothesis test uses the same seven building blocks, whether it's a t-test, a chi-square test or an A/B test on a website.
| Term | Plain meaning | Example (food delivery claim) |
|---|---|---|
| Null hypothesis (H0) | The default "no effect" claim | Average delivery time = 30 minutes |
| Alternative hypothesis (H1) | What you suspect instead | Average delivery time > 30 minutes |
| Significance level (α) | The false alarm rate you accept | 0.05 (5%) |
| Test statistic | How far your sample is from H0, in standard-error units | t = 2.97 |
| P-value | Chance of data this extreme or more if H0 were true | 0.0025 |
| Critical value | The statistic's cut-off at your α | t > 1.68 (one-tailed, df = 39) |
| Confidence interval | Range of plausible values for the true effect | 30.7 to 33.9 minutes |
Two more terms come up later: effect size (how big the difference is, for example Cohen's d) and degrees of freedom (roughly, sample size minus the number of things you estimated).
If the mean and standard deviation feel shaky, revisit our guide to measures of central tendency first.
Hypothesis Testing Steps: The 7-Step Process
The hypothesis testing process has seven steps, and the order matters because steps 1 to 4 must happen before you look at results.
- State H0 and H1.
- Choose the significance level (α).
- Choose the test.
- Decide the sample size and check assumptions.
- Compute the test statistic and p-value.
- Decide: reject H0 if p ≤ α.
- Report the effect size and confidence interval, in plain words.
Here's each step on one running example: a Nagpur cloud kitchen claims its average delivery time is 30 minutes. You suspect it's slower.
Step 1: State the hypotheses. H0 says μ = 30 minutes and H1 says μ > 30 minutes. It is one-tailed, because you only care about "slower".
Step 2: Pick α. Use 0.05 unless a wrong "yes" is expensive. Medicine and new scientific claims often use stricter levels; a 2018 paper by 72 researchers proposed 0.005 for claims of new discoveries (Benjamin et al., Nature Human Behaviour, 2018).
Step 3: Choose the test. One numeric outcome, one group, unknown population standard deviation: a one-sample t-test.
Step 4: Sample size and assumptions. You log 40 orders. Observations should be independent, and the data should roughly follow a normal distribution (or the sample should be large).
Our sample's Shapiro-Wilk p-value was 0.969, so normality looks fine. How you collect those 40 orders matters too; see our guide to types of sampling.
Step 5: Compute. Sample mean 32.33 minutes, standard deviation 4.97, t = 2.97, p = 0.0025.
Step 6: Decide. 0.0025 is below 0.05, so you reject H0.
Step 7: Report. "Deliveries averaged 32.3 minutes (95% CI 30.7 to 33.9), about 2.3 minutes slower than claimed (Cohen's d = 0.47, a medium effect)."
Step 7 is the one most tutorials skip. A manager doesn't care that p = 0.0025. They care that orders arrive about 2 minutes late.

One-Tailed vs Two-Tailed Tests
A one-tailed test checks for a difference in one direction only; a two-tailed test checks both directions. Pick the direction from your question, before you see the data.
| One-tailed | Two-tailed | |
|---|---|---|
| H1 example | μ > 30 | μ ≠ 30 |
| Use when | Only one direction matters for the decision | Any change matters (A/B tests, most research) |
| Critical z at α = 0.05 | 1.645 | ±1.96 |
| Risk | Blind to an effect in the other direction | Needs a slightly larger effect to reach significance |
Important: Never switch from two-tailed to one-tailed after seeing the data because it "halves the p-value". That is a quiet form of p-hacking.

In SciPy, the alternative argument controls this: "two-sided" (the default), "less" or "greater" (SciPy ttest_ind docs).
Type 1 and Type 2 Errors (and Statistical Power)
Every hypothesis test can be wrong in two ways: a Type I error rejects a true null (false alarm), and a Type II error misses a real effect.
| H0 is actually true | H0 is actually false | |
|---|---|---|
| You reject H0 | Type I error (false positive), probability α | Correct: you found the effect (power = 1 − β) |
| You fail to reject H0 | Correct | Type II error (false negative), probability β |
α is a long-run rate, and you can see it in action. We ran 10,000 A/A tests in Python: two groups of 50 drawn from the same population, so no real difference existed. 4.59% came out "significant" at α = 0.05, close to the promised 5%.
Statistical power is the chance your test detects an effect that really exists. Most teams aim for 80%.
Power depends on three things: sample size, effect size and α. Here's what that means in practice:
- To detect a lift from a 4% to a 5% enquiry rate with 80% power (α = 0.05, two-tailed), you need about 6,726 visitors per version.
- With only 1,200 visitors per version, the same test has just 22% power. It misses a real 1-point lift almost 4 times out of 5.
(Calculated with statsmodels NormalIndPower, December 2026.)
This is why "we ran the test for a week and saw nothing" often means "we never had enough data to see anything".

Types of Hypothesis Testing in Statistics: The 4-Question Test Picker
The type of hypothesis test you need depends on your data, not on which test you learned most recently. We call our shortcut the 4-Question Test Picker: answer four questions in order and the test falls out.
- What is the outcome? A number (marks, minutes, revenue) or a category (enquired yes/no, chosen course)?
- How many groups are you comparing? One (against a claimed value), two, or three or more?
- Are the samples paired? The same people measured twice, or matched pairs?
- Do the t-test assumptions hold? Roughly normal data or a large sample, and no extreme outliers? If not, use the non-parametric version.
| Outcome | Groups | Paired? | Assumptions OK | Use this test | If assumptions fail |
|---|---|---|---|---|---|
| Number | 1 vs claimed value | n/a | Yes | One-sample t-test | Wilcoxon signed-rank |
| Number | 2 | No | Yes | Welch's t-test | Mann-Whitney U |
| Number | 2 | Yes | Yes | Paired t-test | Wilcoxon signed-rank |
| Number | 3 or more | No | Yes | One-way ANOVA | Kruskal-Wallis |
| Category (proportion) | 1 or 2, large n | No | Yes | z-test for proportions | Fisher's exact test |
| Category vs category | Any | No | Expected counts ≥ 5 | Chi-square test of independence | Fisher's exact test |
| Number vs number | n/a | n/a | Linear relationship | Correlation or regression t-test | Spearman correlation |
A z-test for means needs a known population standard deviation, which you almost never have in real data. That's why the t-test is the everyday workhorse.
Our separate guides go deeper on hypothesis testing using the z-test, hypothesis testing using the t-test and chi-square and ANOVA tests.
Pro tip: Default to Welch's t-test (
equal_var=Falsein SciPy) for two independent groups. It doesn't assume equal variances, and when variances are equal it gives almost the same answer.

Hypothesis Testing Examples in Python
The four hypothesis testing examples below use simulated practice datasets with Indian business contexts, so you can rerun every number yourself. We ran them on 3 December 2026 with Python 3.13, SciPy 1.18.1 and statsmodels 0.15.0.
Resource: Download the free Fireblaze Hypothesis Testing Practice Pack (4 CSV files, the solutions script and the simulation code): Download the practice pack (ZIP)
Example 1: One-Sample t-Test (Is Delivery Slower Than Claimed?)
The cloud kitchen from the 7 steps above, in code:
import pandas as pd
from scipy import stats
t = pd.read_csv("delivery_times.csv")["delivery_minutes"]
res = stats.ttest_1samp(t, popmean=30, alternative="greater")
print(f"mean={t.mean():.2f}, t={res.statistic:.3f}, p={res.pvalue:.4f}")
Output:
mean=32.33, t=2.969, p=0.0025
Conclusion: reject H0. Deliveries are slower than 30 minutes on average, by about 2.3 minutes.
Example 2: A/B Test With a Two-Proportion z-Test
An institute tests two landing pages for 1,200 visitors each: version A has an enquiry form, version B a WhatsApp button. A got 41 enquiries (3.42%), B got 65 (5.42%).
H0: both versions convert at the same rate. H1: they differ (two-tailed).
from statsmodels.stats.proportion import proportions_ztest, confint_proportions_2indep
z, p = proportions_ztest([65, 41], [1200, 1200])
lo, hi = confint_proportions_2indep(65, 1200, 41, 1200, method="wald")
print(f"z={z:.3f}, p={p:.4f}, CI: {lo*100:.2f} to {hi*100:.2f} points")
Output:
z=2.384, p=0.0171, CI: 0.36 to 3.64 points
Conclusion: reject H0 at 0.05. B's lift is somewhere between 0.4 and 3.6 percentage points, a wide range.
That width is the warning sign. Our power check says 1,200 visitors per version gives only about 45% power even for the true lift we built into this data (4.0% to 5.6%), so results this size are fragile. Before shipping, confirm with a larger, pre-planned sample.

Example 3: Chi-Square Test of Independence
A counsellor logs 300 enquiries: each student's academic background and the program they chose.
| Background | AI Marketing | Data Analytics | Data Science |
|---|---|---|---|
| Arts | 31 | 39 | 10 |
| Commerce | 11 | 63 | 26 |
| Engineering | 12 | 46 | 62 |
H0: program choice is independent of background.
ci = pd.read_csv("course_interest.csv")
table = pd.crosstab(ci["background"], ci["program"])
chi = stats.chi2_contingency(table)
print(f"chi2={chi.statistic:.2f}, df={chi.dof}, p={chi.pvalue:.2e}")
Output:
chi2=57.44, df=4, p=1.00e-11
Conclusion: reject H0. Background and program choice are related, with a moderate strength (Cramér's V = 0.31). Every expected count was at least 14.4, so the chi-square approximation is safe.
Example 4: Paired t-Test (and the Mistake That Hides a Real Effect)
25 students take a SQL mock test, do a 2-week practice sprint, then retake it. Average score goes from 56.76 to 60.28.
s = pd.read_csv("sql_mock_scores.csv")
paired = stats.ttest_rel(s["after"], s["before"]) # correct
unpaired = stats.ttest_ind(s["after"], s["before"], equal_var=False) # wrong
print(f"paired: t={paired.statistic:.3f}, p={paired.pvalue:.4f}")
print(f"unpaired: t={unpaired.statistic:.3f}, p={unpaired.pvalue:.4f}")
Output:
paired: t=2.419, p=0.0235
unpaired: t=1.269, p=0.2106
Conclusion: the paired test finds a significant 3.5-point gain (p = 0.024, 95% CI 0.5 to 6.5 points). The unpaired test on the same numbers says p = 0.21, "no effect".
Why the gap? Student ability varies a lot, and the paired test cancels that out by looking at each student's own change. Treat paired data as independent and the real effect drowns in between-student noise.

How to Read a Hypothesis Testing P-Value Correctly
A p-value is the probability of getting data at least as extreme as yours if the null hypothesis were true. It is not the probability that the null is true, and it does not tell you how big or important an effect is.
The American Statistical Association published six principles on p-values in 2016 because misuse was so widespread (ASA statement, The American Statistician). In short, the ASA says p-values can show how incompatible data are with a model, but they don't measure the probability that a hypothesis is true, and decisions shouldn't rest only on crossing a threshold.
| What people say | What's actually true |
|---|---|
| "p = 0.03, so there's a 3% chance H0 is true." | If H0 were true, data this extreme would show up about 3% of the time. |
| "p = 0.20, so there's no effect." | There isn't enough evidence. The effect could be real but under-sampled. |
| "p = 0.0001 means a huge effect." | It may be a tiny effect measured on a huge sample. Check the effect size. |
| "p = 0.049 is a win, p = 0.051 is a loss." | These are practically the same evidence. Report the number and the CI. |

For a short audio explainer, listen to the Fireblaze podcast episode What Is the P-Value?.
4 Hypothesis Testing Mistakes We Simulated
Four common mistakes make "significant" results unreliable, and we measured how much with seeded Python simulations (code in the practice pack). No top-ranking guide we checked in December 2026 quantifies them.
| Mistake | What we simulated | False positive rate (or result) |
|---|---|---|
| Testing many metrics | 20 metrics, no real effect, 10,000 runs | 64.7% had at least one "significant" metric |
| ...fixed with Bonferroni | Same, α = 0.05 / 20 = 0.0025 | 5.1% |
| Peeking daily | A/A test, 300 visitors/version/day, stop at first p < 0.05, 14 days, 5,000 runs | 22.0% |
| ...checking once at day 14 | Same data, one planned look | 4.9% |
| Huge sample, trivial effect | 100,000 orders per app, 0.2-minute true difference | p = 1.0 × 10⁻⁹, Cohen's d = 0.03 |
| Under-powered test | 1,200 visitors/version, 4% vs 5% | Only 22% power |
Mistake 1: Testing 20 Things and Reporting the Winner
Check enough metrics and something will cross 0.05 by luck. With 20 independent tests, the chance of at least one false alarm is 1 − 0.95²⁰ ≈ 64%, and our simulation matched it (64.7%).
Fix: pick one primary metric before the test. If you must test many, divide α by the number of tests (Bonferroni) or use a false discovery rate method.
Mistake 2: Peeking and Stopping Early
Looking at a running A/B test every day and stopping the moment p dips below 0.05 gives luck 14 chances instead of 1. Our false positive rate jumped from 4.9% to 22.0%, more than four times the promised 5%.
Fix: set the sample size in advance with a power calculation, then analyse once. If you need to monitor, use a sequential testing method designed for it.
Mistake 3: Confusing "Significant" With "Important"
With 100,000 orders per app, a 0.2-minute difference in delivery time gave p = 0.000000001. Nobody will notice 12 seconds.
Fix: always report the effect size and confidence interval next to the p-value, and decide in advance what difference is worth acting on.
Mistake 4: Running Tests That Can't Detect Anything
A test with 22% power will usually say "no difference" even when a real lift exists. Teams then kill good ideas.
Fix: run the power calculation from the Type II error section before collecting data.
Bottom line: A p-value is only as honest as the plan behind it. Decide the metric, sample size and test first.

Hypothesis Testing in Data Science and A/B Testing
Hypothesis testing in data science shows up most in A/B testing, model comparison and feature analysis, and it is a standard topic in analyst and data scientist interviews.
A/B testing is hypothesis testing at company scale. Ronny Kohavi, who led Microsoft's experimentation team, reported that when ideas are tested in controlled experiments, fewer than a third improve the metric they were built to move (Bing blog, 2013). Without a proper test, teams would ship the other two-thirds on gut feel.
Other places you'll use it:
- Regression output: the p-value next to each coefficient tests H0: "this coefficient is zero". It only holds if the model's assumptions do; see assumptions of linear regression.
- Comparing models: is model B's accuracy gain real or a lucky test split?
- Business analysis: did the price change, campaign or new centre timing actually change enquiries?
Interviewers love to ask you to explain a p-value without jargon, pick a test for a scenario, or spot the peeking mistake. Practise with our statistics interview questions and answers.
Fireblaze's PG Program in Data Science and Analytics covers hypothesis testing, confidence intervals and A/B testing in its Statistics for Data Science module, as listed on the course page in December 2026.
Now It's Your Turn
Hypothesis testing in statistics comes down to a plan: state H0 and H1, fix α and the sample size, pick the test with the 4-Question Test Picker, then report the effect size along with the p-value.
The fastest way to make it stick is to run the four examples yourself. Download the practice pack, change one number, and watch the p-value move.
Want feedback from a trainer while you learn? Book a free career counselling session with Fireblaze AI School.
Which part trips you up most: choosing the test or reading the p-value?
FAQ
What is hypothesis testing in statistics in simple words?
Hypothesis testing in statistics is a way to check whether a pattern in your sample is real or could easily be random luck. You assume there is no effect, measure how surprising your data would be under that assumption, and reject the assumption only if the data is surprising enough, usually with a p-value below 0.05.
What are the main types of hypothesis testing?
The main types of hypothesis testing are t-tests (one-sample, two-sample and paired), z-tests for proportions, chi-square tests for categories, and ANOVA for three or more group means. Each has a non-parametric alternative, such as Mann-Whitney U or Wilcoxon, for data that breaks the normality assumption.
What does a p-value of 0.05 mean?
A p-value of 0.05 means that if the null hypothesis were true, you would see data at least this extreme about 5% of the time. It does not mean there is a 5% chance the null hypothesis is true, and it says nothing about how large the effect is.
What is the difference between a Type 1 and a Type 2 error?
A Type 1 error is rejecting a null hypothesis that is actually true, a false positive whose rate is set by α. A Type 2 error is failing to reject a null hypothesis that is actually false, a missed effect. Larger samples reduce Type 2 errors without raising Type 1 errors.
Can we accept the null hypothesis?
No, you don't accept the null hypothesis; you either reject it or fail to reject it. Failing to reject means the data didn't give enough evidence against it, which can happen even when a real effect exists but the sample was too small.
Which Python library is used for hypothesis testing?
SciPy's scipy.stats module covers most hypothesis tests in Python, including ttest_1samp, ttest_ind, ttest_rel, chi2_contingency and mannwhitneyu. statsmodels adds proportion z-tests, power and sample size calculations, and multiple testing corrections.
Sources
- Statistical Methods for Research Workers, Ronald A. Fisher, Chapter 3, 1925
- The ASA's Statement on p-Values: Context, Process, and Purpose, American Statistical Association, 2016
- Redefine Statistical Significance, Benjamin et al., Nature Human Behaviour, 2018
- Large Scale Experimentation at Bing, Ronny Kohavi, 2013
- scipy.stats.ttest_ind documentation, SciPy, 2026
- statsmodels proportions_ztest documentation, statsmodels, 2026
- Fireblaze AI School simulations and worked examples (Python 3.13, SciPy 1.18.1, statsmodels 0.15.0), run 3 December 2026; code in the practice pack
Keep Reading
Related Articles
Fireblaze News & Events
KITS Ramtek Inaugurated by Aniruddha Kalbande: A Milestone in Technical Education
Explore the significance of the KITS Ramtek inauguration by Aniruddha Kalbande and its impact on technical education, innovation, skill development, a
Fireblaze Tech League Season 2: AI CFO Hackathon Brings 20 Student Teams to Nagpur
On 13 June 2026, Fireblaze AI School hosted its flagship AI hackathon, "Fireblaze Tech League (FTL) 2.0," at Mate Square, Nagpur. The theme was "AI CF
Fireblaze AI School Founder Mentors Winning Teams at Orange Promptathon 2026
Fireblaze AI School founder Aniruddha Kalbande mentored multiple student teams that secured top positions at Orange Promptathon 2026, a major AI innov