Skip to content
CoreSource checked

Stratified Sampling

Samples separately from groups so each group is represented.

Quick Facts

Compact metadata for implementation and discovery.

Category
Randomness & Sampling
Difficulty
Beginner
Family
Sampling Design
Tier
Core
Status
Verified
Review
Source Checked
Sources
1
Formulas
1
Relationships
6
Code example
Ready
Visualization
Ready

Overview

Stratified Sampling divides a population into strata and draws samples from each stratum to reduce imbalance or variance.

Core Concepts

sample selectionrandom drawstate estimatesampling designrandom sourcedistribution shape

Quick facts

Complexity

Runtime and memory behavior at a glance.

Best

O(n)

Average

O(n)

Worst

O(n)

Space

O(k)

When to Use

  • Use Stratified Sampling when you need to partition a population into groups.
  • Use it for surveys with inputs like population.
  • Use it when randomization, representative samples, or controlled variation are needed.
  • Use it when the Sampling Design tradeoff is acceptable for the problem size.

When Not to Use

  • Avoid it when reproducibility, distribution quality, or sample independence cannot be verified.
  • Avoid it when the required output is not stratified sample.

What It Does

  • Partitions a population into groups
  • Samples within each group

Use Cases

  • Surveys
  • Monte Carlo integration
  • Balanced dataset sampling

Inputs

  • Population
  • Strata definitions
  • Sample allocation

Outputs

  • Stratified sample

Key Formulas (1)

Stratified estimate

estimate = ∑(weightstratum · mean(samplevalues in stratum))
estimate = sum(weight_stratum * mean(sample_values_in_stratum))

Combines separate group estimates according to each stratum's population weight.

Pseudocode

  1. 1.Assign each item to a stratum
  2. 2.Choose how many samples to draw per stratum
  3. 3.Randomly sample within each stratum
  4. 4.Combine stratum samples
  5. 5.Weight results if needed

Canonical Example

Input
items = [A, B, C, D], seed = 7
Output
sampled or randomized result
Explanation
Stratified Sampling: The algorithm uses controlled randomness to choose or generate values.

Implementation Notes

  • Keep the input contract explicit: Population; Strata definitions; Sample allocation.
  • Separate the random number source from the algorithm so tests can use fixed seeds.
  • Separate the random source from the sampler so tests can use fixed seeds and distribution checks.

Common Pitfalls

  • Good strata should group items that are similar for the quantity being estimated.
  • Sampling from the wrong distribution can make the estimate look precise but biased.
  • Using biased random choices or forgetting to store the seed for reproducible runs.
  • Handle empty, invalid, and boundary inputs before trusting stratified sample.

Interactive Mechanism Walkthrough

Iterative Convergence & State Trajectory

Show each population group contributing samples.

Stratified Sampling mechanism walkthrough step 1 of 5x₀x₁x₂x*
Step 1 of 5: Assign each item to a stratum
grouped-samples

Notes

Stratified Sampling operates in O(n) time and O(k) space within the Sampling Design family. Key governing relation: estimate = sum(weight_stratum * mean(sample_values_in_stratum)). Often compared with Latin Hypercube Sampling and Importance Sampling.

Sources (1)

What each reference supports for this entry.

Monte Carlo Statistical Methods

Book

Monte Carlo reference for Stratified Sampling's estimator construction, sampling assumptions, and variance behavior.

Explore Next

Good next jumps from the relationship graph, ranked for useful discovery.

Conceptual neighborImportance Sampling

Both reduce estimator variance with structured sampling choices.

Both improve coverage by dividing the sample space.

Alternative toReservoir Sampling

Stratified sampling controls sample coverage, while reservoir sampling handles streams.

Tags

SamplingRandomnessEstimation