Skip to content
Confidence
  • Documentation
  • Blog
  • Bootcamp
  • Status
  • Confidence Bootcamp
    • My learning
    • Intro to experimentation
      • Introduction
      • Lesson 1: Why you should experiment
      • Lesson 2: Experiment hypothesis
      • Lesson 3: Success and guardrail metrics
      • Lesson 4: Success metrics
      • Lesson 5: Set up your experiment
      • Lesson 6: Calculation frequency
      • Lesson 7: Target audience
      • Lesson 8: Sample size
      • Lesson 9: Quality assurance
      • Lesson 10: Run your experiment
      • Lesson 11: Evaluate your experiment and make a decision
      • Lesson 12: A/B tests and rollouts
      • Course wrap up
    • Intro to metrics
      • Introduction
      • Lesson 1: What is a metric?
      • Lesson 2: Metric roles
      • Lesson 3: Time considerations
      • Lesson 4: Capturing behavior
      • Lesson 5: Strategic metrics
      • Lesson 6: Interpretability
      • Lesson 7: Feasibility and sensitivity
      • Lesson 8: Variance reduction and metric selection
      • Lesson 9: Select metrics
      • Lesson 10: Segment-level analysis
      • Course wrap up
    • Scientific product development
      • Introduction
      • Lesson 1: Why you should experiment
      • Lesson 2: The scientific method
      • Lesson 3: Randomized controlled trials
      • Lesson 4: Experiment hypothesis
      • Lesson 5: Case study
        • Case study
        • Answers to case study
      • Lesson 6: Why do we need statistics?
      • Lesson 7: Success metrics
      • Lesson 8: Detectable effects and sample size
      • Lesson 9: Make a decision
      • Course wrap up
    • A primer on hypothesis testing
      • Introduction
      • Lesson 1: Introduction to hypothesis testing
      • Lesson 2: True vs estimated effects
      • Lesson 3: Sampling distribution of the difference-in-means estimator
      • Lesson 4: Z-tests and how to reject the null hypothesis
      • Lesson 5: False postive rate and alpha
      • Lesson 6: True positive rate, MDE, and power
      • Course wrap up
    • Intro to Feature Flags
      • Introduction
      • Lesson 1: What is a feature flag?
      • Lesson 2: Lifecycle of a feature flag
      • Lesson 3: Clients
      • Lesson 4: Evaluation context and targeting
    • Sample size calculation - I
      • Introduction
      • Lesson 1: What is the required sample size?
      • Lesson 2: Alpha and power
      • Lesson 3: Baseline mean and variance
      • Lesson 4: Sample size playground - I
    • Sample size calculation - II
      • Introduction
      • Lesson 1: Multi-metric decision making
      • Lesson 2: Number of success metrics
      • Lesson 3: Number of guardrail metrics
      • Lesson 4: Number of comparisons
      • Lesson 5: Sample size playground - II
    • Sample size calculation - III
      • Introduction
      • Lesson 1: Binary metrics
      • Lesson 2: Treatment group proportions
      • Lesson 3: Variance reduction
      • Lesson 4: Sequential testing and sample size
      • Lesson 5: Sample size playground - III
    • Advance your experimentation
      • Introduction
      • Lesson 1: Guardrail metrics with non-inferiority margins
      • Lesson 2: Choose evaluation frequency
      • Lesson 3: Metrics' roles in experiments
      • Lesson 4: Cumulative holdback evaluations
    • Experimentation culture
      • Introduction
      • Lesson 1: Onboarding into experimentation
      • Lesson 2: Empowering experimentation champions
      • Lesson 3: Sustaining the experimentation culture
    • Videos

Lesson 2: Treatment group proportions

Summary

This lesson explains how the relative sizes of treatment groups affect the required sample size in experiments. If the total sample size is fixed, it's in most cases optimal to have equal group sizes. However, a larger total sample size is always better.


Group size and power

When discussing required sample size, it is common to refer to a single number: "the sample size." However, this total sample size is actually a combination of the sample size in the control group and the sample size in the treatment group.

