Non-Parametric Tests (Mann-Whitney, Wilcoxon)
Why non-parametric tests
Section titled “Why non-parametric tests”When data is:
- Not normally distributed
- Heavy-tailed
- Contains outliers
…it can be safer to compare median/rank behavior.
Mann–Whitney U test (two independent groups)
Section titled “Mann–Whitney U test (two independent groups)”Alternative to the independent t-test.
import numpy as np
from scipy import stats
A = np.array([1, 2, 2, 3, 100])
B = np.array([1, 1, 2, 2, 3])
u, p = stats.mannwhitneyu(A, B, alternative="two-sided")
print("U:", u)
print("p:", p)Wilcoxon signed-rank (paired)
Section titled “Wilcoxon signed-rank (paired)”Alternative to the paired t-test.
import numpy as np
from scipy import stats
before = np.array([10, 12, 11, 9, 13])
after = np.array([11, 12, 12, 10, 14])
w, p = stats.wilcoxon(after - before)
print("W:", w)
print("p:", p)- Non-parametric tests often have less power when assumptions for parametric tests are satisfied.
- Always combine tests with visualizations.
Choosing parametric vs. non-parametric
Section titled “Choosing parametric vs. non-parametric”flowchart TD A["Comparing two groups"] --> B["Data roughly normal,
no big outliers?"] B -->|"Yes"| C["t-test
(parametric)"] B -->|"No"| D["Same subjects twice?"] D -->|"Yes"| E["Wilcoxon
signed-rank"] D -->|"No"| F["Mann-Whitney U"]
🧪 Try It Yourself
Section titled “🧪 Try It Yourself”Exercise 1 – Mann-Whitney U test
Section titled “Exercise 1 – Mann-Whitney U test”Exercise 2 – Wilcoxon signed-rank test
Section titled “Exercise 2 – Wilcoxon signed-rank test”Exercise 3 – Deciding which test fits
Section titled “Exercise 3 – Deciding which test fits”Continue to A/B Testing Basics to apply these comparison tests to a real product experiment.
pch.coffeeTagline
pch.coffeeCtapch.feedbackHeading
pch.feedbackSubheading