When we test a new idea on a sample and see the average change, we need a way to tell whether that change is real or just ordinary random luck.
1
What a p-Value Measures
A p-value is the probability of getting data at least as extreme as our result, assuming the null hypothesis H0 is true. Instead of trying to calculate the probability of every possible way an idea could work, we start by assuming nothing changed at all and ask how surprising our sample would be by pure chance.
What a p-Value Measures
p-value=Probability of gettingdata at least this extreme,ifH0 is true
2
Finding One- and Two-Sided p-Values by Simulation
We want to find the p-value for a sample average xˉ by simulating how much the sample average varies by luck when H0 is true.
Historically, a coffee shop has averaged μ=20 customers per hour. Over n=9 hours with a new sidewalk sign, the shop averages xˉ=24 customers per hour with a standard deviation of s=6 customers. Could a 9-hour average of 24 happen easily by ordinary luck if the true average is still 20?
Finding One- and Two-Sided p-Values by Simulation
Text solution:
Simulate the null hypothesis (H0): Assuming the sign has zero effect gives a single exact baseline of μ=20 customers per hour, so a computer can simulate 1,000 random 9-hour averages by pure luck.
H0:μ=20
Count one tail for a one-sided test (Ha:μ>20): Because any single exact number has a tiny probability, we count the 40 simulated dots at 24 or higher in the right tail.
One-sided p-value=1,00040=0.04
Count both tails for a two-sided test (Ha:μ=20): When testing for a change in either direction, a drop of 4 customers to 16 or lower is just as extreme as a jump of 4 customers to 24 or higher, so we count both tails.
Two-sided p-value=1,00040+40=1,00080=0.08
So the simulated p-value is 0.04 (4%) when testing specifically for an increase, and 0.08 (8%) when testing for a change in either direction.
Sample averages close to 20 leave lots of simulated dots out in the tail, giving a large p-value that looks like ordinary luck. Sample averages further from 20 leave very few dots beyond them, giving a small p-value, and the two-sided p-value is always double the one-sided p-value.
Move the result line further from the center to see the tail shrink, and how counting both tails always doubles the p-value.
3
Finding a p-Value with Standard Error and a t-Curve
We don't need a computer simulation every time we want a p-value. To find the p-value directly from our sample numbers, we measure how many standard errors our sample average xˉ=24 sits from the null center μ=20 and find the tail area under a t-distribution.
Finding a p-Value with Standard Error and a t-Curve
Text solution:
Find the standard error of the sample mean: Averaging n=9 hours divides the single-hour variation of s=6 customers by 9, giving the typical variation of a 9-hour average under H0.
Standard Error=ns=96=2 customers
Convert the difference into standard errors (t): Dividing the 4-customer increase above 20 by the standard error of 2 tells us how many standard errors the sample average landed above the center.
t=Standard Errorxˉ−μ=224−20=2 standard errors
Find the tail area on the t-curve: Checking a t-distribution with n−1=8 degrees of freedom at t=2 gives the right-tail area for the one-sided test and both tail areas combined for the two-sided test.
So the t-distribution gives a one-sided p-value of 0.040 and a two-sided p-value of 0.080, matching the simulation.
Even for the same 4-customer increase to 24, a large standard error means 24 is only a little way above 20 in standard errors, leaving a big tail of ordinary luck. A small standard error puts that exact same 24 many standard errors out in the tail, giving a tiny p-value.
Even when the gap to 24 stays the same, changing the size of one standard error changes how many standard errors out 24 is and how much of the tail goes past it.
4
Comparing the p-Value to Alpha and Stating a Conclusion
To decide whether a p-value is small enough to rule out ordinary luck, we compare it to a cutoff chosen ahead of time called the significance level, α (usually α=0.05). Comparing our one-sided (p=0.04) and two-sided (p=0.08) results against α=0.05 shows both possible outcomes, and why failing to reject H0 never proves H0 is true.
Comparing the p-Value to Alpha and Stating a Conclusion
Text solution:
Reject H0 when p<α: For the one-sided test (Ha:μ>20), the p-value falls below the 0.05 cutoff, so pure luck is hard to believe and we have convincing evidence that the sign increases average traffic above 20 customers per hour.
p=0.04<α=0.05⟹Reject H0 (convincing evidence for Ha)
Fail to reject H0 when p≥α: For the two-sided test (Ha:μ=20), the p-value is at or above the 0.05 cutoff, so a change at least this size happens 8% of the time by luck and we do not have convincing evidence that the sign changes average traffic.
p=0.08≥α=0.05⟹Fail to reject H0 (not enough evidence for Ha)
5
Common p-Value Traps and Recap
Even when we calculate a p-value and compare it to α properly, we have to avoid two common traps: reading the p-value backward as the probability that H0 is true, or assuming a tiny p-value automatically means a large, practically useful effect.
Common p-Value Traps and Recap
p=0.04
a 4% chance that H0 is true?
We calculate a p-value by assuming H0 is 100% true from the start, so the condition goes in only one direction:
p-value=Measures how surprising the data isunder pure luckProbability of gettingdata at least this extreme,ifH0 is true=Common trapProbability that H0 is true,giventhis data
Key concepts
To test a sample average xˉ against a baseline H0:μ=20, start by assuming H0 is true and see how far out the sample result (xˉ=24) landed in the tail. Never count just the single exact outcome 24.0, because any single exact number has a tiny probability even right at the center. In a simulation, count all the dots at 24 and beyond. With a formula, find how much the sample mean typically varies using Standard Error=ns=96=2, and then convert the gap into standard errors using t=Standard Errorxˉ−μ=224−20=2 with df=n−1=8. Check Ha to see which tails to count: use one tail for a one-sided test (Ha:μ>20 gives p=1,00040=0.04), and double it to count equally extreme results in both tails for a two-sided test (Ha:μ=20 counts ≥24 and ≤16, giving p=1,00080=0.08). Finally, compare p to α=0.05. If p<α, reject H0 (convincing evidence for Ha). If p≥α, fail to reject H0 (not enough evidence for Ha, which never proves H0 is true). Always remember that p is the chance of getting data at least this extreme if H0 is true, not the chance that H0 is true and not a measure of how big the effect is in practice.
6
Practice
1
A bakery's loaves have historically weighed an average of μ=500 grams. After adjusting the dough mixer, the baker weighs a random sample of loaves to test H0:μ=500 against Ha:μ>500 and gets a sample mean of xˉ=506.0 grams. In a computer simulation of 1,000 random samples assuming μ=500,3 dots land at exactly 506.0 grams and 29 dots land above 506.0 grams. What is the simulated p-value, and why don't we count only the 3 dots at 506.0?
Watch out: Counting only the 3 dots at 506.0 gives 1,0003=0.003, or counting only the 29 dots above 506.0 gives 1,00029=0.029. We don't count only the 3 dots at 506.0 because when many outcomes are possible, any single exact number has a tiny probability, even right at the center of the distribution, so a p-value always counts our sample result and everything even more extreme in the direction of Ha.
Check which dots represent pure luck giving a sample average at least as high above 500 grams as the baker's sample.
To measure how often random luck gives a sample average at least this far from 500, we include both the dots at 506.0 and the dots above 506.0:
(Watch out: Counting only the 3 dots at 506.0 gives 1,0003=0.003, or counting only the 29 dots above 506.0 gives 1,00029=0.029. We don't count only the 3 dots at 506.0 because when many outcomes are possible, any single exact number has a tiny probability, even right at the center of the distribution, so a p-value always counts our sample result and everything even more extreme in the direction of Ha.)
p-value=1,0003+29=1,00032=0.032 (or 3.2%)
2
A city bus route has historically taken an average of μ=30 minutes. After retiming the traffic lights, a planner tests H0:μ=30 against the two-sided alternative Ha:μ=30 at α=0.05 and gets a sample average of xˉ=27 minutes. In 1,000 simulated samples assuming μ=30,35 dots land at 27 minutes or lower and 35 dots land at 33 minutes or higher. Find the p-value and state the conclusion in context.
Watch out: Counting only the left tail where xˉ=27 landed gives p=1,00035=0.035<0.05, which leads to the wrong decision of rejecting H0 because it ignores the equally extreme right tail required by Ha:μ=30.
Look at the sign in Ha:μ=30 to decide which outcomes are at least 3 minutes away from 30 before comparing p to α=0.05.
Because Ha:μ=30 is two-sided, any sample mean at least 3 minutes away from 30 in either direction (27 or lower, or 33 or higher) is at least as extreme as the sample result:
(Watch out: Counting only the left tail where xˉ=27 landed gives p=1,00035=0.035<0.05, which leads to the wrong decision of rejecting H0 because it ignores the equally extreme right tail required by Ha:μ=30.)
p-value=1,00035+35=1,00070=0.07 (or 7%)
Because p=0.07≥0.05, we fail to reject H0; we do not have convincing evidence that retiming the traffic lights changes the average trip time from 30 minutes.
3
Students at a tutoring center have historically averaged μ=75 points on a placement test. A random sample of n=16 students using a new study guide averages xˉ=79 points with a sample standard deviation of s=8 points. (a) Assuming H0:μ=75 is true, find the standard error, the t-statistic, and the degrees of freedom. (b) In this t-distribution, the area in the right tail beyond your t-statistic is 0.032. Using α=0.05, find the p-value and decision for a one-sided test (Ha:μ>75) versus a two-sided test (Ha:μ=75).
Watch out: Dividing s by n=16 instead of 16 gives a standard error of 168=0.5 and t=8, or dividing the 4-point difference directly by s=8 without finding the standard error gives t=84=0.5.
For (a), divide s by n first to find how much a 16-student average typically varies, then measure the 4-point gap in those standard-error units. For (b), check how the two-sided p-value relates to the one-tail area of 0.032.
(a) Divide s=8 by 16 to get the standard error, then divide the 4-point increase by the standard error:
(Watch out: Dividing s by n=16 instead of 16 gives a standard error of 168=0.5 and t=8, or dividing the 4-point difference directly by s=8 without finding the standard error gives t=84=0.5.)
Standard Errortdf=ns=168=2 points,=279−75=2,=16−1=15
(b) For the one-sided test (Ha:μ>75), we use the single right-tail area: p=0.032<0.05, so we reject H0 and find convincing evidence that the study guide increases average scores. For the two-sided test (Ha:μ=75), we count both tails:
(Watch out: Forgetting to double the tail area for Ha:μ=75 leaves p=0.032 and wrongly rejects H0.)
Two-sided p-value=2(0.032)=0.064
Because p=0.064≥0.05, we fail to reject H0 and do not have convincing evidence that the study guide changes average scores.
4
Historically, a greenhouse's tomato plants yield an average of μ=30 tomatoes. A grower tests a new fertilizer on n=4 plants and gets a sample mean of xˉ=33 tomatoes with s=6 tomatoes, giving a two-sided p-value of p=0.39. The grower says, "Because p=0.39 is way above 0.05, we proved the fertilizer has zero effect." Find the standard error and explain why the grower's claim is wrong.
Calculate Standard Error=ns for n=4 plants and compare that typical luck variation to the 3-tomato gain.
(Watch out: Treating p≥0.05 as proof that H0:μ=30 is true confuses not having enough evidence against H0 with proving H0 is true.)
Standard Error=ns=46=3 tomatoes
Failing to reject H0 never proves H0 is true. With only n=4 plants, the sample average typically varies by ±3 tomatoes per plant just by luck, so a real improvement of 2 or 3 tomatoes per plant is only 1 standard error or less above 30 and cannot be separated from ordinary plant-to-plant luck in such a small sample.
5
Critique two claims about a study testing whether listening to whale songs overnight changes resting heart rate (H0:μ=70 bpm,Ha:μ=70 bpm): (a) A small study gets p=0.03, and a blogger writes, "There is only a 3% chance the null hypothesis is true, so there is a 97% chance whale songs change heart rate." (b) A huge study of 100,000 people finds xˉ=69.95 bpm with p=0.001, and a headline claims this tiny p-value proves a huge, medically important reduction in heart rate.
For (a), check what was assumed to be 100% true when calculating p=0.03. For (b), think about what dividing by 100,000 does to the standard error when xˉ is only 0.05 bpm below 70.
(a) (Watch out: Subtracting p=0.03 from 1 to get a 97% chance H0 is false flips the condition backward: it confuses the probability of the data given H0 with the probability of H0 given the data.) A p-value is the probability of getting data at least this extreme ifH0 is true, not the probability that H0 is true given the data; a result this extreme happens 3 times in 100 by pure luck even when whale songs do nothing at all.
(b) (Watch out: Treating a tiny p-value like p=0.001 as proof of a large real-world effect ignores sample size.) A tiny p-value only gives strong evidence that the true effect is not zero; with 100,000 people, the standard error ns is so tiny that even a practically meaningless 0.05 bpm difference lands several standard errors from 70.