Interestingly, the total required sample size is not fixed if we change the relative sizes of the treatment groups. This is intuitive: imagine you have a sample of 100 users. When do you learn the most about the treatment effect? If the groups are split 50/50 or 99/1? If only one user is in the treatment group, it will not provide much information about the treatment effect.


Fixed sample size: Equal group sizes maximize power

For continuous metrics, it is optimal from a power perspective to have equal group sizes. For binary metrics, the optimal group sizes depend on the Minimum Detectable Effect (MDE) and the baseline proportion. For the optimal group sizes to deviate from equal, the baseline proportion and the proportion under the hypothetical treatment effect must differ a lot. In other words, unless the MDE is very large, it is a good general rule to aim for similar group sizes. If you are interested in the mathematical details, see the derivation of optimal treatment group sizes in the Note for nerds section below.

Recommendation

If the total possible sample size is fixed, it is a good general rule to aim for similar group sizes.


Larger total sample size is always better

It's important to realize that:

  1. For a fixed total sample size, it is optimal to have similar group sizes to maximize power.
  2. It is always better to have a larger total sample size.

This also means that if you have a fixed number of users that can be exposed to the treatment (for example, due to legal or budget constraints), the larger the control group, the better. In other words, if the size of one group is fixed for some reason, increasing the size of the other group will always improve power.

This is because we want to minimize the uncertainty of the mean for both the treatment and control groups to accurately estimate the treatment effect.

Risky treatments

If a treatment is risky, you might want to limit the number of users exposed to this treatment for risk mitigation purposes. In such cases, the power can be improved by increasing the size of the control group. Sometimes for risky treatments at Spotify, the treatment group is fixed to a small size, and the control group is increased to as large as possible to maximize power. This requires some fiddling in practice since the allocation of the population and treatment proportions are both relative.

For example, if the population is 1000 users and you want 30 to be exposed to the treatment. Then you could have any number up to 970 in the control group. You could run a 50/50 split on 6% of the population to have 30 in each group, or a 97/3 split on 100% of the population to have 970 in the control group and 30 in the treatment group.


Optimal Group Sizes for Power
Reader exercise

What is the optimal group size allocation for continuous metrics when the total sample size is fixed?

Reader exercise

Why is it better to have a larger total sample size in experiments?

Reader exercise

What happens to the required sample size if the relative sizes of the treatment groups are uneven?


Note for nerds

It's in fact quite straightforward to derive the optimal group sizes for binary and continuous metrics. If calculus is not your thing, feel free to skip this section.

Binary metrics

Let's derive the optimal proportions for binary metrics step by step:

Initial setup

Let NaN_aNa​ and NbN_bNb​ be the sample sizes of two treatment groups, and pap_apa​ and pbp_bpb​ be the baseline proportion and the proportion under the hypothetical treatment effect. Define κ=Nb/Na\kappa = N_b / N_aκ=Nb​/Na​, where κ>0\kappa > 0κ>0. For simplicity, let vj=pj(1−pj)v_j = p_j(1 - p_j)vj​=pj​(1−pj​) for j∈{a,b}j \in \{a, b\}j∈{a,b}.

Step 1: Express total sample size

The minimum required sample size for given type-I and type-II risks is found by solving:

arg min⁡κN=arg min⁡κ((Zα+Zβpa−pb)2×(va/κ+vb)+(Zα+Zβpa−pb)2×(va+vbκ))\argmin_{\kappa} N = \argmin_{\kappa} \left(\left(\frac{Z_{\alpha}+Z_{\beta}}{p_a-p_b}\right)^2 \times (v_a / \kappa + v_b) + \left(\frac{Z_{\alpha}+Z_{\beta}}{p_a-p_b}\right)^2 \times (v_a + v_b \kappa)\right)argminκ​N=argminκ​((pa​−pb​Zα​+Zβ​​)2×(va​/κ+vb​)+(pa​−pb​Zα​+Zβ​​)2×(va​+vb​κ))

This expands to:

