Inferensys

Glossary

Stratified Sampling

A randomization technique that divides the population into homogeneous subgroups before sampling to ensure the treatment and control groups are balanced on critical covariates, thereby reducing variance and improving sensitivity.
Stylish WeWork-like workspace with hot desks and document wall, professional searching through enterprise knowledge base on a mounted ultrawide display, warm industrial pendants overhead.
EXPERIMENTAL DESIGN

What is Stratified Sampling?

A variance reduction technique that ensures treatment and control groups are balanced on critical covariates before randomization.

Stratified sampling is a randomization technique that divides a population into distinct, non-overlapping subgroups called strata based on specific covariates before drawing samples. By ensuring each stratum is proportionally represented in both treatment and control groups, it eliminates covariate imbalance and reduces sampling variance, making experiments more sensitive to true treatment effects.

In A/B testing infrastructure, stratification is critical when key metrics are heavily influenced by factors like user tenure or geographic region. Unlike simple random sampling, which can produce unbalanced groups by chance, stratified assignment guarantees that confounding variables are evenly distributed, preventing Simpson's Paradox and improving the precision of causal estimates without increasing sample size.

VARIANCE REDUCTION

Key Properties of Stratified Sampling

Stratified sampling is a foundational randomization technique that partitions a population into homogeneous subgroups before assigning treatment and control. By ensuring balance on critical covariates, it dramatically reduces variance and increases the sensitivity of online controlled experiments.

01

The Core Mechanism

Stratified sampling divides the experimental population into distinct, non-overlapping strata based on pre-experiment covariates known to correlate with the outcome metric. Randomization is then performed independently within each stratum. This guarantees that the treatment and control groups have near-identical distributions of these critical features, eliminating the random imbalances that plague simple random assignment. Common stratification variables include country, device type, acquisition channel, and historical user activity tiers.

02

Variance Reduction Formula

The statistical power of stratified sampling derives from removing the between-strata variance from the treatment effect estimator. The total variance of the metric is decomposed into within-stratum variance and between-stratum variance. By forcing balance across strata, the between-stratum component is eliminated from the comparison. The resulting variance reduction is proportional to the predictive power of the stratification variables. Even a modestly correlated covariate can yield a 10-30% reduction in the required sample size.

03

Post-Stratification Adjustment

Even when pre-stratification is not implemented at randomization time, analysts can apply post-stratification during the analysis phase. This technique computes the treatment effect separately within each observed stratum and then calculates a weighted average based on the stratum sizes in the full population. While it does not achieve the full efficiency of pre-stratified randomization, it corrects for observed imbalances and provides a consistent estimator. This is a critical safeguard when a Sample Ratio Mismatch is detected.

04

Stratification vs. CUPED

Stratified sampling and Controlled-experiment Using Pre-Experiment Data (CUPED) are complementary variance reduction techniques. Stratification operates on discrete covariates at the assignment stage, ensuring balance. CUPED uses continuous pre-experiment metrics as a covariate in a linear regression adjustment during analysis. The most robust experimentation platforms combine both: stratifying on categorical variables like platform and applying CUPED on continuous pre-period metrics like historical spend. This dual approach maximizes sensitivity.

05

Practical Implementation

In production systems, stratification is implemented via a hash-based assignment function. The user ID and stratum identifier are concatenated and passed through a consistent hashing algorithm. This ensures deterministic, repeatable assignment that is stable across restarts. Key considerations include:

  • Strata granularity: Too many strata with small populations can lead to empty cells.
  • Adaptive stratification: Strata definitions must be updated as user populations shift.
  • Interaction effects: Stratification does not correct for interference between units.
06

Common Pitfalls

The primary risk is over-stratification, where dividing the population into too many fine-grained strata creates sparsity and invalidates the asymptotic assumptions of the variance estimator. Another failure mode is stratifying on a variable that is a post-treatment mediator rather than a pre-experiment covariate, which introduces collider bias and distorts the treatment effect estimate. Always verify that stratification variables are immutable attributes recorded before the user's exposure to the experiment.

STRATIFIED SAMPLING

Frequently Asked Questions

Clear, technical answers to the most common questions about stratified sampling in A/B testing and AI experimentation.

Stratified sampling is a randomization technique that partitions a population into distinct, non-overlapping subgroups—called strata—based on specific covariates before drawing independent random samples from each stratum. The primary mechanism involves identifying critical pre-experiment variables (such as country, device type, or historical spend tier), dividing the user base into homogeneous blocks, and then applying randomization within each block. This ensures the treatment and control groups are balanced on these covariates by design, rather than relying on post-experiment correction. For example, in an e-commerce A/B test, users might be stratified by their prior 30-day purchase frequency (high, medium, low) before assignment, guaranteeing that each variant receives an identical distribution of high-value customers. This contrasts with simple random sampling, where random imbalance on a critical covariate can introduce noise and reduce the sensitivity of the experiment.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.