Learn ANOVA and nonparametric tests with 34 solved examples, clear formulas, charts, verified calculations, and common mistakes.

ANOVA and Nonparametric Tests: Solved Examples

ANOVA and Nonparametric Tests: Solved Examples

STATISTICS • VERIFIED WORKED EXAMPLES

ANOVA and nonparametric tests help you compare groups, evaluate patterns, and decide whether sample evidence challenges a statistical claim. However, choosing a test requires more than recognizing a formula. You also need to understand the study design, check assumptions, and interpret the result without claiming more than the data support.

This detailed guide develops the examples in the supplied textbook photographs, covering pages 109–127. Along the way, it connects analysis of variance, signed ranks, goodness of fit, statistical power, confidence intervals, and two-sample comparisons. Every numerical result below comes from a fresh calculation using the displayed data, unless a table explicitly identifies a historical printed result.

The distinctive feature is an answer-key audit. For example, you will see why an ANOVA ratio changes from 70 to 75, why removing zero differences changes a Wilcoxon decision, and why a familiar Kolmogorov–Smirnov table does not automatically apply to counts. Consequently, the article teaches both the calculation and the judgment needed to use it.

How to Choose Between ANOVA and Nonparametric Tests

Start with the unit of observation. If the same person tastes two products, the observations form pairs. By contrast, separate samples of workers from two cities usually form independent groups. That distinction determines the analysis before a normality check enters the discussion.

QuestionSuitable starting methodWhat to verify
Do several independent groups have equal means?One-way ANOVAIndependent errors, reasonable residual normality, common variance
Do two factors explain a continuous outcome?Two-factor ANOVAReplication, interaction, randomization, residual assumptions
Do paired differences center on zero?Paired t test or Wilcoxon signed-rank testPairing; symmetry for signed-rank location interpretation
Do independent groups have different distributions?Kruskal–Wallis testIndependent observations; distribution shapes for a median interpretation
Does a continuous sample fit a specified CDF?One-sample KS testContinuous model; parameters specified independently of the tested sample
Are observed category counts consistent with probabilities?Chi-square goodness-of-fit testExpected counts and specified probabilities
Are two categorical variables associated?Chi-square independence testIndependent records and adequate expected cell counts
Does one success probability exceed a benchmark?Binomial test or proportion z testIndependent Bernoulli trials; approximation conditions

Nonparametric does not mean assumption-free. For instance, a rank test can still fail when repeated observations create dependence. Similarly, a large sample cannot repair a biased sample or turn an observational association into a causal effect.

Before calculating, write down the outcome, grouping variable, sample size, and sampling process. Next, inspect the raw observations for missing values, unusual observations, and repeated measurements. Finally, identify the quantity you want to learn: a mean difference, a distributional shift, an association, or a model discrepancy.

Hypothesis Testing: The Logic Behind Every Calculation

State the null and alternative before looking for significance

A null hypothesis specifies the reference model. For a four-group ANOVA, it says that all four population means are equal. The alternative says that at least one mean differs; it does not say that every mean differs from every other mean.

H0: μ1 = μ2 = μ3 = μ4
HA: Not all population means are equal

Choose a one-sided alternative only when the scientific question justifies that direction in advance. Otherwise, use a two-sided alternative. Switching directions after observing the results changes the error properties of the procedure.

Read a p-value without reversing its meaning

A p-value measures how incompatible the observed statistic is with the null model, using outcomes at least as extreme in the prespecified direction. It does not give the probability that the null hypothesis is true. Moreover, a small p-value does not establish a large or economically important effect.

Method reference: American Statistical Association statement on p-values.

RealityReject H₀Do not reject H₀
H₀ is trueType I error; probability αCorrect non-rejection
A specified alternative is truePower = 1 − βType II error; probability β

Use “fail to reject” when the evidence does not cross the chosen threshold. In particular, a non-significant result does not prove equality. If your objective is to demonstrate that a difference is small enough to ignore, define a meaningful equivalence margin and use an equivalence procedure.

Method reference: Penn State: power and sample-size considerations.

One-Way ANOVA: Formulas and Fully Worked Examples

Why a test about means uses variances

ANOVA compares variation between group means with variation among observations inside groups. Under the equal-means model, both mean squares estimate the same error variance. However, real separation among means tends to increase the numerator.

F = MSbetween / MSwithin
SSbetween = Σ nj(x̄j − x̄)2
SSwithin = ΣΣ(xij − x̄j)2
MSbetween = SSbetween / (k − 1)
MSwithin = SSwithin / (N − k)

Here, k counts groups, N counts all observations, and nj counts observations in group j. The grand mean weights groups by their sample sizes. Therefore, an unweighted average of group means works only when group sizes match, or when it happens to coincide with the weighted mean.

Method reference: NIST: the ANOVA table and tests of means.

Example 1: Compare four fertilizers across eight observations

Raw inputs from the fertilizer exercise
ObservationFertilizer 1Fertilizer 2Fertilizer 3Fertilizer 4
151475750
247504861
356585257
452616065
557516158
659485753
758595161
860504659
Total440424432464
Mean55535458