arg min⁡κN=arg min⁡κ((Zα+Zβpa−pb)2va/κ+(Zα+Zβpa−pb)2vb+(Zα+Zβpa−pb)2va+(Zα+Zβpa−pb)2vbκ)\argmin_{\kappa} N = \argmin_{\kappa} \left(\left(\frac{Z_{\alpha}+Z_{\beta}}{p_a-p_b}\right)^2 v_a / \kappa + \left(\frac{Z_{\alpha}+Z_{\beta}}{p_a-p_b}\right)^2 v_b + \left(\frac{Z_{\alpha}+Z_{\beta}}{p_a-p_b}\right)^2 v_a + \left(\frac{Z_{\alpha}+Z_{\beta}}{p_a-p_b}\right)^2 v_b \kappa\right)argminκ​N=argminκ​((pa​−pb​Zα​+Zβ​​)2va​/κ+(pa​−pb​Zα​+Zβ​​)2vb​+(pa​−pb​Zα​+Zβ​​)2va​+(pa​−pb​Zα​+Zβ​​)2vb​κ)

Step 2: Take derivative

Taking the derivative with respect to κ\kappaκ:

∂∂κ=−(Zα+Zβpa−pb)2va/κ2+(Zα+Zβpa−pb)2vb\frac{\partial}{\partial \kappa} = -\left(\frac{Z_{\alpha}+Z_{\beta}}{p_a-p_b}\right)^2 v_a / \kappa^2 + \left(\frac{Z_{\alpha}+Z_{\beta}}{p_a-p_b}\right)^2 v_b∂κ∂​=−(pa​−pb​Zα​+Zβ​​)2va​/κ2+(pa​−pb​Zα​+Zβ​​)2vb​

Step 3: Set to zero and solve

Setting to zero:

−(Zα+Zβpa−pb)2va/κ2+(Zα+Zβpa−pb)2vb=0-\left(\frac{Z_{\alpha}+Z_{\beta}}{p_a-p_b}\right)^2 v_a / \kappa^2 + \left(\frac{Z_{\alpha}+Z_{\beta}}{p_a-p_b}\right)^2 v_b = 0−(pa​−pb​Zα​+Zβ​​)2va​/κ2+(pa​−pb​Zα​+Zβ​​)2vb​=0

(Zα+Zβpa−pb)2va/κ2=(Zα+Zβpa−pb)2vb\left(\frac{Z_{\alpha}+Z_{\beta}}{p_a-p_b}\right)^2 v_a / \kappa^2 = \left(\frac{Z_{\alpha}+Z_{\beta}}{p_a-p_b}\right)^2 v_b(pa​−pb​Zα​+Zβ​​)2va​/κ2=(pa​−pb​Zα​+Zβ​​)2vb​

va/κ2=vbv_a / \kappa^2 = v_bva​/κ2=vb​

va/vb=κ2v_a / v_b = \kappa^2va​/vb​=κ2

κ=va/vb=pa(1−pa)pb(1−pb)\kappa = \sqrt{v_a / v_b} = \sqrt{\frac{p_a(1-p_a)}{p_b(1-p_b)}}κ=va​/vb​​=pb​(1−pb​)pa​(1−pa​)​​

This implies that for a baseline proportion pap_apa​ and a hypothetical treatment group proportion pbp_bpb​, it is optimal to have:

Nb=Napa(1−pa)pb(1−pb)N_b = N_a \sqrt{\frac{p_a(1-p_a)}{p_b(1-p_b)}}Nb​=Na​pb​(1−pb​)pa​(1−pa​)​​

Clearly, if pa≈pbp_a \approx p_bpa​≈pb​, then NaN_aNa​ is close to NbN_bNb​, which makes the rule of keeping the groups similar a good general guideline. For the nerds who paid attention in the previous lesson, this also of course implies that for binary guardrail metrics, the optimal group sizes are equal.

Continuous metrics

For continuous metrics, let's derive the optimal group sizes step by step:

Initial setup

Let mam_ama​ and mbm_bmb​ be the mean of two groups on some continuous metric. Since the variance doesn't depend on the treatment effect, our optimization simplifies.

Step 1: Express total sample size

We want to minimize:

