- Statistics
- Beginner
- 30 min
- Interactive
Hypothesis Testing for Beginners
Hypothesis testing is a fair, step-by-step way to answer one question: is what I'm seeing real, or could it just be luck? No formulas to memorise yet. You will flip coins, play referee, and see why statisticians talk about the null hypothesis, alpha, beta, power, and Type I and Type II errors.
By the end, you will be able to
- Write a null hypothesis and an alternative hypothesis for an everyday question.
- Explain what the significance level (alpha) means and why you pick it before looking at the data.
- Tell a Type I error (false alarm) from a Type II error (missed it).
- Explain beta and power, and the three things that make a test more powerful.
Part 1 · The story
Real, or just luck? The case of the lucky coin
Meet Riley, captain of the school basketball team. Before every game the referee flips a coin and Riley calls "heads". Riley uses a shiny "lucky coin" from home, and it seems to land heads a lot.
- Riley calls heads before game 1... and wins the toss. Then game 2. Then game 3."Heads again! Told you it's lucky."
- Sam, the referee, starts to wonder. Is the coin rigged, or is Riley just having a good run?"Hmm. Lucky streaks happen. But this many?"
- Sam doesn't want to accuse Riley unfairly. So Sam decides to test the coin with a fair set of rules."I'll flip it 20 times and let the evidence decide."
Sam's problem is the problem every scientist, doctor, engineer, and quality inspector faces: random chance can fool you. A fair coin can land heads 7 times in 10 just by luck. So how many heads is "too many to be luck"? Hypothesis testing is the rulebook Sam needs.
The one-sentence idea: start by assuming nothing special is happening, then ask whether your evidence would be really surprising if that were true. If it would be, you stop believing the "nothing special" story.
Part 2 · The big idea
Think like a courtroom: innocent until proven guilty
The easiest way to understand hypothesis testing is a trial. A court doesn't start by assuming the person did it. It starts with "innocent" and only changes its mind when the evidence is strong. A hypothesis test works exactly the same way.
The accused is presumed innocent.
We assume the null hypothesis: nothing special is going on (the coin is fair).
Notice the wording. A jury never says "innocent". It says "not guilty", which only means there wasn't enough evidence. Statisticians are just as careful: we say "fail to reject the null", never "the null is proven true".
Part 3 · Two competing stories
The null hypothesis and the alternative hypothesis
Every hypothesis test starts with two statements that can't both be true. Think of them as two stories about the world. Your data will help you decide which story to believe.
The null hypothesis: "nothing special"
The boring, default story. Nothing has changed, there's no difference, no effect, no cheating. It gets the symbol \(H_0\) (say "H-nought" or "H-zero").
where \(p\) is the coin's true chance of landing heads. In words: Riley's coin is fair.
The alternative hypothesis: "something's up"
The claim you're looking for evidence of. Something changed, there is a difference, there is an effect. It gets the symbol \(H_1\) (some books write \(H_a\)).
In words: Riley's coin lands heads more than half the time.
Four rules of thumb
- The null always contains the "equals" sign. It names one exact value (here, exactly half). The alternative is "bigger than", "smaller than", or "different from".
- You assume the null is true until the evidence says otherwise, just like "innocent until proven guilty".
- The alternative is usually the exciting claim: the new medicine works, the new machine is faster, the coin is rigged.
- Write both before you collect any data. Changing your hypotheses after peeking is like the prosecutor changing the charge after hearing the evidence.
Good to know: Sam suspects too many heads, so the alternative points one way (\(p > 0.5\)). That's a one-sided test. If Sam only suspected the coin was "unfair in some direction", the alternative would be \(p \ne 0.5\), a two-sided test. The reasoning in this lesson works the same for both.
Try it Null or alternative?
Read each statement. Is it the "nothing special" story (null) or the "something's up" claim (alternative)?
Part 4 · Collect evidence
How surprising is the result? Meet the p-value
Here is the key move. We pretend the null is true (the coin is fair) and ask: if the coin really were fair, how often would we see a result as extreme as ours? If the answer is "almost never", the fair-coin story starts to look silly.
Try it yourself. Flip a coin and watch where your results land compared with what a fair coin usually does.
Lab 1 The coin-flip lab
Press Flip once to start an experiment.
The surprise score has a name: the p-value
The number in the lab is called the p-value. It answers one question:
where \(P(\ldots)\) means "the probability of", and the bar \(\mid\) means "assuming". So: the chance of seeing data this extreme if the coin really is fair.
- Small p-value (like 0.006): "Wow, a fair coin almost never does that." That's strong evidence against the null.
- Large p-value (like 0.25): "Meh, a fair coin does that all the time." Not much evidence against the null.
Sam flipped Riley's coin 20 times and got 16 heads. Here is how surprising each result would be for a fair coin:
| Heads in 20 flips | p-value | In plain words |
|---|---|---|
| 12 or more | 0.2517 | About 1 in 4. Happens all the time. |
| 13 or more | 0.1316 | About 1 in 8. Not unusual. |
| 14 or more | 0.0577 | About 1 in 17. A bit unusual. |
| 15 or more | 0.0207 | About 1 in 50. Pretty surprising. |
| 16 or more (Sam's result) | 0.0059 | About 6 in 1,000. Very surprising. |
| 17 or more | 0.0013 | About 1 in 770. Extremely rare. |
Careful: a p-value of 0.0059 does not mean "there's a 0.59% chance the coin is fair". It means "if the coin were fair, results like this would happen only 0.59% of the time." It's a statement about the data, assuming the null.
Part 5 · Set the bar
Draw the line first: the significance level (alpha)
"Surprising" is fuzzy. Is 1 in 17 surprising enough? 1 in 50? To keep things fair, Sam picks a cut-off before flipping. That cut-off is the significance level, written \(\alpha\) (the Greek letter alpha).
where \(\alpha\) is the largest false-alarm risk you are willing to accept. The most common choice is \(\alpha = 0.05\), which means "I'm OK being fooled by luck about 1 time in 20 when nothing is really going on".
Lab 2 Set the bar and make the call
Sam flips 20 times. Choose alpha, then slide the number of heads. Watch the red "reject" zone and the verdict.
- Fair coin result: keep the null
- Reject zone (hatched)
- Sam's result
Two ways to say the same decision, and both always agree:
- The p-value way: 16 heads has a p-value of 0.0059. That's below 0.05, so reject the null.
- The cut-off way: with \(\alpha = 0.05\), the reject zone starts at 15 heads. 16 is inside the zone, so reject the null.
Why is the "real" risk not exactly 0.05? Coin flips come in whole numbers, so you can't land exactly on 0.05. Starting the zone at 15 heads gives a false-alarm risk of 0.0207, the closest you can get without going over 0.05. With smooth measurements (like heights or weights), alpha can be hit exactly.
Pick alpha before you look. If Sam saw 14 heads (a p-value of 0.0577) and then said "let's switch to 0.10 instead", that's cheating, just like moving the goalposts after the kick.
Part 6 · Nobody's perfect
Two ways to be wrong: Type I and Type II errors
Sam never gets to peek inside the coin. Sam only sees the flips, and flips are random. So even with perfect rules, Sam can still be wrong in two different ways. Pick a story below and read the four boxes.
Explore The four possible outcomes
| Your decision | The truth: the null is TRUE | The truth: the null is FALSE |
|---|---|---|
| You reject the null | Type I error: false alarmChance of this: \(\alpha\) | Correct: caught itChance of this: \(1-\beta\), the power |
| You fail to reject the null | Correct: rightly left aloneChance of this: \(1-\alpha\) | Type II error: missed itChance of this: \(\beta\) |
Type I error: the false alarm
You reject a null that was actually true. You "see" an effect that isn't there.
Its probability is \(\alpha\). That's why you choose \(\alpha\) yourself: you're choosing how many false alarms you'll put up with.
Type II error: the miss
You fail to reject a null that was actually false. A real effect slips past you.
Its probability is \(\beta\) (the Greek letter beta). You don't set \(\beta\) directly. It depends on your sample size and how big the real effect is.
Memory trick: The Boy Who Cried Wolf. The null is "there is no wolf".
First, the villagers believe the boy and run out, but there's no wolf. They rejected a true null: a Type I error (false alarm).
Later, a real wolf comes, but the villagers ignore the boy. They failed to reject a false null: a Type II error (missed it).
Part 7 · Your turn
Play referee: the mystery coin game
Now you're the referee. Each round the computer secretly hands you either a fair coin or a rigged coin that lands heads 70% of the time (50/50 chance of each). Flip it, look at the evidence, and make the call. Then the truth is revealed.
Game Fair or rigged?
Press the button to get your first mystery coin.
Let a robot referee play 1,000 rounds
The robot always uses the rule "reject the null if \(\text{p-value} \le 0.05\)". How often does it get fooled?
Play a few rounds with 10 flips, then switch to 50. With more flips, the rigged coin gets much harder to hide. That's the next big idea: power.
Part 8 · How good is your detector?
Beta and power: how good is your cheat detector?
Think of a hypothesis test as a cheat detector. \(\alpha\) tells you how often it goes off when nothing is wrong. But you also want to know how often it catches a real cheat. That's called power.
where \(\beta\) is the chance of a miss (Type II error). If \(\beta = 0.20\), the test misses a real effect 20% of the time and catches it 80% of the time, so the power is 0.80. Many studies aim for a power of at least 0.80.
Lab 3 The power explorer
Two worlds are drawn on one chart: what a fair coin does (left half of each bar slot) and what a rigged coin does (right half). The dashed red line is where the reject zone starts.
- Fair coin, correctly kept
- Fair coin wrongly rejected (false alarm)
- Rigged coin missed (Type II error)
- Rigged coin caught (power, hatched)
Three levers that change power
| Lever | What happens to power | Why, in plain words | The catch |
|---|---|---|---|
| More flips (bigger sample) | Goes up | More evidence makes the two worlds overlap less, so the cheat can't hide. | Costs more time and money. |
| Bigger cheat (bigger effect) | Goes up | A coin that lands heads 90% of the time is easier to spot than one at 55%. | You don't control this. Nature does. |
| Larger alpha | Goes up | A lower bar for rejecting catches more real cheats. | More false alarms, too. That's the seesaw. |
With Riley's coin (75% heads), 20 flips, and \(\alpha = 0.05\), the power is about 0.62: Sam would catch the trick only about 6 times in 10. With 50 flips, power jumps to about 0.97. When the stakes are high, plan enough data before you start.
Part 9 · Put it together
The five-step referee checklist
Every hypothesis test, from coin flips to medicine trials to factory quality checks, follows the same five steps. Here's Sam's case from start to finish.
- Write the two stories. Null \(H_0\): the coin is fair, \(p = 0.5\). Alternative \(H_1\): the coin favours heads, \(p > 0.5\).
- Set the bar before looking. Sam chooses \(\alpha = 0.05\). Sam also notes that 20 flips gives only about 62% power against a 75%-heads coin, so a "not rigged" result won't prove much.
- Collect the evidence. 20 flips. Result: 16 heads.
- Measure the surprise. If the coin were fair, 16 or more heads happens with probability 0.0059 (the p-value).
- Decide and say it in plain words. 0.0059 is below 0.05, so Sam rejects the null: "The evidence suggests Riley's coin lands heads more than half the time." Sam swaps in the league's own coin.
What if Sam had seen 13 heads? The p-value would be 0.1316, above 0.05, so Sam would fail to reject the null. The right sentence is "there isn't enough evidence that the coin is rigged", not "the coin is fair". Remember: not guilty is not the same as innocent.
Part 10 · Beyond coins
Hypothesis testing in the real world
The same logic runs things you use every day. In each case, ask: what's the "nothing special" story, and which mistake would hurt more? Open each card to check your thinking.
Medical screening test
- Null
- The patient does not have the disease.
- Type I error
- Healthy person told they might be sick (more tests, worry).
- Type II error
- Sick person told they're fine (treatment delayed).
Which mistake is worse?
Usually the Type II error, missing a real disease. Screening tests are designed to catch nearly every real case and accept some false alarms, which a second test then sorts out.
Smoke alarm
- Null
- There is no fire.
- Type I error
- The alarm beeps at burnt toast.
- Type II error
- A real fire, and the alarm stays silent.
Which mistake is worse?
The Type II error, by a mile. That's why smoke alarms are set to be touchy: they accept a high false-alarm rate to keep the miss rate tiny.
Steel pipe inspection
- Null
- The pipe has no hidden crack.
- Type I error
- A good pipe is flagged and pulled for re-checking (wasted time and money).
- Type II error
- A cracked pipe passes inspection and is shipped to a customer.
Which mistake is worse?
The Type II error. A cracked pipe in a pipeline can leak or burst. Mills tune inspection so a missed flaw is very unlikely and accept that some good pipes will be re-checked. In quality language, the false alarm is the producer's risk and the miss is the consumer's risk.
Email spam filter
- Null
- This email is a normal, wanted email.
- Type I error
- Your friend's party invite lands in the spam folder.
- Type II error
- A spam message lands in your inbox.
Which mistake is worse?
Most people say the Type I error: losing an important email hurts more than deleting one junk message. So spam filters are tuned to be cautious about rejecting the null.
The big lesson: there is no free lunch. For a fixed amount of data, making one mistake rarer makes the other more common. You choose alpha by asking which mistake costs more. If you want both to be rare, you need more data.
Part 11 · Cheat sheet
Hypothesis testing vocabulary cheat sheet
| Term | Symbol | Plain meaning | In the coin story |
|---|---|---|---|
| Null hypothesis | \(H_0\) | The default "nothing special" story. Contains the equals sign. | The coin is fair: \(p = 0.5\). |
| Alternative hypothesis | \(H_1\) or \(H_a\) | The claim you want evidence for. | The coin favours heads: \(p > 0.5\). |
| p-value | \(p\text{-value}\) | How surprising the data are if the null is true. | 16 heads gives 0.0059. |
| Significance level | \(\alpha\) | The bar you set in advance; also the chance of a false alarm. | 0.05 |
| Type I error | (probability \(\alpha\)) | False alarm: rejecting a true null. | Calling a fair coin rigged. |
| Type II error | (probability \(\beta\)) | Miss: failing to reject a false null. | Letting a rigged coin pass. |
| Beta | \(\beta\) | The chance of a miss when a real effect exists. | About 0.38 for 20 flips of a 75%-heads coin. |
| Power | \(1-\beta\) | The chance of catching a real effect. | About 0.62 for 20 flips; about 0.97 for 50. |
| Reject the null | – | The evidence is strong enough to stop believing "nothing special". | Sam's verdict with 16 heads. |
| Fail to reject the null | – | Not enough evidence. Not proof that the null is true. | What 13 heads would give. |
Part 12 · Do it with software
Statistics Implementation
You don't need software to understand the ideas, but at work you'll use Excel or Minitab to get the numbers. Everything below reproduces the coin story: 20 flips, a fair-coin null of \(p = 0.5\), \(\alpha = 0.05\), and Riley's 75%-heads coin as the "real cheat".
Excel Functions
| Function | Syntax | Purpose | When to use it |
|---|---|---|---|
BINOM.DIST (exact) | =BINOM.DIST(number_s, trials, probability_s, FALSE) | Probability of exactly number_s successes. | Height of one bar in the "fair coin" chart, e.g. the chance of exactly 16 heads. |
BINOM.DIST (cumulative) | =BINOM.DIST(number_s, trials, probability_s, TRUE) | Probability of at most number_s successes. | p-values (as 1 - …), beta, and power for count data. |
BINOM.DIST.RANGE | =BINOM.DIST.RANGE(trials, probability_s, number_s, [number_s2]) | Probability of between number_s and number_s2 successes. | A one-step p-value such as "16 to 20 heads". Excel 2013 or later. |
BINOM.INV | =BINOM.INV(trials, probability_s, alpha) | Smallest count whose cumulative probability is at least alpha. | Finding where the reject zone starts. Its alpha argument is a cumulative probability, not your significance level. |
NORM.S.INV | =NORM.S.INV(probability) | The z-value with that much area to its left on the standard normal curve. | Critical values for measurement data: =NORM.S.INV(0.95) = 1.645 (one-sided, 0.05); =NORM.S.INV(0.975) = 1.960 (two-sided, 0.05). |
NORM.S.DIST | =NORM.S.DIST(z, TRUE) | Area to the left of a z-value. | Turning a z-value into a tail probability; approximating power for large samples. |
RAND | =RAND() | A random number between 0 and 1. | Simulating a coin: =IF(RAND()<0.5,"H","T"). |
COUNTIF | =COUNTIF(range, criteria) | Counts cells that match. | Counting heads in a column of simulated flips. |
| Legacy names | BINOMDIST, CRITBINOM, NORMSINV, NORMSDIST | Older versions of the functions above, kept for compatibility. | Recognise them in older workbooks and textbooks; use the newer names in new work. |
Excel Use Cases
| Question | Formula | Result | What it means |
|---|---|---|---|
| Chance a fair coin gives exactly 16 heads in 20 | =BINOM.DIST(16,20,0.5,FALSE) | 0.0046 | One bar of the fair-coin chart. |
| p-value for 16 or more heads | =1-BINOM.DIST(15,20,0.5,TRUE) | 0.0059 | "At least 16" is everything above 15. |
| Same p-value in one step | =BINOM.DIST.RANGE(20,0.5,16,20) | 0.0059 | Adds up the bars from 16 to 20. |
| Where does the reject zone start (alpha 0.05)? | =BINOM.INV(20,0.5,1-0.05) | 14 | Up to 14 heads is "normal", so reject at 15 or more. |
| Real false-alarm risk of that rule | =1-BINOM.DIST(14,20,0.5,TRUE) | 0.0207 | The actual alpha, just under 0.05. |
| Beta against Riley's 75% coin | =BINOM.DIST(14,20,0.75,TRUE) | 0.3828 | Chance a rigged coin still lands in the "keep" zone. |
| Power against Riley's 75% coin | =1-BINOM.DIST(14,20,0.75,TRUE) | 0.6172 | Chance Sam catches the rigged coin. |
| Simulate 20 flips | =IF(RAND()<0.5,"H","T") in A2:A21, then =COUNTIF(A2:A21,"H") | Changes each time | Press F9 to re-flip, just like Lab 1. |
| Write the decision automatically | =IF(B1<=0.05,"Reject H0","Fail to reject H0") | Reject H0 | With the p-value (0.0059) in cell B1. |
Minitab Navigation
| Task | Menu path | What to enter | Notes: which option and why |
|---|---|---|---|
| p-value for a count | Calc → Probability Distributions → Binomial | Cumulative probability; Number of trials 20; Event probability 0.5; Input constant 15. | Minitab returns the chance of 15 or fewer heads (0.9941). Subtract from 1 to get the p-value, 0.0059. |
| Where the reject zone starts | Calc → Probability Distributions → Binomial | Inverse cumulative probability; Input constant 0.95. | For counts, Minitab lists the two values either side of 0.95 (13 heads at 0.9423, 14 heads at 0.9793). Reject above 14. |
| Picture the reject zone | Graph → Probability Distribution Plot → View Probability | Distribution: Binomial (20, 0.5); Shaded Area: X Value, Right Tail, 15. | Draws the same picture as Lab 2 with the alpha tail shaded. Great for reports. |
| Compare the two worlds | Graph → Probability Distribution Plot → Two Distributions | Binomial (20, 0.5) and Binomial (20, 0.75). | Shows how much the fair and rigged shapes overlap, which is what drives beta. |
| Simulate coin flips | Calc → Random Data → Binomial | Number of rows 1000; Number of trials 20; Event probability 0.5. | Each row is one 20-flip experiment, like "Run 100 quick experiments" in Lab 1. |
| Power and beta | Stat → Power and Sample Size → 1 Proportion | Sample sizes 20; Comparison proportions 0.75; Hypothesized proportion 0.5; Options: Greater than, significance level 0.05. | Reports power (beta is 1 minus power). Leave Sample sizes blank and enter a Power value of 0.8 to ask "how many flips do I need?". Minitab's figure can differ slightly from the hand calculation depending on the method it uses for counts. |
| Alternative path for measurements | Stat → Power and Sample Size → 1-Sample Z or 1-Sample t | Sample size, difference to detect, standard deviation. | Use these when your data are measurements (weights, thicknesses) instead of counts. |
| Next step: run a real test | Stat → Basic Statistics → 1 Proportion | Summarized data: 16 events in 20 trials; Perform hypothesis test, hypothesized proportion 0.5; Options: Greater than. | Preview only. It wraps all five referee steps into one dialog. You'll meet it in a later lesson. |
Exam Tips
- Know the definitions cold. ASQ CSSBB and CQE questions test that \(\alpha = P(\text{Type I error})\), \(\beta = P(\text{Type II error})\), and \(\text{power} = 1-\beta\). Expect "which statement is true" questions built on swapping these.
- Producer's risk and consumer's risk. In acceptance sampling (a CQE favourite), \(\alpha\) is the producer's risk (a good lot is rejected) and \(\beta\) is the consumer's risk (a bad lot is accepted). Same idea as false alarm vs miss.
- The null holds the equality. \(H_0\) uses \(=\), \(\le\), or \(\ge\); \(H_1\) uses \(\ne\), \(<\), or \(>\). If an answer option puts \(\ne\) in the null, eliminate it.
- Wording traps. The correct conclusion is "reject" or "fail to reject" the null. Options that say "accept the null" or "prove the alternative" are usually wrong.
- Levers on power. Power rises with a larger sample, a larger true difference, a larger \(\alpha\), and less process variation. For a fixed sample, lowering \(\alpha\) raises \(\beta\).
- Decision rule. Reject when \(\text{p-value} \le \alpha\). A handy memory line: "If the p is low, the null must go."
- Link to OC curves. An operating characteristic curve plots the probability of accepting (not rejecting) against the true quality level. At a bad quality level its height is \(\beta\); the power curve is its mirror image (\(1-\beta\)).
- Excel argument names. In
BINOM.INV, the argument calledalphais a cumulative probability. For a one-sided upper test at 0.05 you pass 0.95, not 0.05. - Real-world practice. Statistically significant does not always mean important. In reports, state the decision, the p-value, alpha, and whether the size of the effect matters to the business. Plan sample size for at least 0.80 power before collecting data.
Lesson summary
- Hypothesis testing asks: real, or just luck?
- The null hypothesis \(H_0\) is the "nothing special" story you assume first. The alternative \(H_1\) is the claim you want evidence for.
- The p-value measures how surprising your data would be if the null were true.
- The significance level \(\alpha\) is the bar you set in advance. Reject the null when the p-value is at or below it.
- A Type I error is a false alarm (probability \(\alpha\)). A Type II error is a miss (probability \(\beta\)).
- Power \(1-\beta\) is the chance of catching a real effect. More data, a bigger effect, or a larger \(\alpha\) all raise it.
- Never say "accept the null". Say "fail to reject": not guilty is not the same as innocent.
Knowledge check
Check your understanding
Comprehension quiz
Pick the strongest answer, then submit. Explanations appear after you submit.