First, add the four column totals: 440 + 424 + 432 + 464 = 1,760. Since the table contains 32 observations, the grand mean equals 55. Next, compare each group mean with that overall value.

SSbetween = 8[(55 − 55)2 + (53 − 55)2 + (54 − 55)2 + (58 − 55)2] = 112

The within-group sums of squares equal 144, 208, 216, and 158. Therefore, their total equals 726. Adding between-group and within-group variation gives a total sum of squares of 838.

SourceSSdfMSF
Fertilizer112337.33331.4399
Within groups7262825.9286
Total83831
F = (112 / 3) / (726 / 28) = 1.4399
p = P(F3,28 ≥ 1.4399) = 0.2522

At α = 0.05, fail to reject equal population means. Although fertilizer 4 has the largest sample mean, this experiment does not establish an overall mean difference at that threshold. Consequently, the ranking of sample averages alone cannot justify a claim that fertilizer 4 performs best in the population.

2026-10-19T13:08:32.024451 image/svg+xml Matplotlib v3.10.8, https://matplotlib.org/ Fertilizer 1 Fertilizer 2 Fertilizer 3 Fertilizer 4 47.5 50.0 52.5 55.0 57.5 60.0 62.5 65.0 Output (exercise units) Different sample means, substantial within-group variation
Figure 1. Dots show the 32 supplied observations; orange lines show sample means. The plot displays raw variability, not confidence intervals.

Example 2: Add effect size to the fertilizer result

A significance decision leaves an obvious question unanswered: how much variation separates the groups in this sample? Eta squared provides one descriptive answer. However, it is a sample statistic, not proof of a causal contribution.

η2 = SSbetween / SStotal = 112 / 838 = 0.1337
ω2 = [SSbetween − (k − 1)MSwithin] / [SStotal + MSwithin] ≈ 0.0396

The observed group separation accounts for about 13.4% of sample variation. In contrast, the bias-adjusted omega-squared estimate is about 4.0%. This gap shows why an attractive descriptive percentage can overstate the strength of a small experiment.

Example 3: Compare four gasoline types

DayType 1Type 2Type 3Type 4
112121617
211141415
312131517
413151316
511141418
Mean11.813.614.416.6

Under the independent-groups interpretation, the grand mean equals 14.1 mpg. Between-group variation equals 59.4, while within-group variation equals 18.4. Thus, the total sum of squares equals 77.8.

SourceSSdfMSF
Gasoline type59.4319.817.2174
Within groups18.4161.15
Total77.819
F = 19.8 / 1.15 = 17.2174; p ≈ 0.0000290

Reject equal means at the 5% level. Nevertheless, the omnibus test does not identify every differing pair. Follow-up comparisons require a suitable multiplicity adjustment, and the study design must support treating the five days as independent replicates rather than repeated measurements on the same unit.

Assumptions, diagnostics, and post-hoc comparisons

Inspect residual plots rather than demanding that the pooled outcome look normal. If the groups have different means, pooling them can produce a non-normal-looking mixture even when each group follows a normal error model. Also, investigate strong variance differences, especially when sample sizes differ.

For unequal variances, Welch’s ANOVA can be a better mean-comparison procedure. When the target concerns distributions or ordered outcomes, a rank-based method may fit better. Neither choice should substitute for understanding how the observations were collected.

Method reference: NIST: one-factor ANOVA.

Two-Factor ANOVA: Separate Two Sources of Variation

A two-factor design places one factor in rows and another in columns. With replication, the model can include an interaction: the effect of one factor depends on the level of the other. However, one observation per cell does not independently identify a full interaction term and a separate experimental error term.

Yijk = μ + Ai + Bj + (AB)ij + εijk

Method reference: NIST: two-way crossed ANOVA.

The following textbook calculations use an additive model with no separately estimated interaction. For r rows and c columns, the residual degrees of freedom equal (r − 1)(c − 1). Therefore, interpret the resulting F tests conditionally on that additive-model assumption.

SScolumns = rΣ(x̄·j − x̄)2
SSrows = cΣ(x̄i· − x̄)2
SSerror = SStotal − SScolumns − SSrows

Example 4: Fertilizers and pesticides

PesticideFertilizer 1Fertilizer 2Fertilizer 3Fertilizer 4Row mean
121129612
21310859
388716
Column mean1410849

The grand mean equals 9. Next, use the row and column means to separate 266 units of total squared variation into fertilizer, pesticide, and residual components.

SourceSSdfMSFp
Fertilizer1563528.21050.01518
Pesticide722365.68420.04123
Residual3866.3333
Total26611

At the exercise’s 1% significance level, neither result reaches the rejection threshold. By comparison, both reach the 5% threshold. This does not make the data contradictory: the analyst has changed the decision rule, not the observed evidence.

Example 5: Graduate earnings by school and class rank

Historical exercise values in thousands of dollars
Class rankSchool 1School 2School 3School 4School 5
Top third2018161412
Middle third1916131210
Bottom third181410108

The five school means equal 19, 16, 13, 12, and 10. Meanwhile, the three class-rank means equal 16, 14, and 12. Since the grand mean equals 14, the additive ANOVA yields the following results.

