Hypothesis testing helps you evaluate claims about averages, proportions, and patterns using sample data. However, a correct formula does not guarantee a correct conclusion. This guide works through 22 connected examples, explains the reasoning behind each test, and checks the shortcuts that can quietly change an answer.
You will learn how to choose a test, calculate its statistic, interpret its p-value, and report the result clearly. In addition, you will see why early rounding, weak study design, and incorrect degrees of freedom can undermine an otherwise polished solution.
Hypothesis testing: the foundations
A statistical hypothesis describes a population or a probability model. For example, a factory might claim that its cables have a mean breaking strength of 5,000 pounds. A random sample gives an estimate, but sampling variation prevents you from treating that estimate as the exact population value.
The null hypothesis, H0, specifies the benchmark you test. By contrast, the alternative hypothesis, H1, describes the departure you want to detect. Both statements concern population parameters, not the sample mean you already observed.
| Symbol | Meaning | Example |
|---|---|---|
| μ | Population mean | Mean cable strength |
| x̄ | Sample mean | Average strength in 64 tested cables |
| σ and s | Population and sample standard deviation | Variation in strength |
| p and p̂ | Population and sample proportion | Share of plants that comply |
| α | Chosen Type I error threshold | 0.05 |
| β | Type II error probability at a specified alternative | Probability of missing a particular change |
| 1 − β | Power at that alternative | Probability of detecting that change |
Choose the direction before looking at the result
| Question | Alternative | Rejection direction |
|---|---|---|
| Has the mean changed? | μ ≠ μ₀ | Both tails |
| Has the mean increased? | μ > μ₀ | Right tail |
| Has the mean decreased? | μ < μ₀ | Left tail |
For a directional claim, write the full null as an inequality when appropriate. As an illustration, H0: μ ≤ 80 competes with H1: μ > 80. The boundary μ = 80 supplies the reference distribution for the one-sided calculation.
Do not choose a one-sided test simply because the observed difference points in a convenient direction. Instead, tie the direction to the research question before analyzing the data. This choice determines which outcomes count as evidence against the null.
A six-step procedure that works across tests
- Define the population, outcome, and parameter.
- State the null and alternative hypotheses.
- Choose α and the analysis method before inspecting the result.
- Check independence, sampling, and distributional assumptions.
- Calculate the statistic and p-value, retaining full precision.
- Report the estimate, uncertainty, decision, and practical limitation.
A p-value measures how incompatible the observed statistic is with the null model, using outcomes at least as extreme in the chosen direction. However, it does not give the probability that the null hypothesis is true. Nor does it measure the economic or scientific importance of the effect.
Method reference: American Statistical Association: statement on p-values.
Which test should you use?
| Data and question | Usual starting method | Main qualification |
|---|---|---|
| One mean; population σ known | One-sample z-test | Normal population or suitable approximation |
| One mean; σ unknown | One-sample t-test | Independent observations; assess skew and outliers |
| One binary proportion | Proportion z-test or exact binomial test | Check expected successes and failures under H₀ |
| Two independent means | Welch two-sample t-test | Accounts for unequal variance estimates |
| Two means with justified equal variances | Pooled t-test | Requires a defensible equal-variance assumption |
| Before/after measures on the same units | Paired t-test on differences | Analyze pairing, not independent groups |
| Two independent proportions | Pooled two-proportion z-test under equality | Adequate expected counts |
| One categorical distribution | Chi-square goodness-of-fit test | Valid expected counts and degrees of freedom |
| Association in a contingency table | Chi-square independence test | Consider exact or simulation methods for small tables |
Importantly, a sample size above 30 does not magically make every method valid. A large sample can improve an approximation, but it cannot repair dependent observations or a biased sample. Likewise, knowing a historical standard deviation differs from estimating it using the same sample.
Examples 1–9: one-sample hypothesis testing
Example 1. Type I error, Type II error, and confidence
Suppose a manufacturer tests whether a process meets its benchmark. A Type I error occurs when the test rejects a true null hypothesis. Conversely, a Type II error occurs when the test fails to reject a false null.
| Decision | Null is true | Specified alternative is true |
|---|---|---|
| Reject H₀ | Type I error: α | Correct detection: power |
| Do not reject H₀ | Correct non-rejection | Type II error: β |
At α = 0.05, a correctly calibrated procedure limits its long-run false-rejection rate under the null to 5%, or approximately 5% for an approximate test. This does not mean a particular rejected result has a 5% chance of being wrong. For discrete tests, the actual rate may fall below the nominal threshold.
Similarly, a 95% confidence procedure covers the fixed population parameter in 95% of repeated samples under its assumptions. It does not assign a 95% probability to the null hypothesis. Therefore, confidence and significance describe procedures, not certainty about a single claim.
Method reference: NIST: confidence limits for the mean.
Example 2. Does a coin appear balanced?
A coin produces 9 heads in 20 independent tosses. Test H0: p = 0.50 against H1: p ≠ 0.50. Because the sample is small and the outcome is binary, an exact binomial test provides a direct calculation.
p-value for 9 heads = 0.823803
The result gives little evidence against a balanced coin. However, it does not establish perfect fairness. Many biased coins can still produce 9 heads in a short sequence.
For comparison, 4 heads in 20 tosses gives a two-sided exact p-value of 0.011818. Thus, that result rejects fairness at 5%, but not at 1%. The distinction illustrates why an unusual sample needs a specified decision threshold.
Method reference: SciPy: exact binomial testing.
Example 3. Translate a cable-strength question into hypotheses
A producer considers three different questions about a 5,000-pound benchmark. Although each question uses the same measurement, the appropriate alternative changes. Consequently, each version has a different rejection region.
| Purpose | Null | Alternative |
|---|---|---|
| Detect any departure | μ = 5,000 | μ ≠ 5,000 |
| Find strength above the benchmark | μ ≤ 5,000 | μ > 5,000 |
| Find inadequate mean strength | μ ≥ 5,000 | μ < 5,000 |
Mean strength alone does not establish product safety. For example, a process may meet its mean target while producing an unacceptable lower tail of weak cables. Therefore, a real quality program needs variation and specification information as well.
Example 4. Test mean cable strength
In a random sample, 64 cables have x̄ = 5,100 pounds and s = 480 pounds. Test whether the population mean differs from 5,000 at α = 0.05. Since the problem supplies a sample standard deviation, a t-test is the more direct analysis.
t = (x̄ − μ₀) / SE = (5,100 − 5,000) / 60 = 1.6667
df = 63; two-sided p-value = 0.1005
Because 0.1005 exceeds 0.05, fail to reject the null. The sample does not provide enough evidence of a mean difference at the chosen threshold. Nevertheless, the estimate remains 100 pounds above the benchmark.
The large-sample z approximation gives p ≈ 0.0956 and reaches the same 5% decision. However, agreement here does not justify using z whenever n exceeds 30. The t procedure explicitly reflects uncertainty in the estimated standard deviation.
Method reference: NIST: testing a process mean.
Example 5. Rejection regions and confidence intervals are related, but different
Using the textbook z approximation, reject when the observed sample mean lies more than 1.96 standard errors from 5,000. Therefore, the non-rejection interval for the sample mean runs from 4,882.4 to 5,117.6 pounds. Its center is the null value.
Approximate 95% confidence interval for μ: 5,100 ± 1.96(60) = [4,982.4, 5,217.6]
In contrast, the confidence interval centers on the observed sample mean. Both calculations express the same two-sided decision when you use matching methods. The more appropriate t-based confidence interval is approximately [4,980.1, 5,219.9] pounds.
Example 6. Has the mean weight increased?
A normally distributed population has a known standard deviation of 10 kg. In this example, a sample of 25 recruits has an average weight of 85 kg. Test H0: μ ≤ 80 against H1: μ > 80 at α = 0.01.
z = (85 − 80) / 2 = 2.50
p-value = P(Z ≥ 2.50) = 0.006210
Since 0.006210 is below 0.01, reject the null. The sample supports a mean above 80 kg under the stated assumptions. However, the result does not mean there is a 99% probability that this conclusion is correct.
The precise critical sample mean is 80 + 2.326348 × 2 = 84.6527 kg. This boundary matters later when we calculate power. In particular, the observed mean of 85 kg is not the rejection cutoff.
Example 7. Does a package contain less than advertised?
Nine detergent packages have a mean weight of 18 ounces and a sample standard deviation of 3 ounces. The advertised mean is 20 ounces. Assuming independent measurements from a normal population, test for underfilling at the 5% level.
t = (18 − 20) / (3 / √9) = −2.00
df = 8; one-sided p-value = 0.04026
The sample provides evidence of a mean below 20 ounces at 5%. At 1%, however, the same result does not reject the null. Neither decision establishes whether every individual package is underweight.
With only nine observations, the normality assumption deserves attention. A severe outlier can strongly influence both the mean and standard deviation. Consequently, inspect the raw weights before treating the numerical result as reliable.
Example 8. Does a dosage-compliance rate differ from 90%?
An educational hospital example records 85 compliant doses in 100 independent checks. Test H0: p = 0.90 against H1: p ≠ 0.90. The null standard error uses 0.90, not the sample estimate of 0.85.
SE₀ = √[0.90(0.10) / 100] = 0.03
z = (0.85 − 0.90) / 0.03 = −1.6667
Two-sided normal-approximation p-value = 0.09558
| Significance level | Decision with the stated two-sided test | Reason |
|---|---|---|
| 1% | Do not reject | 0.09558 > 0.01 |
| 5% | Do not reject | 0.09558 > 0.05 |
| 10% | Reject | 0.09558 < 0.10 |
An exact two-sided binomial calculation gives p ≈ 0.09628, which preserves these decisions. By contrast, a pre-specified one-sided test for deterioration gives a different p-value because it asks a different question. Specify that question before counting the doses.
Practical quality concerns need not disappear when a test fails to reject. For example, the observed shortfall may still trigger investigation under an operational policy. Statistical evidence and a quality-control action threshold serve different purposes.
Example 9. Do more than 80% of plants comply?
Among 64 plants, 56 meet the relevant standard. Test H0: p ≤ 0.80 against H1: p > 0.80 at α = 0.05. First retain the exact sample proportion.
SE₀ = √[0.80(0.20) / 64] = 0.05
z = (0.875 − 0.80) / 0.05 = 1.50
One-sided approximate p-value = 0.06681
Therefore, fail to reject at 5%. The exact binomial p-value is approximately 0.08441, which reaches the same decision. Rounding 0.875 to 0.88 prematurely produces z = 1.60 and understates the approximate p-value.
Now imagine a larger sample with a similar compliance rate. A hypothetical proportion of 0.88 at n = 124 gives SE ≈ 0.03592 and z ≈ 2.2271. However, exactly 0.88 × 124 = 109.12 successes is impossible.
A realizable example uses 109 compliant plants out of 124, or approximately 87.90%. Its uncorrected z statistic is about 2.2001, with p ≈ 0.01390. Thus, a larger sample can detect a similar effect more clearly, although it never guarantees support for the claim.
Examples 10–12: Type II error and statistical power
A significance test can miss a real difference. Therefore, a useful design asks how often the planned test would detect an effect that matters. That probability depends on the true effect, sample size, variability, and significance level.
Method reference: Penn State: power and sample size considerations.
Example 10. Calculate β using the actual decision rule
Return to the recruit example: σ = 10 kg, n = 25, and a right-sided test at α = 0.01. We reject when x̄ exceeds 84.6527 kg. For any specified true mean μ, calculate the chance that the sample mean remains below that boundary.
Power(μ) = 1 − Φ[(84.6527 − μ) / 2]
Here Φ denotes the standard normal cumulative distribution function. For example, if the true mean is 85 kg, β ≈ 0.4311 and power ≈ 0.5689. In other words, the procedure detects that particular increase in about 56.9% of repeated samples.
At μ = 80, the 99% non-rejection probability is not a Type II error rate because the null is true. Similarly, the 1% rejection probability at that boundary represents the Type I error rate. Keeping these labels separate prevents a common conceptual mistake.
| True mean (kg) | Non-rejection probability | Rejection probability |
|---|---|---|
| 80 | 0.9900 | 0.0100 |
| 82 | 0.9076 | 0.0924 |
| 84 | 0.6279 | 0.3721 |
| 85 | 0.4311 | 0.5689 |
| 86 | 0.2503 | 0.7497 |
| 87 | 0.1203 | 0.8797 |
| 88 | 0.0471 | 0.9529 |
| 90 | 0.0038 | 0.9962 |
Example 11. Read an operating characteristic curve
An operating characteristic, or OC, curve plots the probability of non-rejection against possible true parameter values. In this right-sided example, the curve declines as the mean rises. Consequently, large positive departures become harder to miss.
The supplied worked solution instead uses 85 kg as the cutoff in its β calculations. That threshold gives a null rejection probability of about 0.00621, not 0.01. It describes a different test, so its power values cannot represent the stated 1% procedure exactly.
For instance, the 85 kg cutoff produces power of 0.50 at a true mean of 85 kg. The correct 1% cutoff produces approximately 0.5689. This discrepancy comes from the decision boundary, not a disagreement between probability tables.
Example 12. Plot power and plan the sample size
Power equals one minus the OC curve at each alternative. As a result, the two curves mirror each other vertically and sum to one. For this design, a true mean of 88 kg gives approximately 95.29% power.
As an original extension, suppose you want 80% power to detect a 5 kg increase while keeping α = 0.01. For this known-variance normal model, solve the following planning formula. Then round the sample size upward.
n ≥ [(2.32635 + 0.84162) × 10 / 5]² ≈ 40.145
Required sample size: n = 41
This calculation assumes a fixed design and the stated known variability. If σ is uncertain, use a t-based planning method or examine several plausible values. Better measurement and a stronger design can also improve power; adding observations is not the only option.
Examples 13–16: comparing two independent groups
Two-group comparisons measure a difference rather than a single population value. Before calculating anything, determine whether the groups are independent or paired. For example, measuring the same people twice requires an analysis of within-person differences.
The general two-mean formula
ν = (s₁²/n₁ + s₂²/n₂)² / [(s₁²/n₁)²/(n₁−1) + (s₂²/n₂)²/(n₂−1)]
Welch’s test uses the displayed standard error and degrees of freedom without assuming equal population variances. If equal variances are justified, a pooled t-test uses a weighted variance estimate instead. Both approaches need appropriate sampling and independent groups.
Method reference: NIST: two-sample t-test for equal means.
Example 13. Compare two lightbulb brands
An educational purchasing example tests 100 bulbs from each of two equally priced brands. Brand 1 has a mean lifetime of 980 hours and s = 80 hours. Meanwhile, Brand 2 has a mean of 1,010 hours and s = 120 hours.
SE = √(80²/100 + 120²/100) = 14.4222 hours
t = −30 / 14.4222 = −2.0801
Welch df ≈ 172.48; two-sided p ≈ 0.03899
Therefore, reject equal means at 5%, but not at 1%. The textbook normal approximation gives p ≈ 0.03751 and the same decisions. Brand 2 has the higher observed average, but it also has greater observed variability.
A purchasing decision should include more than the significance label. For example, the 30-hour estimated advantage is about 3.06% of Brand 1’s sample mean lifetime. Warranty terms, early failures, and replacement costs may matter more than this average difference.
Example 14. Compare two groups of admission scores
The first group has n₁ = 64, x̄₁ = 640, and s₁ = 20. By comparison, the second has n₂ = 81, x̄₂ = 650, and s₂ = 40. Test whether the first population mean is lower at α = 0.01. The photographed question mentions 65 applicants, but its displayed calculation uses 64; this reconstruction follows the calculation’s n₁ = 64.
t = (640 − 650) / 5.0993 = −1.9610
Welch df ≈ 123.00; one-sided p ≈ 0.02607
The evidence does not meet the 1% threshold. Nevertheless, the estimate remains a 10-point difference, and a non-rejection does not show that the populations are equivalent. A test of score means also cannot establish that one group of people is generally “inferior.”
Under the textbook z approximation, the 1% lower rejection boundary for the sample difference is about −11.8627 points. The observed −10 points does not cross it. Using Welch’s reference distribution changes the boundary slightly, but not this conclusion.
Example 15. Compare two toothpaste groups with equal variances
Two independent groups each contain 21 people. Their mean cavity counts are 25 and 23, with sample standard deviations of 5 and 4. For this exercise, assume normal populations and equal population variances.
SE = √[20.5(1/21 + 1/21)] = 1.3973
t = (25 − 23) / 1.3973 = 1.4314
df = 40; two-sided p ≈ 0.1601
At 5%, fail to reject equal mean cavity counts. This does not demonstrate that the products perform identically. Moreover, actual cavity counts are discrete, so a real study should examine whether the normal-model approximation makes sense.
The photographed calculation rounds intermediate quantities enough to report a slightly different statistic. Retaining full precision gives t ≈ 1.4314. Although the decision stays the same here, the cleaner calculation improves reproducibility.
Example 16. Compare compliance proportions across regions
Region 1 has 30 compliant plants out of 60, while Region 2 has 16 out of 40. Test H0: p₁ ≤ p₂ against H1: p₁ > p₂. Under the boundary null of equal proportions, pool the successes to estimate the common rate.
SE₀ = √[0.46(0.54)(1/60 + 1/40)] = 0.101735
z = (0.50 − 0.40) / 0.101735 ≈ 0.9830
One-sided p-value ≈ 0.1628
Neither a 5% nor a 10% threshold leads to rejection. The observed difference is 10 percentage points, but the sample gives limited precision. Thus, a noticeable point estimate can coexist with weak statistical evidence.
For a confidence interval on the difference, the usual unpooled standard error differs from the pooled null standard error. Consequently, do not automatically reuse the testing standard error in every interval formula. The estimation question and the null-model question require distinct reasoning.
Examples 17–22: chi-square hypothesis testing
Chi-square methods compare observed counts with counts expected under a model. Goodness of fit examines one categorical distribution. By contrast, an independence test examines the relationship between two categorical variables.
Each contribution grows when an observed count departs from its expectation. Because the discrepancies enter as squares, both excesses and shortfalls increase the statistic. Therefore, these tests usually reject in the right tail even when departures occur in either direction.
Example 17. Does the distribution of sick days match workforce shares?
An illustrative workforce has age-group shares of 30%, 40%, 20%, and 10%. A total of 100 sick days produces the following counts. Under a model of equal sick-day rates per worker and comparable exposure, the workforce shares determine the expected distribution.
| Age group | Observed days | Expected days | Contribution |
|---|---|---|---|
| 20–29 | 26 | 30 | 0.5333 |
| 30–39 | 37 | 40 | 0.2250 |
| 40–49 | 24 | 20 | 0.8000 |
| 50+ | 13 | 10 | 0.9000 |
At 5%, the result does not reject the specified distribution. However, days from the same employee may cluster rather than act as independent categorical draws. Without information about repeated absences, the simple multinomial model may overstate the effective information.
An improved analysis could use employee-level counts and exposure time. For example, workers with different schedules contribute different opportunities to record an absence. The arithmetic above answers a narrower question than whether age causes sick leave.
Example 18. Pool rare categories without rounding expectations
Four categories have observed counts of 3, 5, 6, and 3. Their expected counts are 6, 6, 3, and 2. Because the last two expectations are small, the exercise combines those categories before calculating the statistic.
| Category | Observed | Expected | Contribution |
|---|---|---|---|
| A | 3 | 6 | 1.5000 |
| B | 5 | 6 | 0.1667 |
| C + D | 9 | 5 | 3.2000 |
Therefore, reject at 10%, but not at 5%, using this pooled approximation. The analysis assumes the expected proportions were specified independently of these observations. If the data also estimated model parameters, the degrees of freedom would require further adjustment.
Pooling should follow a meaningful, pre-specified grouping rule. Otherwise, trying many combinations can turn the analysis into a search for a convenient p-value. Also, losing categories can hide the particular pattern that motivated the original question.
Example 19. Does the number of admissions follow a binomial model?
A hypothetical sample of 100 applicants records how many of three colleges accepted each person. The proposed model assumes three independent decisions with the same acceptance probability of 0.40. Under those assumptions, the acceptance count follows Binomial(3, 0.40).
Eₖ = 100 × P(X = k)
| Acceptances | Observed applicants | Model probability | Expected applicants |
|---|---|---|---|
| 0 | 25 | 0.216 | 21.6 |
| 1 | 34 | 0.432 | 43.2 |
| 2 | 31 | 0.288 | 28.8 |
| 3 | 10 | 0.064 | 6.4 |
At 5%, fail to reject the stated binomial model. However, preserve expected counts as decimals. Rounding them to 22, 43, 29, and 6 changes the statistic to approximately 5.0974 without adding information.
The deeper issue is the model itself. College decisions may correlate because the same applicant’s qualifications affect all three decisions. Likewise, colleges may have different acceptance probabilities; either feature breaks the simple binomial assumptions.
If you estimate the probability from these applicants, the estimate becomes 126/300 = 0.42. That creates a different fitted-model test and normally consumes one additional degree of freedom. Consequently, distinguish a specified probability from a probability estimated using the same data.
Method reference: NIST: chi-square goodness-of-fit procedure.
Example 20. A grouped normality test that needs repair
The photographed score example groups 100 observations into five classes. It estimates the mean and standard deviation from class midpoints. Those summaries are approximations because the raw individual scores are unavailable.
| Score class | Frequency | Midpoint | Frequency × midpoint | Frequency × midpoint² |
|---|---|---|---|---|
| 251–350 | 3 | 300 | 900 | 270000 |
| 351–450 | 25 | 400 | 10000 | 4000000 |
| 451–550 | 50 | 500 | 25000 | 12500000 |
| 551–650 | 20 | 600 | 12000 | 7200000 |
| 651–750 | 2 | 700 | 1400 | 980000 |
| Total | 100 | 49300 | 24950000 |
s ≈ √[(24,950,000 − 100 × 493²) / 99] ≈ 80.72
The exercise pools the first two classes and the last two classes because of low expected tail counts. Only three categories remain. However, it then compares its statistic with a chi-square reference using two degrees of freedom.
After pooling: k = 3; estimated normal parameters: q = 2
Therefore: df = 3 − 1 − 2 = 0
A defensible repair needs more information or a different analysis. For example, use the raw scores with a suitable normality diagnostic, fit grouped data with a method that matches its reference distribution, or calibrate the complete fitting-and-binning procedure by simulation. With only these summaries, the original p-value cannot simply survive the pooling step.
This example also illustrates why every expected category must cover the full model support. Open-ended tail bins account for probability beyond the observed score range. Ignoring that probability can make the expected counts sum to less than the sample size.
Method reference: NIST: binning, parameter fitting, and chi-square degrees of freedom.
Example 21. Are age group and sex associated among recorded cases?
An illustrative table describes 150 recorded heart-attack cases. We test whether age group and sex are independent within this case sample at α = 0.01. Crucially, the table contains no counts for people who did not have a recorded event.
| Age group | Male cases | Female cases | Row total |
|---|---|---|---|
| Under 30 | 10 | 10 | 20 |
| 30–60 | 50 | 30 | 80 |
| Over 60 | 30 | 20 | 50 |
| Total | 90 | 60 | 150 |
Eunder 30, male = 20 × 90 / 150 = 12
df = (rows − 1)(columns − 1) = (3 − 1)(2 − 1) = 2
| Age group | Expected male cases | Expected female cases |
|---|---|---|
| Under 30 | 12 | 8 |
| 30–60 | 48 | 32 |
| Over 60 | 30 | 20 |
Thus, fail to reject independence in this case sample at 1%. This is not evidence that age and sex have no relationship with heart-attack risk. Risk comparisons require population denominators, exposure information, and an appropriate study design.
For example, 90 male cases and 60 female cases do not establish a higher male risk by themselves. Different population sizes could produce the same counts under equal risks. The distinction between case composition and population incidence is essential.
Example 22. A small worker table and continuity correction
A sample of 37 workers over age 65 gives the following table. Test independence between the recorded age category and sex at α = 0.10. The example groups workers into ages 66–70 and 71 or older.
| Age group | Male | Female | Total |
|---|---|---|---|
| 66–70 | 17 | 9 | 26 |
| 71+ | 3 | 8 | 11 |
| Total | 20 | 17 | 37 |
First calculate the expected counts from the exact margins. They are approximately 14.0541, 11.9459, 5.9459, and 5.0541. Although none is an integer, that is entirely normal: an expectation is an average over possible samples.
Yates-corrected χ² ≈ 3.1164; p ≈ 0.07751
Two-sided Fisher exact p ≈ 0.06887
| Method | p-value | Decision at 10% | Decision at 5% |
|---|---|---|---|
| Pearson without correction | 0.03349 | Reject | Reject |
| Yates continuity correction | 0.07751 | Reject | Do not reject |
| Fisher exact, two-sided | 0.06887 | Reject | Do not reject |
All three methods reject at the exercise’s 10% threshold. However, they do not agree at 5%, which makes the method choice consequential. Specify the analysis before seeing which p-value produces the preferred conclusion.
The photographed solution rounds the expected counts to 14, 12, 6, and 5 before applying its correction. Retaining the exact values gives 3.1164 rather than the reported value near 3.25. This is another reason to round only the final presentation.
Finally, these counts describe the age composition of sampled workers. Without denominators for all older adults, they cannot establish which group has a higher probability of continuing to work. A claim about employment rates needs data beyond this table.
Method reference: SciPy: contingency-table calculations and Yates correction.
Method reference: SciPy: Fisher exact test.
What most hypothesis testing guides leave out
The examples reveal several problems that routine formula lists rarely discuss together. Some errors change a numerical answer, while others change the question itself. Therefore, a calculation audit should examine both arithmetic and interpretation.
| Issue in the supplied material | More careful treatment | Why it matters |
|---|---|---|
| “Accept the null” language | Say “fail to reject” unless a separate equivalence design supports more | Insufficient evidence does not prove equality |
| Population σ replaced by sample s | Use t where appropriate; label z approximations | Uncertainty in s changes the reference distribution |
| 56/64 rounded to 0.88 early | Keep 0.875 until the final display | z changes from 1.60 to 1.50 |
| A sample rate of exactly 0.88 at n = 124 | Use a feasible integer count or label a hypothetical rate | The implied count 109.12 cannot occur |
| Observed 85 kg used as a 1% test cutoff | Use 84.6527 kg | The original OC curve represents a different decision rule |
| Expected admission counts rounded to integers | Keep 21.6, 43.2, 28.8, 6.4 | χ² changes from about 5.0974 to 4.6875 |
| Five original bins retained in a pooled normality df calculation | Count the three retained bins and the two fitted parameters | The usual positive-df chi-square reference is unavailable |
| Expected counts in a small table rounded before correction | Keep exact row × column / total values | Corrected χ² becomes 3.1164 |
| Case counts interpreted as population risk | Require appropriate denominators | Composition is not incidence |
| A worker-only table interpreted as employment rates | Include the relevant nonworking population | Selection limits the question you can answer |
Why more data can make a tiny effect significant
The standard error of a mean decreases with the square root of sample size. Consequently, multiplying n by four halves that standard error when variability stays the same. A fixed nonzero difference then produces a test statistic roughly twice as large.
For an original illustration, suppose σ = 10 and the sample mean is only one unit above the null. At n = 25, z = 0.5 and the two-sided p-value is about 0.6171. By contrast, at n = 2,500, the same one-unit difference gives z = 5 and p ≈ 0.000000573.
The estimated effect remains one unit in both examples. Therefore, a much smaller p-value does not automatically imply a larger benefit. Report the effect in meaningful units and compare it with a practical threshold.
Why repeated testing changes the false-positive problem
Suppose you run 20 independent tests, each at α = 0.05, and every null is true. The probability of avoiding all false positives is 0.95²⁰. Consequently, the probability of at least one false positive reaches approximately 64.15%.
For 20 independent true-null tests: 1 − 0.95²⁰ ≈ 0.6415
This calculation assumes independence and exact 5% test sizes. Correlated outcomes can change the probability, but multiple comparisons still deserve an explicit plan. For example, distinguish confirmatory hypotheses from exploratory follow-up questions before you start testing.
Why a mean test does not establish equivalence
A large p-value can arise from a small effect, high variability, or limited sample size. Thus, non-rejection alone cannot show that two options are practically equivalent. An equivalence analysis instead begins with a justified margin for differences small enough to disregard.
For the lightbulb example, a buyer might decide that a difference under 10 hours has no operational importance. That margin creates a new question and a different inferential procedure. The ordinary equal-means test does not answer it automatically.
How to report a hypothesis test clearly
A useful result combines the estimate with its uncertainty and context. Rather than writing only “significant,” identify what changed and by how much. Also state the assumptions that determine how far the conclusion can travel.
- Question: identify the parameter and comparison.
- Design: describe sampling, group structure, and independence.
- Method: name the test and whether it is one-sided or two-sided.
- Result: provide the estimate, statistic, degrees of freedom, and p-value.
- Uncertainty: add a matching confidence interval where appropriate.
- Meaning: explain the practical size and the main limitation.
A compact verification recipe
Independent recalculation helps detect transcription and rounding errors. The following Python example reproduces several distinctive results from this guide. In addition, it makes the precise test choices visible.
from scipy.stats import norm, t, binomtest, chisquare
from scipy.stats import chi2_contingency, fisher_exact
# Cable mean: sample standard deviation, two-sided t-test
print(2 * t.sf(abs((5100 - 5000) / (480 / 64**0.5)), df=63))
# Compliance: preserve the exact sample proportion
z = (56 / 64 - 0.8) / (0.8 * 0.2 / 64)**0.5
print(z, norm.sf(z))
print(binomtest(56, 64, 0.8, alternative="greater").pvalue)
# Power: use the decision boundary, not the observed mean
cutoff = 80 + norm.ppf(0.99) * (10 / 25**0.5)
print(cutoff, norm.sf((cutoff - 85) / 2))
# Goodness of fit: do not round expected counts
print(chisquare([25, 34, 31, 10], [21.6, 43.2, 28.8, 6.4]))
# Small contingency table: state the method
observed = [[17, 9], [3, 8]]
print(chi2_contingency(observed, correction=True))
print(fisher_exact(observed, alternative="two-sided"))Frequently asked questions about hypothesis testing
What does a p-value above 0.05 mean?
It means the result does not cross a 5% rejection threshold for the selected test. However, it does not prove that the null is true or that the effect is zero. Examine the confidence interval, sample size, and plausible effect sizes as well.
Can the same data be significant at 10% but not 5%?
Yes. For example, the dosage-compliance z-test gives p ≈ 0.0956, which falls below 0.10 but above 0.05. The data remain unchanged; only the decision threshold differs.
When should I use a t-test instead of a z-test?
For a mean, a t-test generally fits the case where you estimate the population standard deviation from the sample. A z-test fits the known-σ normal model or a justified approximation. However, neither test fixes dependence, sampling bias, or severe model mismatch.
Why do exact and approximate proportion tests give different results?
A binomial count changes in whole-number steps, whereas the normal approximation uses a continuous distribution. Therefore, exact and approximate tail probabilities need not match. Differences can matter near a chosen significance threshold.
Must expected chi-square counts be whole numbers?
No. Expected counts represent averages under a model, so decimals are appropriate. In fact, rounding them before calculating the statistic can introduce avoidable error.
Does a larger sample always support the alternative?
No. A larger sample usually improves precision under a sound design, but it can also reveal that the true effect is smaller than expected. Moreover, collecting more biased observations does not remove selection bias.
Does statistical significance imply causation?
No. A test quantifies evidence within a statistical model, while causal interpretation depends on design and assumptions. For example, a contingency-table association alone cannot exclude confounding or selection effects.
What should I do when the textbook and software disagree?
First check the alternative, distribution, degrees of freedom, and any continuity correction. Next, compare unrounded inputs and verify whether the model uses known or estimated parameters. If those choices match, inspect the arithmetic and the source table for transcription errors.
Make hypothesis testing a reasoning process
Hypothesis testing works best when you connect the research question, sampling design, calculation, and interpretation. A small p-value can support a departure from a model, but it cannot supply missing denominators or rescue incorrect assumptions. Likewise, a large p-value cannot prove equivalence.
The worked examples show how modest details can matter: keep exact proportions, preserve expected counts, use the actual rejection boundary, and update degrees of freedom after pooling. Above all, report the estimated effect and its uncertainty alongside the test result. That combination gives readers a much clearer basis for judgment.
References and calculation notes
The worked numerical inputs come from the user-supplied educational pages covering problems 5.1–5.22. This article rewrites the explanations, recalculates the results, and adds explicitly identified analytical extensions. Because the images do not supply complete bibliographic details, no author, edition, or publication date is inferred.
- American Statistical Association, p-value statement: https://www.amstat.org/asa/files/pdfs/p-valuestatement.pdf
- NIST, confidence limits for the mean: https://www.itl.nist.gov/div898/handbook/eda/section3/eda352.htm
- NIST, testing a process mean: https://www.itl.nist.gov/div898/handbook/prc/section2/prc22.htm
- NIST, two-sample t-test: https://www.itl.nist.gov/div898/handbook/eda/section3/eda353.htm
- NIST, chi-square goodness of fit: https://www.itl.nist.gov/div898/handbook/eda/section3/eda35f.htm
- NIST Dataplot, chi-square goodness-of-fit procedure: https://www.itl.nist.gov/div898/software/dataplot/refman1/auxillar/chsqgood.htm
- Penn State, power and sample size: https://online.stat.psu.edu/stat507/Lesson10
- SciPy, binomial test: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.binomtest.html
- SciPy, contingency-table test: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.contingency.chi2_contingency.html
- SciPy, Fisher exact test: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.fisher_exact.html
Calculation note: numerical results use full-precision probability functions before display rounding. Graphs show original calculations from the stated educational models. Exact two-sided binomial and Fisher p-values follow the conventions of the cited SciPy functions; alternative exact-test conventions may give different values.
