Hypothesis Testing Explained

Run 20 tests on pure noise and what happens? You have about a 64 percent chance of finding at least one “significant” result. That single number shows why hypothesis testing needs clear logic, not just a formula. This guide walks through that logic with a courtroom, a coffee machine, and a website test, all with real numbers.

Quick Answer

  • Hypothesis testing assumes no effect (H0) and rejects it only when the data make that assumption hard to believe.
  • A Type I error is a false alarm; a Type II error is a missed real effect.
  • Lowering one error rate raises the other unless you collect a larger sample.
  • Power is the chance of catching a real effect; 80 percent is a common planning target.
  • Statistically significant does not mean large or important, especially with huge samples.

What Is Hypothesis Testing?

Hypothesis testing is a method for deciding whether sample data give strong enough evidence against a default claim, called the null hypothesis. It works much like a criminal trial.

In court, the defendant is presumed innocent. The null hypothesis (H0) plays that role: no effect, no difference, nothing unusual. The prosecution must bring evidence strong enough to convict “beyond reasonable doubt.” In statistics, that bar is the significance level, alpha, often set at 0.05.

The verdict wording matters. A jury says “not guilty,” never “innocent.” Weak evidence does not prove innocence; it only fails to prove guilt. A test works the same way. We either “reject H0” or “fail to reject H0,” and we never “accept H0.” A small sample can miss a real effect, just as a thin case can free a guilty person.

How Do You Write the Null and Alternative Hypotheses?

Turn your question into two claims about a population number. H0 states “no change” with an equals sign, and H1 states the effect you want to show.

Start with the plain question, then name the parameter. Three examples show the pattern:

  • “Does this machine fill 250 ml cups correctly?” becomes H0: mean = 250 ml and H1: mean is not 250 ml.
  • “Does the new checkout page sell more?” becomes H0: p(new) = p(old) and H1: p(new) > p(old).
  • “Is the defect rate above 2 percent?” becomes H0: p = 0.02 and H1: p > 0.02.

Write both hypotheses before you see the data. Choosing the direction after peeking at results inflates false alarms. The claim you hope to support always goes in H1, because a test can only build evidence against H0.

How Does a Hypothesis Test Work From Start to Finish?

A test states the hypotheses, sets alpha, computes a test statistic from the sample, converts it to a p-value, and compares that p-value with alpha.

The hypothesis testing decision flow Four steps lead from a real question to a test statistic. A decision diamond then asks whether the p-value is at most alpha. Yes leads to reject H0; no leads to fail to reject H0. From question to decision 1. Real question 2. State H0 and H1 3. Set alpha = 0.05 4. Collect data, compute statistic p-value <= alpha? Yes No Reject H0 evidence supports H1 Fail to reject H0 not enough evidence
Every test follows the same path; only the test statistic changes.

Worked Example: The 250 ml Coffee Machine

A cafe owner measures 40 cups. The sample mean is 247.8 ml and the standard deviation is 6.1 ml. Set H0: mean = 250 and H1: mean is not 250, with alpha = 0.05.

The standard error is 6.1 / sqrt(40) = 0.964 ml. The t statistic is (247.8 – 250) / 0.964 = -2.28, with 39 degrees of freedom. That gives a two-sided p-value of 0.028. Since 0.028 is below 0.05, we reject H0: the machine underfills. What the 0.028 actually means is covered in what a p-value really tells you.

The same data give a 95 percent interval of 245.8 to 249.8 ml, which excludes 250. That match is no coincidence, as confidence intervals explained shows. To run this test on your own numbers, use the hypothesis test calculator for z, t, and proportion tests.

What Are Type I and Type II Errors?

A Type I error rejects a true null hypothesis, a false alarm; a Type II error fails to reject a false one, a missed effect. Their rates are alpha and beta.

The four outcomes of a hypothesis test Rows show the decision and columns show the truth. Rejecting a true H0 is a Type I error. Failing to reject a false H0 is a Type II error. The other two cells are correct decisions. Decision versus truth H0 is true H0 is false Reject H0 Fail to reject H0 Type I error (alpha) innocent person convicted Correct: power (1 – beta) guilty person convicted Correct (1 – alpha) innocent person freed Type II error (beta) guilty person goes free
Two cells are correct calls and two are errors; the courtroom version sits under each label.

The two errors pull against each other. Demand stronger evidence and you convict fewer innocents but free more guilty people. Which error hurts more depends on the setting:

The same tradeoff in two real settings
Setting Type I error means Type II error means Usual priority
Medical screening (H0: no disease) A healthy person gets a follow-up test A real disease goes undetected Avoid Type II; accept more false alarms
Spam filter (H0: email is legitimate) A real email lands in spam A spam message reaches the inbox Avoid Type I; accept some missed spam

How Do Power and Sample Size Affect a Test?

Power is the probability that a test detects a real effect, equal to 1 – beta. Larger samples, larger effects, and a higher alpha all raise it.

