5/17
Part 2 of 7 · Two groups and pairsLearn and do
Pairs: test the differences
NIST calls two samples paired when there's a one-to-one correspondence between their values. Say both carriers run the same 12 routes. Some routes are slow for everyone, so the route matters more than the carrier, and two-group tests count that route-to-route spread as noise.
from statistics import mean, stdev
# carrier A on 12 routes
a = [2.9, 3.2, 3.6, 4.0, 4.4, 4.3, 4.9, 5.2, 5.4, 5.9, 6.2, 6.7]
# carrier B on the same routes
b = [2.6, 3.1, 3.1, 3.9, 4.1, 3.9, 4.4, 5.0, 5.3, 5.4, 6.1, 6.2]
t_u, df_u = welch(mean(a), stdev(a), len(a), mean(b), stdev(b), len(b))
t_p, df_p = paired_t(a, b)
print(f"as two groups: t = {t_u:.2f}, p = {t_two_sided_p(t_u, df_u):.3f}")
print(f"as pairs: t = {t_p:.2f}, p = {t_two_sided_p(t_p, df_p):.6f}")
Carrier A is 0.3 days slower on every route, give or take a little. Which analysis sees it?
Pick one to see what it prints.
Pick an answer above to see the rest