An A/B test compared the old checkout (A) with a new one (B). Write ab_test(conv_a, n_a, conv_b, n_b) that compares their conversion rates with a two-proportion z-test using the pooled proportion. Return a tuple (z, p_value): z is B's rate minus A's rate, divided by the pooled standard error, and p_value is two-sided. Round both to 4 decimal places. math.erf gives you the normal distribution: 0.5 * (1 + math.erf(x / math.sqrt(2))) is the chance of a value below x.
Example
ab_test(200, 2000, 250, 2000)
(2.502, 0.0124)
What this question tests
Tests the two-proportion z-test written by hand: pooled rate, standard error, z, and a two-sided p-value from the normal distribution. Data science loops at ride-hailing and marketplace companies are reported to mix live coding with A/B testing, and this is where the two meet.
More Python interview questions