SourceSSdfMSFp
School150437.5750.00000223
Class rank40220400.0000683
Residual480.5
Total19414

Both factors show evidence of differences within the additive model. However, these observational earnings comparisons do not establish that attending a particular school causes the difference. Selection, background, occupation, and location could also affect earnings.

Example 6: Octane and vehicle type

VehicleOctane 1Octane 2Octane 3Octane 4
Heavy89910
Medium16151817
Light24262830
SourceSSdfMSFp
Octane17.666735.88893.78570.07769
Vehicle type6542327210.21430.00000279
Residual9.333361.5556

At α = 0.01, reject equal vehicle-type means but fail to reject equal octane means. Notice that the raw response to octane looks different across vehicle categories. Consequently, a follow-up experiment with replicated cells would help assess interaction instead of forcing all departures into the residual term.

Example 7: Soap sales by wrapping and formula

FormulaWrapping 1Wrapping 2Wrapping 3
1877890
2797984
3838191
4858389
SourceSSdfMSFp
Wrapping138.1667269.083313.29950.00624
Formula47.5833315.86113.05350.11355
Residual31.166765.1944

At 5%, the wrapping comparison reaches significance, while the formula comparison does not. Even so, the design needs randomization and a sensible experimental unit before a business can treat the wrapping result as causal. Store, week, and shelf placement can create additional variation that this small table does not describe.

Nonparametric Tests: Signed Ranks, Ties, and Group Comparisons

How the Wilcoxon signed-rank test works

For paired data, calculate one difference per pair. Under the conventional zero-dropping rule, remove differences equal to zero, rank the remaining absolute differences, and assign average ranks to ties. Finally, sum the ranks attached to positive differences.

di = Ai − Bi
W+ = Σ rank(|di|) for di > 0

A location interpretation requires a symmetric distribution of differences. In addition, exact no-tie reference tables cannot simply ignore ties or retain the original sample size after dropping zeros. A conditional sign-flip calculation can instead enumerate all sign assignments to the observed nonzero absolute differences.

Method reference: SciPy: Wilcoxon signed-rank test, zeros, and ties.

Example 8: Does additive B receive better taste ratings?

PersonABA − B
15.56-0.5
278-1
3990
436-3
568-2
6660
7844
86.58-1.5
978-1
1069-3

Define negative differences as evidence favoring B. After removing two zeros, eight differences remain. The ordered absolute values are 0.5, 1, 1, 1.5, 2, 3, 3, and 4, so the corresponding ranks are 1, 2.5, 2.5, 4, 5, 6.5, 6.5, and 8.

W+ = 8
Number of sign assignments = 28 = 256
One-sided conditional p = 23 / 256 = 0.08984375

At 5%, fail to reject the null in favor of better ratings for B. Although most nonzero differences favor B, the small sample and positive difference of 4 affect the signed-rank evidence. The result would reach a prespecified 10% threshold, but that is a different decision rule.

Example 9: Test a benchmark of 8% in the literacy exercise

Use the nine historical exercise values 3, 8, 15, 4, 9, 7, 6, 3, and 7. Subtracting 8 gives −5, 0, 7, −4, 1, −1, −2, −5, and −1. Once again, dropping the zero leaves eight ranked differences.

W+ = 2 + 8 = 10
One-sided p for a lower location = 36 / 256 = 0.140625
Two-sided p = 0.28125

Neither version rejects at α = 0.10. Therefore, the data do not provide enough signed-rank evidence for a location below 8 under the stated symmetry assumptions. The printed one-sided rejection does not survive the corrected effective sample size and tied-rank calculation.

For a claim strictly about a median without symmetry, consider a sign test instead. Moreover, a convenience list of countries does not become a random sample merely because a statistical formula accepts the numbers. Regional generalizations need an appropriate sampling argument.

Example 10: Test gasoline type 1 against 12 and 15 mpg

The five observations are 12, 11, 12, 13, and 11. Against 12 mpg, only −1, 1, and −1 remain after dropping zeros; all three absolute differences tie. Consequently, each receives rank 2 and W+ = 2.

BenchmarkNonzero nW⁺Two-sided conditional pDecision at 10%
12321.0000Fail to reject
15500.0625Reject

Against 15 mpg, every observation falls below the benchmark. For five independent symmetric differences, all-negative signs occur with probability 1/32. Doubling that tail probability gives 0.0625, so the two-sided test rejects at 10% but not at 5%.

How Kruskal–Wallis compares independent groups

Kruskal–Wallis ranks all observations together and compares group rank sums. Its general null concerns equal distributions. A simpler statement about equal medians requires comparable distribution shapes, so do not reduce every rank-test result to a median claim.

H = [12 / (N(N + 1))] Σ(Rj2 / nj) − 3(N + 1)
C = 1 − Σ(t3 − t) / (N3 − N)
Hcorrected = H / C

Here, Rj denotes a group’s rank sum, while t denotes the size of each pooled tie block. Compare the corrected statistic with an approximate chi-square distribution using k − 1 degrees of freedom. For small samples, a permutation procedure can improve calibration.