Alpha, beta, and power on two distributions The null distribution centers at 0 and the alternative at 2.5 standard errors. A one-sided cutoff at 1.645 leaves alpha of 0.05 under the null, beta of about 0.20 under the alternative, and power of about 0.80. Where alpha, beta, and power live H0 true H1 true cutoff (z = 1.645) alpha = 0.05 beta = 0.20 power = 0.80
Moving the cutoff right shrinks alpha but grows beta; only more data pulls the curves apart.

The figure shows a one-sided z test where the true effect sits 2.5 standard errors from H0. The cutoff at 1.645 leaves alpha at 0.05 and power at 0.80.

Back to the coffee machine. Suppose the true mean is 248 ml, a 2 ml shortfall. With 40 cups and a spread of 6.1 ml, a simulation of 40,000 samples gives power of only about 53 percent. That is close to a coin flip. Measuring about 75 cups lifts power to 80 percent, and 100 cups reaches about 90 percent. Plan the sample size before collecting data, not after a disappointing result.

Why Can a Significant Result Still Mislead You?

Significance says an effect is unlikely to be zero, not that it is large. It also breaks down when you run many tests at once.

A Tiny Effect With a Huge Sample

Consider an A/B test of two signup pages. Page A converts 200 of 4,000 visitors (5.0 percent) and page B converts 250 of 4,000 (6.25 percent). A two-proportion z test gives z = 2.43 and p = 0.015, a real and useful 1.25-point lift.

Now scale up to 1,000,000 visitors per page, with rates of 5.00 and 5.10 percent. The test gives z = 3.23 and p = 0.0012, an even smaller p-value. Yet the lift is just 0.1 point, which rarely pays for a redesign. Always report the effect size next to the p-value.

The Multiple-Comparisons Trap

Each test at alpha 0.05 carries a 5 percent false-alarm risk. Across 20 independent tests with no real effects, the chance of at least one false positive is 1 – 0.95^20 = 0.64. The expected number of false positives is exactly one. A simple fix, the Bonferroni correction, divides alpha by the number of tests, giving 0.05 / 20 = 0.0025 per test.

Practical rule: Decide your hypotheses, alpha, and sample size in writing before you look at the data. That habit blocks the three most common traps: direction switching, underpowered tests, and fishing through many comparisons.
Testing a claim of your own?

The Hypothesis Test Calculator runs one-sample z, t, and one-proportion tests and returns the test statistic, p-value, and decision.

FAQs About Hypothesis Testing

What Is Hypothesis Testing in Simple Terms?

It is a way to check whether data give strong evidence against a default claim of no effect. You assume the null hypothesis is true, measure how surprising your sample is, and reject the null only when the evidence is strong.

What Is the Difference Between the Null and Alternative Hypothesis?

The null hypothesis states no effect or no difference and always contains an equals sign. The alternative hypothesis states the effect you want evidence for, such as a mean that is higher, lower, or simply different.

Does Failing to Reject the Null Hypothesis Prove It Is True?

No. Like a “not guilty” verdict, it means the evidence was not strong enough. A small sample or low power can hide a real effect. The correct wording is “fail to reject,” never “accept.”

Which Is Worse, a Type I or a Type II Error?

It depends on the cost of each mistake. In medical screening, missing a disease (Type II) is usually worse. In spam filtering, sending a real email to spam (Type I) is usually worse.

How Large a Sample Do I Need for a Hypothesis Test?

Enough to give about 80 percent power for the smallest effect you care about. In the coffee example, detecting a 2 ml shortfall with a 6.1 ml spread takes about 75 cups. With 40 cups, power is only about 53 percent.

Why Is 0.05 the Usual Significance Level?

It is a long-standing convention that balances false alarms against missed effects, not a law of nature. Fields with costly false alarms often use 0.01 or stricter, while early exploratory work sometimes uses 0.10.

Can a Result Be Statistically Significant but Not Important?

Yes. With 1,000,000 users per group, a lift from 5.00 to 5.10 percent gives p = 0.0012, yet the 0.1-point gain is tiny. Always judge the effect size alongside the p-value.

Sources

References Used in This Article

This article explains the logic of hypothesis testing for general education. Worked numbers were computed and checked independently. Reviewed for accuracy by Prof. Dr. Khalil Mudassar, PhD. Last updated September 27, 2026.


Author

shakeel-Muzaffar
Founder & Editor-in-Chief at  ~ Web ~  More Posts

Shakeel Muzaffar is the Founder and Editor-in-Chief of MultiCalculators.com, bringing over 15 years of experience in digital publishing, product strategy, and online tool development. He leads the platform's editorial vision, ensuring every calculator meets strict standards for accuracy, usability, and real-world value. Shakeel personally oversees content quality, formula verification workflows, and the platform's commitment to publishing tools that are genuinely useful for students, professionals, and everyday users worldwide.

Leave a Comment