arg min⁡κN=arg min⁡κ((Zα+Zβma−mb)2×σ2(1+1/κ)+(Zα+Zβma−mb)2×σ2(κ+1))\argmin_{\kappa} N = \argmin_{\kappa} \left(\left(\frac{Z_{\alpha}+Z_{\beta}}{m_a-m_b}\right)^2 \times \sigma^2 (1 + 1 / \kappa) + \left(\frac{Z_{\alpha}+Z_{\beta}}{m_a-m_b}\right)^2 \times \sigma^2 (\kappa + 1)\right)argminκ​N=argminκ​((ma​−mb​Zα​+Zβ​​)2×σ2(1+1/κ)+(ma​−mb​Zα​+Zβ​​)2×σ2(κ+1))

This expands to:

arg min⁡κN=arg min⁡κ((Zα+Zβma−mb)2σ2+(Zα+Zβma−mb)2σ2/κ+(Zα+Zβma−mb)2σ2κ+(Zα+Zβma−mb)2σ2)\argmin_{\kappa} N = \argmin_{\kappa} \left(\left(\frac{Z_{\alpha}+Z_{\beta}}{m_a-m_b}\right)^2 \sigma^2 + \left(\frac{Z_{\alpha}+Z_{\beta}}{m_a-m_b}\right)^2 \sigma^2 / \kappa + \left(\frac{Z_{\alpha}+Z_{\beta}}{m_a-m_b}\right)^2 \sigma^2 \kappa + \left(\frac{Z_{\alpha}+Z_{\beta}}{m_a-m_b}\right)^2 \sigma^2\right)argminκ​N=argminκ​((ma​−mb​Zα​+Zβ​​)2σ2+(ma​−mb​Zα​+Zβ​​)2σ2/κ+(ma​−mb​Zα​+Zβ​​)2σ2κ+(ma​−mb​Zα​+Zβ​​)2σ2)

Step 2: Take derivative

Taking the derivative with respect to κ\kappaκ:

∂∂κ=−(Zα+Zβma−mb)2σ2/κ2+(Zα+Zβma−mb)2σ2\frac{\partial}{\partial \kappa} = -\left(\frac{Z_{\alpha}+Z_{\beta}}{m_a-m_b}\right)^2 \sigma^2 / \kappa^2 + \left(\frac{Z_{\alpha}+Z_{\beta}}{m_a-m_b}\right)^2 \sigma^2∂κ∂​=−(ma​−mb​Zα​+Zβ​​)2σ2/κ2+(ma​−mb​Zα​+Zβ​​)2σ2

Step 3: Set to zero and solve

Setting to zero:

(Zα+Zβma−mb)2σ2/κ2=(Zα+Zβma−mb)2σ2\left(\frac{Z_{\alpha}+Z_{\beta}}{m_a-m_b}\right)^2 \sigma^2 / \kappa^2 = \left(\frac{Z_{\alpha}+Z_{\beta}}{m_a-m_b}\right)^2 \sigma^2(ma​−mb​Zα​+Zβ​​)2σ2/κ2=(ma​−mb​Zα​+Zβ​​)2σ2

σ2/κ2=σ2\sigma^2 / \kappa^2 = \sigma^2σ2/κ2=σ2

κ2=σ2σ2\kappa^2 = \frac{\sigma^2}{\sigma^2}κ2=σ2σ2​

κ=1\kappa = 1κ=1

This implies that it is optimal to have equal group sizes (Na=NbN_a = N_bNa​=Nb​).

Summary

  • For binary metrics, the treatment effect impacts the variance, so the optimal group sizes depend on the baseline proportion and the MDE.
  • For continuous metrics, equal group sizes are always optimal.
  • In all cases, a larger total sample size will improve power.

Was this page helpful?

PreviousLesson 1: Binary metrics
NextLesson 3: Variance reduction

© Copyright 2026. All rights reserved.

Follow us on TwitterFollow us on GitHub

On this page

  1. Group size and power

  2. Fixed sample size: Equal group sizes maximize power

  3. Larger total sample size is always better

  4. Note for nerds