Simulation and Resampling Methods
Traditional statistical inference relies on formulas and distributional assumptions — you calculate a test statistic, look up a critical value from a known distribution, and draw a conclusion. Modern simulation-based methods take a different approach: they use the computer to build the sampling distribution directly from your data. No formulas needed, fewer assumptions required.
This page builds on the concepts from Sampling Distributions and Confidence Intervals for Means and shows you how simulation achieves the same goals through a different path.
Why Simulation-Based Methods?
Traditional methods like the -test and -interval work well when their assumptions are met — large enough sample size, approximately normal population, known distribution shape. But what happens when those conditions are not satisfied?
- Your sample size is small () and the population is clearly skewed
- You want a confidence interval for the median instead of the mean — and there is no simple formula for that
- The sampling distribution of your statistic does not follow a known mathematical form
Simulation-based methods handle all of these situations because they do not rely on distributional assumptions. Instead, they let the data speak for itself.
Other advantages:
- More intuitive — you can literally see the sampling distribution in a histogram, rather than relying on abstract formulas
- Increasingly standard — AP Statistics, college introductory courses, and data science programs are moving toward simulation-based approaches
- Require a computer — but since computers are everywhere, this is no longer a limitation
Bootstrapping for Confidence Intervals
The core idea: Your sample is the best available stand-in for the population. If you could sample from the population again, you would get slightly different results each time. Bootstrapping simulates this process by resampling from your sample with replacement.
How Bootstrapping Works
- Start with your original sample of values
- Draw a new sample of values with replacement from the original (some values will appear more than once, others will be left out)
- Calculate the statistic (mean, median, proportion, etc.) for this resample
- Repeat steps 2 and 3 a large number of times (typically 1,000 to 10,000)
- The middle 95% of the resampled statistics forms your 95% bootstrap confidence interval
The key phrase is with replacement. When sampling with replacement, each draw is independent — after you pick a value, you “put it back” so it can be picked again. This is what creates the variation between resamples.
Example 1: Bootstrap CI for a Median
You have a small sample of patient wait times (in minutes) at a clinic:
The sample has . The sample median is the average of the 4th and 5th values (when sorted):
There is no simple formula for a confidence interval for the median (unlike the mean, which uses ). This is where bootstrapping shines.
Resample 1: Draw 8 values with replacement: 15, 22, 22, 25, 12, 35, 18, 25. Sorted: 12, 15, 18, 22, 22, 25, 25, 35. Median = .
Resample 2: Draw 8 values with replacement: 45, 12, 28, 18, 22, 22, 15, 12. Sorted: 12, 12, 15, 18, 22, 22, 28, 45. Median = .
Resample 3: Draw 8 values with replacement: 25, 45, 35, 22, 28, 15, 25, 18. Sorted: 15, 18, 22, 25, 25, 28, 35, 45. Median = .
Each resample produces a slightly different median. After 1,000 resamples, you would have 1,000 bootstrap medians. Sorting those 1,000 values and finding the 2.5th percentile (25th value) and the 97.5th percentile (975th value) gives you the 95% bootstrap confidence interval for the population median.
If the bootstrap distribution of medians ranges from roughly 18 to 30, with the middle 95% falling between 18.5 and 28.0, then the 95% bootstrap CI for the median wait time is approximately (18.5 minutes, 28.0 minutes).
Randomization Tests for Hypothesis Testing
While bootstrapping builds a confidence interval, randomization tests (also called permutation tests) perform hypothesis testing. The logic is elegant:
If the null hypothesis is true (no difference between groups), then the group labels do not matter. A treatment value could just as easily have been a control value and vice versa. So we shuffle the labels and see how often random chance alone produces a difference as large as what we actually observed.
How Randomization Tests Work
- Calculate the observed test statistic (e.g., difference in group means)
- Pool all the data from both groups into one combined set
- Randomly assign the data to two groups of the same sizes as the original groups
- Calculate the test statistic for the random assignment
- Repeat steps 3 and 4 a large number of times (1,000+)
- P-value = the proportion of random assignments that produce a test statistic as extreme as (or more extreme than) the observed one
Example 2: Two-Group Comparison
A researcher tests whether a new study technique improves exam scores. Five students use the new technique (Treatment) and five use their usual method (Control).
Treatment group: 82, 88, 85, 90, 80
Control group: 72, 78, 75, 70, 80
Observed difference: points.
Question: Could a difference of 10 points occur by random chance alone?
Randomization procedure: Pool all 10 scores: 82, 88, 85, 90, 80, 72, 78, 75, 70, 80. Randomly assign 5 to “Treatment” and 5 to “Control.” Calculate the difference in means.
One random shuffle might assign 88, 72, 85, 80, 75 to “Treatment” (mean = 80.0) and 82, 90, 78, 70, 80 to “Control” (mean = 80.0), giving a difference of 0.
Another shuffle might give a difference of 6, or -4, or 12.
After 1,000 random shuffles, you count how many produced a difference of 10 or greater (or -10 or less, for a two-sided test). If only 25 out of 1,000 shuffles produce such an extreme difference, the p-value is:
Since , you would reject and conclude that the new study technique appears to produce a real improvement.
Monte Carlo Simulation
Monte Carlo simulation uses random number generation to estimate probabilities or outcomes that are difficult (or impossible) to calculate with formulas.
The idea: if you cannot solve a problem analytically, simulate it thousands of times and observe what happens. The law of large numbers guarantees that the simulation result will converge to the true answer as the number of trials increases.
Example 3: The Birthday Problem
What is the probability that at least 2 people in a group of 23 share a birthday?
The exact answer (derived from combinatorics) is approximately 50.7%. But rather than working through the formula, you can simulate it:
- Generate 23 random birthdays (integers from 1 to 365)
- Check if any two match
- Record “yes” or “no”
- Repeat 10,000 times
- The proportion of “yes” results estimates the probability
If 5,073 out of 10,000 simulations contain at least one shared birthday:
This matches the theoretical result. The more simulations you run, the more precise the estimate becomes.
Other Applications of Monte Carlo
- Project planning: Simulate task durations to estimate the probability of finishing on time
- Financial modeling: Simulate market returns to estimate the probability of a portfolio losing more than 10%
- Quality control: Simulate a manufacturing process to estimate the defect rate under different conditions
- Risk analysis: Simulate insurance claim amounts to set appropriate premiums
When to Use Simulation Methods
| Method | Use When | Goal |
|---|---|---|
| Bootstrap | You want a CI but traditional assumptions are not met (small , non-normal, median, or other non-standard statistic) | Confidence interval |
| Randomization test | You want a hypothesis test without distributional assumptions | P-value for hypothesis test |
| Monte Carlo | The probability or outcome is too complex to derive analytically | Probability estimate or distribution of outcomes |
General guideline: If the traditional method’s assumptions are clearly satisfied and the formula is straightforward, the traditional approach is fine — it is faster and gives an exact answer. Use simulation methods when the traditional approach is unavailable, unreliable, or overly complex.
Advantages and Limitations
| Feature | Traditional Methods | Simulation Methods |
|---|---|---|
| Assumptions | Require specific distributional assumptions (normality, large , etc.) | Minimal assumptions — data-driven |
| Flexibility | Limited to statistics with known sampling distributions | Work for any statistic (median, trimmed mean, ratio, etc.) |
| Intuition | Abstract — rely on memorized formulas and distribution tables | Concrete — you see the sampling distribution directly |
| Reproducibility | Exact — same data always gives the same answer | Varies slightly between runs (set a random seed for exact reproducibility) |
| Speed | Instantaneous calculation | Requires computing time (negligible for modern computers in most cases) |
| Complexity | Simple formulas for standard cases | Can handle arbitrarily complex models |
| Teaching | Historically dominant in textbooks | Increasingly adopted in modern curricula |
Key limitation of simulation: The results depend on the quality of the original data. If your sample is biased or unrepresentative, bootstrapping from it will not fix the underlying problem — it will just give you a precise estimate of the wrong answer.
Practice Problems
Test your understanding with these problems. Click to reveal each answer.
Problem 1: You have a sample of 10 home sale prices and want a 95% confidence interval for the median price. The distribution of home prices is right-skewed. Which method is more appropriate — a traditional t-interval or a bootstrap interval? Why?
Answer: A bootstrap interval is more appropriate for two reasons: (1) You want a CI for the median, not the mean — there is no standard formula for a median CI. (2) The distribution is right-skewed with only , so the normality assumption for the t-interval is questionable even for the mean. Bootstrap makes no distributional assumptions and works directly with the median.
Problem 2: A researcher collects data from two groups (n=8 each) and observes a difference in means of 4.5. After 2,000 randomization shuffles, 148 produce a difference of 4.5 or greater, and 136 produce a difference of -4.5 or less. What is the two-sided p-value?
The two-sided p-value counts shuffles as extreme as the observed difference in either direction:
Answer: The two-sided p-value is 0.142. Since this exceeds 0.05, the observed difference is not statistically significant — it could plausibly be due to random chance.
Problem 3: In a bootstrap analysis, you generate 1,000 resampled means. The sorted means at positions 25 and 975 (the 2.5th and 97.5th percentiles) are 14.2 and 19.8. What is the 95% bootstrap confidence interval? What does it mean?
Answer: The 95% bootstrap CI is (14.2, 19.8). This means we are 95% confident that the true population mean falls between 14.2 and 19.8. This interval was constructed by observing where the middle 95% of resampled means fell — no normality assumption was required.
Problem 4: You want to estimate the probability of rolling at least one six in four rolls of a fair die. Describe how you would use Monte Carlo simulation to estimate this probability. What is the theoretical answer?
Monte Carlo approach:
- Simulate 4 random integers from 1 to 6 (representing 4 die rolls)
- Check if at least one value equals 6
- Record “yes” or “no”
- Repeat 10,000 times
- The proportion of “yes” results estimates the probability
Theoretical answer:
The probability is approximately 51.8%. A Monte Carlo simulation with 10,000 runs would produce a result close to this value.
Problem 5: A bootstrapped sampling distribution of the mean is approximately bell-shaped and centered at 42.3 with a standard deviation (called the bootstrap standard error) of 2.1. Using the normal approximation, what is the approximate 95% confidence interval?
Using the formula:
Answer: The approximate 95% CI is (38.2, 46.4). When the bootstrap distribution is approximately normal, this “standard error method” gives results very similar to the percentile method.
Key Takeaways
- Bootstrapping resamples your data with replacement to build a sampling distribution — the middle 95% of resampled statistics forms a 95% confidence interval
- Randomization tests shuffle group labels to test whether an observed difference could be due to chance — the p-value is the proportion of shuffles producing a result as extreme as observed
- Monte Carlo simulation uses random number generation to estimate probabilities that are hard to calculate analytically
- Simulation methods require fewer assumptions than traditional methods and work for any statistic, not just means and proportions
- The quality of simulation results depends on the quality of your original data — biased data in means biased results out
Return to Statistics for more topics in this section.
Next Up in Statistics
All Statistics topicsLast updated: March 29, 2026