Method reference: SciPy: Kruskal–Wallis test and tie correction.

Example 11: Compare three regional literacy exercise groups

Exercise groupValuesnCorrect pooled rank sum
South America3, 8, 15, 4, 9, 7, 6, 3, 7977.5
Asia9, 4, 9, 1, 9, 5, 4758.5
Africa50, 46, 34, 57, 39, 77, 29, 278164
Hcorrected = 15.4727; df = 2; approximate p = 0.0004367

Reject equal distributions at 1%. In this exercise, all African-group values exceed the observations in the other two groups. However, the omnibus result does not establish a difference between South America and Asia, and these old figures cannot support present-day regional comparisons.

Example 12: Compare South America and Asia alone

Re-rank the combined 16 observations for this new comparison. The South America rank sum equals 77.5, giving U = 77.5 − 9 × 10 / 2 = 32.5. A tie-corrected normal approximation with continuity correction gives a two-sided p-value of about 0.9573.

Thus, fail to reject equal distributions at 5%. Notice how the strong three-group result coexists with an unremarkable two-group result. The third group drove the original separation, which illustrates why an omnibus test cannot replace pairwise analysis.

Example 13: Apply Kruskal–Wallis to the gasoline data

Hcorrected = 14.5215; df = 3; approximate p = 0.002275

Here, the rank-based test rejects equal distributions at 5%, consistent with the one-way ANOVA conclusion. However, the printed statistic of approximately 14.25 omits the pooled tie adjustment. Although that adjustment does not change this decision, it improves the numerical result.

Kolmogorov–Smirnov Tests: Compare Entire Distributions

A KS test compares an empirical cumulative distribution function with a specified continuous CDF. At each ordered observation, the empirical CDF jumps. Therefore, the calculation must examine both sides of every jump rather than checking only the cumulative proportion after the observation.

D+ = max[i/n − F(x(i))]
D− = max[F(x(i)) − (i − 1)/n]
D = max(D+, D−)

Method reference: NIST: KS definition and limitations.

Example 14: Test a uniform distribution from 25 to 80

Sort the eight exercise observations: 27, 29, 34, 39, 46, 50, 57, and 77. Under Uniform(25, 80), the reference CDF inside that interval is F(x) = (x − 25)/55. Then compare that CDF with both sides of the empirical steps.

xi/8F(x)i/8 − F(x)F(x) − (i−1)/8
270.12500.03640.08860.0364
290.25000.07270.1773-0.0523
340.37500.16360.2114-0.0864
390.50000.25450.2455-0.1205
460.62500.38180.2432-0.1182
500.75000.45450.2955-0.1705
570.87500.58180.2932-0.1682
771.00000.94550.05450.0705
D = 0.29545; continuous-null exact p ≈ 0.4086

At α = 0.10, fail to reject the specified uniform model. Nevertheless, eight observations provide limited ability to identify departures from a distribution. Agreement with a test threshold is not proof that the model generated the data.

Example 15: Change the upper endpoint to 100

F(x) = (x − 25)/75
D = 0.44833; continuous-null exact p ≈ 0.05507

At 10%, reject Uniform(25, 100). By contrast, the same p-value does not cross the 5% threshold. This example demonstrates sensitivity to the proposed model: a broader interval predicts more high observations than the sample supplies.

Both p-values assume exact continuous observations and prespecified endpoints. Since the teaching data appear as rounded percentages, the continuous calculation is an approximation to their measurement process. Choosing endpoints after examining the same sample would also require a different calibration.

2026-10-19T13:08:32.208217 image/svg+xml Matplotlib v3.10.8, https://matplotlib.org/ 30 40 50 60 70 80 90 100 Historical exercise value (%) 0.0 0.2 0.4 0.6 0.8 1.0 Cumulative probability Observed ECDF Uniform(25, 80) Uniform(25, 100)
Figure 2. The same eight values produce different KS distances under different specified models.

Example 16: Why a binomial KS calculation needs different calibration

The photographed binomial example uses observed counts 25, 34, 31, and 10 for outcomes 0, 1, 2, and 3. Under Binomial(3, 0.4), the probabilities are 0.216, 0.432, 0.288, and 0.064. Consequently, observed cumulative proportions are 0.25, 0.59, 0.90, and 1.00, while the model gives 0.216, 0.648, 0.936, and 1.00.

Maximum cumulative discrepancy = max(0.034, 0.058, 0.036, 0) = 0.058

The discrepancy itself is a legitimate descriptive number. However, standard continuous KS critical values do not give the usual distribution-free calibration for a binomial model. Use a discrete-null exact method, a null-model simulation, or a suitable categorical goodness-of-fit test instead.

Example 17: Rainy-day counts versus a normal model

Rainy days012345
Observed cities1012221361

The exercise compares these 64 counts with a normal distribution having mean 3 and standard deviation 2. At x = 2, the empirical CDF equals 44/64 = 0.6875, while the proposed normal CDF equals Φ(−0.5) ≈ 0.30854. Thus, the discrepancy at that point equals about 0.37896.

D = 0.37896 for the ordinary ECDF comparison with N(3, 22)

