4/32
Part 1 of 6 · The splitLearn and do
How far off is too far?
A whole browser gone from B is easy to spot. Most broken splits are subtler, so the check has to say how far off is too far.
from math import sqrt
from statistics import NormalDist
def srm_p_value(n_a, n_b, share_b=0.5):
n = n_a + n_b
z = (n_b - n * share_b) / sqrt(n * share_b * (1 - share_b))
return 2 * (1 - NormalDist().cdf(abs(z)))
for n_a, n_b in [(520, 480), (50_600, 49_400), (821_588, 815_482)]:
share = max(n_a, n_b) / (n_a + n_b)
p = srm_p_value(n_a, n_b)
print(f"{n_a:>7,} vs {n_b:>7,} "
f"larger share {share:.1%} p = {p:.2g}")
Which split is the real alarm: 52.0% of 1,000 users, or 50.6% of 100,000?
Pick one to see what it prints.
Pick an answer above to see the rest
The SRM check runs on every experiment. Why use a strict cutoff like p < 0.001 instead of 0.05?
Pick an answer above to see the rest