A/B Test Conversion Rate & Relative Lift

Basics
BasicsA/B TestingProduct MetricsGoogleMetaJane Street

Problem

Implement ab_conversion_lift(conv_a, n_a, conv_b, n_b) returning (cr_control, cr_treatment, relative_lift) where cr_control = conv_a / n_a, cr_treatment = conv_b / n_b, and relative_lift = (cr_treatment - cr_control) / cr_control.

Why It Matters: Relative lift is the headline business metric in every product A/B test—e.g. a +15% checkout lift rather than raw percentage-point difference.

Function Signature

def ab_conversion_lift(conv_a: int, n_a: int, conv_b: int, n_b: int) -> tuple[float, float, float]:

Sample Input & Output

Example 1: Positive Treatment Lift (+20%)

Input:

conv_a = 100, n_a = 1000, conv_b = 120, n_b = 1000

Expected Output:

(0.1, 0.12, 0.2)

Explanation: cr_a = 0.10, cr_b = 0.12, so relative lift is (0.12 - 0.10) / 0.10 = 0.2 (+20%).

Example 2: Negative Treatment Regression (-25%)

Input:

conv_a = 40, n_a = 200, conv_b = 30, n_b = 200

Expected Output:

(0.2, 0.15, -0.25)

Explanation: cr_a = 0.20, cr_b = 0.15, so relative lift is -0.25 (-25%).

Constraints & Edge Cases

  • Return (cr_a, cr_b, rel_lift) as floats (conv_a > 0).
  • conv_a > 0, n_a > 0, and n_b > 0.
  • Negative lift indicates the treatment performed worse than control.

Constraints & Evaluation Criteria

  • Return `(cr_a, cr_b, rel_lift)` as floats (`conv_a > 0`).

Hints

Python 3
Loading Code Editor...
+1 Hidden Submit Case
Input / Scenario
100/1000 vs 120/1000
Expected Output / Criteria
(0.10, 0.12, 0.20)