Compute Cohen's h effect size for two proportions

Quick Overview

Implement Cohen's h, the arcsine-transformed effect size for comparing two proportions such as conversion rates. It tests the sign convention, agreement with a statsmodels reference, input validation and why the arcsine transform makes effects comparable across baseline rates.

Compute Cohen's h effect size for two proportions

Role: Data Scientist

Category: Analytics & Experimentation

Difficulty: easy

Interview Round: Other

Implement `cohens_h(p_control: float, p_treatment: float) -> float`. Return `2*arcsin(sqrt(p_treatment)) - 2*arcsin(sqrt(p_control))`, which is equivalent to `statsmodels.stats.proportion.proportion_effectsize(p_treatment, p_control)`. Requirements: - Sign: treatment minus control, so the result is positive when `p_treatment > p_control` and negative when it is lower. - Return a Python or NumPy `float` with no absolute value and no rounding. Example: ```python cohens_h(0.10, 0.12) -> 0.06398210298605866 cohens_h(0.40, 0.30) -> -0.2101589252771574 ``` ```hint Argument order The function takes the control rate first, while the formula and the statsmodels call put treatment first. Check the sign of your result against both examples. ``` ### Constraints & Assumptions - Both inputs are proportions between 0 and 1 inclusive, such as conversion rates. ### What a Strong Answer Covers - The arcsine transform of each proportion and the treatment-minus-control difference. - Matching the argument order and sign of `proportion_effectsize`. - Returning the raw float, with no absolute value or rounding. - Validation for inputs outside the range 0 to 1. - Why the arcsine transform is used instead of the raw difference in proportions. ### Follow-up Questions - Use the delta method to show why the arcsine transform makes h comparable across baseline rates. - Compare h for a lift from 1% to 3% and for a lift from 50% to 52%. What does the gap between them tell you? - How would you use h to size an A/B test on conversion rate? - What is the largest possible absolute value of h, and when is it reached?

Overview: Implement Cohen's h, the arcsine-transformed effect size for comparing two proportions such as conversion rates. It tests the sign convention, agreement with a statsmodels reference, input validation and why the arcsine transform makes effects comparable across baseline rates.

Nov 25, 2026
easyData ScientistOtherAnalytics & Experimentation
0
0

Implement cohens_h(p_control: float, p_treatment: float) -> float. Return 2*arcsin(sqrt(p_treatment)) - 2*arcsin(sqrt(p_control)), which is equivalent to statsmodels.stats.proportion.proportion_effectsize(p_treatment, p_control).

Requirements:

  • Sign: treatment minus control, so the result is positive when p_treatment > p_control and negative when it is lower.
  • Return a Python or NumPy float with no absolute value and no rounding.

Example:

cohens_h(0.10, 0.12) -> 0.06398210298605866
cohens_h(0.40, 0.30) -> -0.2101589252771574

Constraints & Assumptions

  • Both inputs are proportions between 0 and 1 inclusive, such as conversion rates.

What a Strong Answer Covers Guidance

  • The arcsine transform of each proportion and the treatment-minus-control difference.
  • Matching the argument order and sign of proportion_effectsize .
  • Returning the raw float, with no absolute value or rounding.
  • Validation for inputs outside the range 0 to 1.
  • Why the arcsine transform is used instead of the raw difference in proportions.

Follow-up Questions Guidance

  • Use the delta method to show why the arcsine transform makes h comparable across baseline rates.
  • Compare h for a lift from 1% to 3% and for a lift from 50% to 52%. What does the gap between them tell you?
  • How would you use h to size an A/B test on conversion rate?
  • What is the largest possible absolute value of h, and when is it reached?