A chi-square analysis can compare binned normal probabilities if the exercise explicitly intends that approximation. In that case, specify bin boundaries and include both tails before calculating expected frequencies. Otherwise, different arbitrary bins can produce different answers to an apparently identical question.

Tests for Means and Proportions: Additional Worked Examples

Example 18: Aluminum-sheet thickness

The supplied exercise gives a target mean of 0.004 inches, n = 25, sample mean 0.0043, and sample standard deviation 0.001. Since the population standard deviation is unknown, use a one-sample t statistic with 24 degrees of freedom under the normal model.

t = (0.0043 − 0.004) / (0.001/√25) = 1.5
Two-sided p ≈ 0.1466

At 5%, fail to reject the target mean. The corresponding non-rejection interval for the sample mean, holding the observed standard deviation fixed, runs from approximately 0.003587 to 0.004413 inches. Therefore, 0.0043 lies inside that interval.

Example 19: Has the mean recruit height increased?

The exercise specifies a reference mean of 180 cm and a known population standard deviation of 1.5 cm. For n = 100 and sample mean 182 cm, the standard error equals 0.15 cm. Thus, the observed average sits far above the reference mean in standard-error units.

z = (182 − 180) / 0.15 = 13.3333
5% one-sided rejection rule: x̄ > 180 + 1.64485(0.15) = 180.2467 cm

Reject the null of no increase under the stated model. The observed difference is 2 cm, which should accompany the significance result. Additionally, changes in recruitment or measurement procedures could affect what this comparison means in practice.

Example 20: Do components last less than 100 hours?

Here, n = 16, x̄ = 96 hours, and s = 8 hours. Test H₀: μ = 100 against HA: μ < 100. Because the exercise assumes normal lifetimes but does not supply a known population standard deviation, use t with 15 degrees of freedom.

t = (96 − 100)/(8/√16) = −2
One-sided p = 0.03197

Reject at 5%, but fail to reject at 1%. In everyday language, the evidence suggests a lower mean lifetime under the less stringent threshold. It does not establish that every component lasts fewer than 100 hours.

Example 21: Has an admissions success proportion increased?

Among 88 applicants, 22 exceed the exercise’s score threshold. Therefore, the observed proportion equals 0.25, compared with a historical benchmark of 0.20. This is a proportion test, not a test that the average score equals the threshold.

z = (0.25 − 0.20)/√[0.20(0.80)/88] = 1.1726
One-sided normal p ≈ 0.1205
Exact binomial p = P(X ≥ 22 | n = 88, p = 0.20) ≈ 0.1495

Both approaches fail to reject at 5%. The p-values differ because the normal calculation approximates a discrete sampling distribution. For reporting, specify the method instead of presenting one approximation as the only possible answer.

Example 22: Compare weekly salaries in two cities

The exercise reports 100 workers with mean 400 and standard deviation 100 in one city, versus 75 workers with mean 375 and standard deviation 80 in another. These are historical exercise amounts. The estimated mean difference is 25 currency units per week.

SE = √(1002/100 + 802/75) = 13.6137
Large-sample z = 25/13.6137 = 1.8364
Two-sided normal p ≈ 0.0663

Fail to reject at 5%, but reject at 10% under the stated approximation. For a modern finite-sample analysis, use Welch’s t test unless equal variances have a defensible role in the model. The substantive question remains whether a difference of 25 matters after accounting for location and job characteristics.

Method reference: NIST: comparing two means and Welch’s degrees of freedom.

Example 23: Compare mean player weights

One sample contains 21 players with mean 265 lb and standard deviation 30 lb. Another contains 11 players with mean 240 lb and standard deviation 20 lb. For the directional alternative that the first population mean is larger, Welch’s calculation gives the following result.

t = (265 − 240)/√(302/21 + 202/11) = 2.8088
One-sided Welch p ≈ 0.00448

Reject at 1%. However, this example compares population means under sampling assumptions; it does not classify an individual player. Position mix and other selection differences could also explain an observational group contrast.

Example 24: Marriage proportions measured in two years

The photographed exercise says that a sample of 100 soldiers has 20% married in year 1 and 30% in year 2. That wording leaves a crucial design question: are these the same soldiers? If so, the two proportions are paired, and marginal percentages alone do not identify the appropriate paired test.

For the same people, obtain the counts who changed from unmarried to married and from married to unmarried. McNemar’s test uses those discordant pairs. By contrast, if the exercise intended two independent samples of 100, a pooled two-proportion calculation gives z ≈ −1.633 and a one-sided p-value near 0.0512, which does not reject at 5%.

Statistical Power and Operating-Characteristic Curves

Power describes the probability of rejection under a particular alternative. Meanwhile, an operating-characteristic curve describes the probability of non-rejection. Their values add to one at every specified parameter value, although the non-rejection probability represents β only when the null is false.

Power(θ) = Pθ(reject H0)
OC(θ) = Pθ(do not reject H0) = 1 − Power(θ)

Method reference: Penn State: power analysis.

Example 25: Rebuild the admissions power table

The later printed exercises use a fixed standard error of 0.043 and an implied cutoff of 0.25 for the sample proportion. Treat that as a separate approximate decision rule. It is not the same as the preceding 5% test of a population proportion of 0.20.

Approximate rejection rule: p̂ > 0.25
Power(p) = 1 − Φ[(0.25 − p)/0.043]
True proportionApproximate non-rejection probabilityApproximate rejection probability
0.200.87750.1225
0.220.75730.2427
0.240.59190.4081
0.250.50000.5000
0.260.40810.5919
0.280.24270.7573

At p = 0.20, this rule rejects about 12.25% of the time under the fixed-standard-error approximation. Therefore, its implied Type I error is about 12.25%, not 5%. At p = 0.28, its power rises to about 75.73%.

To construct a genuine 5% normal-approximation test using the same fixed standard error, the cutoff would instead be 0.20 + 1.64485 × 0.043 ≈ 0.2707. A binomial design would calculate rejection probabilities from discrete counts. Consequently, a power curve must always name its test rule, sample size, and variance model.

2026-10-19T13:08:32.397972 image/svg+xml Matplotlib v3.10.8, https://matplotlib.org/ 0.150 0.175 0.200 0.225 0.250 0.275 0.300 0.325 0.350 True proportion 0.0 0.2 0.4 0.6 0.8 1.0 Probability Illustrative fixed-SE rule: reject when sample proportion > 0.25 Rejection probability Non-rejection probability
Figure 3. These curves reproduce the exercise’s implied rule. They do not represent a correctly calibrated 5% test.

Chi-Square Tests: Goodness of Fit and Independence

χ2 = Σ[(O − E)2/E]

For goodness of fit, expected counts follow the specified category probabilities. In an independence table, each expected cell count equals its row total times its column total divided by the grand total. However, sparse expected counts can make the usual chi-square approximation unreliable.

Method reference: NIST: chi-square goodness of fit.

Example 26: Is a six-sided die consistent with fairness?

Face123456
Observed128131278
Expected101010101010
χ2 = 0.4 + 0.4 + 0.9 + 0.4 + 0.9 + 0.4 = 3.4
df = 5; p = 0.6386

Fail to reject equal face probabilities at 5%. This conclusion means that the observed departures are not unusual enough under the fairness model. It does not certify that the physical die is perfectly balanced.

Example 27: Are four urn colors equally common?

The 18 draws yield counts of 8, 7, 1, and 2. Equal color probabilities imply 4.5 expected observations in each category. Substituting those values gives χ² = 8.2222 with 3 degrees of freedom and an asymptotic p-value of about 0.04164.

The conventional approximation rejects at 5%, matching the printed direction. However, every expected count is below five, so this is a fragile approximation. An exact multinomial test or a null-model simulation would provide a more defensible small-sample result; the tail criterion must also be specified.

Example 28: Does defect status depend on production hour?

Status8–9 a.m.9–10 a.m.10–11 a.m.11 a.m.–noonTotal
Acceptable60758065280
Not acceptable30253035120
Total90100110100400

The overall acceptable fraction equals 280/400 = 0.70. Therefore, the expected acceptable counts are 63, 70, 77, and 70. The complementary expected defect counts are 27, 30, 33, and 30.

χ2 = 3.24675; df = (2 − 1)(4 − 1) = 3
p = 0.3551

At 5%, fail to reject independence. Nonetheless, the observed acceptable rates range from 65% to 75%, so an operational review may still care about uncertainty around those rates. Statistical non-significance alone does not establish a stable manufacturing process.

Example 29: Is voting category associated with age group?

Age groupDemocratRepublicanTotal
Under 406511
40 or older10919
Total161430
Pearson χ2 without continuity correction = 0.01025
df = 1; p = 0.9193
Two-sided Fisher exact p = 1.0000

Neither method finds evidence of association at 5%. The observed odds ratio is 1.08, which also shows how similar these sample proportions are. Therefore, the printed “No” should not be interpreted as evidence against independence for the displayed table.

Method reference: SciPy: contingency-table expected counts and chi-square testing.

Statistics Examination: Descriptive Measures, Probability, and Intervals

Example 30: Summarize grouped unemployment rates

Rate class (%)FrequencyMidpointMidpoint × frequency
7.0–7.427.214.4
7.5–7.947.730.8
8.0–8.458.241.0
8.5–8.948.734.8
9.0–9.439.227.6
9.5–9.929.719.4
Approximate mean = Σfm / n = 168 / 20 = 8.4%
Approximate sample variance = 10.70 / 19 = 0.56316 percentage-points²
Sample standard deviation ≈ 0.75044 percentage points
Coefficient of variation ≈ 0.75044 / 8.4 = 8.93%

These are midpoint-based approximations because the exact city observations are unavailable. If the displayed classes represent rates rounded to one decimal place, use continuous boundaries such as 7.95–8.45 for the modal class. Its width is 0.50, not the 0.40 difference between the printed endpoints.

Grouped median ≈ 7.95 + [(10 − 6)/5] × 0.50 = 8.35%
Grouped mode ≈ 7.95 + [1/(1 + 1)] × 0.50 = 8.20%
Pearson second skewness ≈ 3(8.40 − 8.35)/0.75044 = 0.200
2026-10-19T13:08:32.706882 image/svg+xml Matplotlib v3.10.8, https://matplotlib.org/ 7.2 7.7 8.2 8.7 9.2 9.7 Unemployment rate (%) — historical exercise 0.00 0.05 0.10 0.15 0.20 0.25 Relative frequency
Figure 4. Equal-width histogram bins represent the six supplied classes; the sample contains 20 cities.

Example 31: Calculate normal lifetime probabilities

Suppose component lifetime follows a normal distribution with mean 1,000 hours and standard deviation 80 hours. Standardize each endpoint with z = (x − 1,000)/80. Next, subtract CDF values for an interval or use the appropriate tail for a one-sided probability.

QuestionStandardized calculationProbability
1,120 < X < 1,180Φ(2.25) − Φ(1.50)0.054583 = 5.4583%
955 < X < 975Φ(−0.3125) − Φ(−0.5625)0.090443 = 9.0443%
X < 955Φ(−0.5625)0.286888 = 28.6888%
X > 9751 − Φ(−0.3125)0.622670 = 62.2670%

Small differences from printed answers arise when a table rounds z-scores to two decimal places. Keeping full precision until the final result avoids that discrepancy. In addition, continuous distributions assign zero probability to any single exact endpoint, so strict versus inclusive inequalities do not change these probabilities.

Example 32: Confidence intervals with known and unknown standard deviation

For 25 students with a sample mean of 110 and known population standard deviation 10, the 95% normal interval uses a standard error of 2. Therefore, its endpoints equal 110 ± 1.96 × 2, or approximately 106.08 and 113.92.

Known σ: x̄ ± z0.975σ/√n = 110 ± 3.92

In the separate version with unknown population standard deviation and sample standard deviation 8, use t with n − 1 = 24 degrees of freedom. The standard error equals 1.6. Consequently, the 95% interval runs from approximately 106.698 to 113.302.

Unknown σ: x̄ ± t0.975,24s/√n = 110 ± 2.06390 × 1.6 = 110 ± 3.30224

The second interval is narrower because its standard deviation input is smaller, not because t intervals are inherently narrower. With the same standard error, the t critical value would produce a wider interval. A 95% confidence procedure describes long-run coverage, rather than a 95% probability assigned to a fixed population mean after observing this interval.

Example 33: Does plant 1 fill more than 1,000 grams?

For plant 1, n = 25, x̄ = 1,064 g, and s = 100 g. The question asks whether the population mean exceeds 1,000 g, so use a prespecified right-tailed t test. Its standard error equals 20 g.

t = (1,064 − 1,000)/20 = 3.2
df = 24; one-sided p = 0.001920

Reject the reference mean at 5%. Report the estimated excess of 64 g along with the statistical result. However, a test of average fill does not show that every package exceeds the labeled amount.

Example 34: Do the two plants have different mean fills?

Plant 2 has n = 25, sample mean 1,024 g, and standard deviation 60 g. The estimated mean difference is 40 g. Since equal population variances are not established, Welch’s comparison is a defensible starting point.

SE = √(1002/25 + 602/25) = √544 = 23.3238
t = 40/23.3238 = 1.7150
Welch df ≈ 39.30; two-sided p ≈ 0.09422

Fail to reject equal means at 5%. This result does not contradict the strong evidence that plant 1 exceeds 1,000 g: the two tests ask different questions. One compares a plant with a fixed benchmark, while the other compares two estimated means.

A better rule than “use the normal distribution when n reaches 30”

Thirty is not a universal boundary that guarantees a good approximation. Tail heaviness, outliers, dependence, and skewness all affect sampling behavior. For normally distributed independent data with unknown variance, the one-sample t procedure remains appropriate even when n exceeds 30.

Chebyshev’s inequality supplies a distribution-free probability bound when the variance exists. However, substituting an unstable small-sample variance does not automatically produce a useful exact confidence interval. When assumptions look doubtful, investigate the sampling process and consider a justified robust or resampling method.

What Makes This Guide Different: A Reproducible Answer-Key Audit

Issue in the supplied pagesChecked result or qualificationWhy it matters
School ANOVA F printed as 7037.5 / 0.5 = 75Corrects arithmetic without changing the decision
Taste-rating signed-rank rejection at 5%Conditional one-sided p = 0.08984Changes the decision under the stated sign-flip method
Literacy signed-rank rejection at 10%Conditional one-sided p = 0.140625Zeros and ties affect the reference distribution
Regional rank sums total 297Correct total is 300Detects ranking errors before a test statistic is calculated
Three-group Kruskal–Wallis uses 3 dfCorrect reference has 2 dfChanges the critical distribution
Gasoline rank statistic omits tie correctionH = 14.5215 after correctionMakes the test reproducible
Binomial example uses continuous KS cutoffDiscrete-null calibration requiredA valid distance is not automatically a valid p-value
Rainy-day KS distance printed as 0.391Ordinary ECDF distance is 0.37896Checks both calculation and observation model
Power table appears beside a 5% testImplied fixed-SE rule has α ≈ 12.25%Reveals inconsistent decision rules
Voting-table answer suggests non-independencePearson p ≈ 0.9193Displayed counts do not support that interpretation
Two-plant test uses 49 dfPooled df = 48; Welch df ≈ 39.30Corrects a common degrees-of-freedom mistake
Grouped median uses printed endpoint widthContiguous rounded-data boundaries give 8.35%Separates a convention from an exact statistic

Verify the most consequential calculations yourself

The following Python code reproduces the one-way fertilizer result and the two corrected signed-rank probabilities. Specifically, the sign-flip function conditions on nonzero absolute differences and averages tied ranks. It assumes that independent signs are equally likely under the symmetric null model.

import itertools
import numpy as np
from scipy import stats

fertilizers = [
    [51, 47, 56, 52, 57, 59, 58, 60],
    [47, 50, 58, 61, 51, 48, 59, 50],
    [57, 48, 52, 60, 61, 57, 51, 46],
    [50, 61, 57, 65, 58, 53, 61, 59],
]
print(stats.f_oneway(*fertilizers))
# F = 1.439853..., p = 0.252228...

def lower_tail_signed_rank(differences):
    d = np.asarray(differences, dtype=float)
    d = d[d != 0]
    ranks = stats.rankdata(np.abs(d), method="average")
    observed = ranks[d > 0].sum()
    possibilities = [
        np.dot(ranks, signs)
        for signs in itertools.product([0, 1], repeat=len(d))
    ]
    return observed, np.mean(np.asarray(possibilities) <= observed)

print(lower_tail_signed_rank(
    [-0.5, -1, 0, -3, -2, 0, 4, -1.5, -1, -3]
))
# W+ = 8, p = 0.08984375

print(lower_tail_signed_rank(
    np.array([3, 8, 15, 4, 9, 7, 6, 3, 7]) - 8
))
# W+ = 10, p = 0.140625

A practical reporting checklist

  1. Identify the sampling unit and whether observations are independent or paired.
  2. State the null, alternative, and significance level before calculating.
  3. Show the sample sizes, units, and relevant descriptive statistics.
  4. Name the method, including tie handling, continuity corrections, or exact calibration.
  5. Report the statistic, degrees of freedom where relevant, and p-value.
  6. Add an effect estimate and an interval when the data support them.
  7. Explain the decision in the original context and state the main design limitation.

For example, a concise fertilizer report would say: “A one-way ANOVA found insufficient evidence of different population means, F(3, 28) = 1.440, p = 0.252. Sample means ranged from 53 to 58 output units. The analysis assumes independent observations and common error variance; the shared-year structure requires further design review.”

Frequently Asked Questions About ANOVA and Nonparametric Tests

Can I use ANOVA for two groups?

Yes. Under the same independent, equal-variance model, a two-group one-way ANOVA gives F = t² for the corresponding two-sided pooled t test. However, Welch’s alternatives use different variance assumptions, so do not mix their formulas with a pooled reference table.

Does a significant ANOVA prove every group differs?

No. The omnibus alternative requires only one population mean to differ. Therefore, use planned contrasts or adjusted post-hoc comparisons to answer specific pairwise questions.

Does Kruskal–Wallis always test medians?

No. Its general interpretation concerns group distributions. Comparable shapes allow a location or median interpretation, but unequal spread or shape can also contribute to a significant result.

Should I always choose a nonparametric test for a small sample?

No. Small-sample parametric methods can be valid under appropriate models. Conversely, rank methods still require assumptions, and tiny samples can leave both families with limited power.

Why do my software results differ from a textbook?

Check rounding, one-sided versus two-sided alternatives, zero handling, average ranks, tie corrections, and exact versus asymptotic calculations. Also, verify the transcribed observations before interpreting any discrepancy. A clear method specification often explains a difference that first looks like an arithmetic error.

Can a non-significant result support a practical decision?

Yes, but the decision needs more than a threshold. Consider the effect estimate, uncertainty, cost of error, and whether the study could detect a meaningful difference. If the interval remains wide, further measurement may be more useful than declaring that nothing changed.

Can I apply a standard KS test after estimating the model from the same data?

Not with the ordinary fully specified-null calibration. Estimating parameters changes the distribution of the test statistic. Use a method designed for fitted models or a suitable simulation procedure.

Turn Statistical Calculations Into Defensible Conclusions

ANOVA and nonparametric tests become useful when the method matches the question and the sampling design. The worked examples show how to calculate statistics, but they also demonstrate why correct arithmetic alone is insufficient. Pairing, interaction, ties, discreteness, and uncertainty determine what those numbers can support.

Begin with the design, preserve the raw data, and verify the reference distribution. Then report the effect and its uncertainty alongside the p-value. That approach produces conclusions readers can check, rather than answers that depend on an unexplained table or a copied yes/no decision.

Sources and Calculation Notes

The numerical examples derive from the supplied photographs, with original explanatory text and independently recalculated results. Institutional and software references below support the methods. Approximate p-values use the named reference distributions; conditional signed-rank probabilities enumerate sign assignments, and KS probabilities assume a fully specified continuous null.

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *