
Image by Editor | ChatGPT
Statistics often deal with uncertainty. Data rarely tells the full story at first instance, so analysts and scientists rely on methods that can extract more information from what is available. One of the most practical techniques for this purpose is resampling, a strategy that creates many possible versions of the same dataset by drawing repeated samples.
In this article, we set up an experiment to explore what happens when the same dataset is resampled 10,000 times. The goal is to test the limits of repetition and observe how statistical measures behave across so many iterations.
By the end of this article, you will:
- Understand how resampling helps reveal the stability of a metric
- See how repeated sampling shapes distributions that can be compared to theoretical expectations
- Learn what insights 10,000 iterations can offer about bias, variance, and randomness in data
Why Resampling Matters
Resampling is a statistical technique where new samples are drawn from an observed dataset to study variability, estimate accuracy, or test hypotheses. Rather than relying only on strict mathematical formulas, resampling allows us to approximate results through simulation.
There are three main approaches worth highlighting:
- Bootstrap: Random sampling with replacement from the original dataset, often used to estimate confidence intervals and standard errors.
- Jackknife: Systematic resampling where one observation is removed at a time, useful for bias reduction and variance estimation.
- Permutation (or randomization tests): Shuffling labels or values to test the likelihood of observing a statistic under the null hypothesis.
These methods play a critical role in modern data analysis. For example, machine learning practitioners use resampling to validate models by splitting datasets into training and test subsets multiple times. In fields like medicine or economics, bootstrap confidence intervals are common when the underlying distribution of a measure is unknown.
Simulation-based experiments like the one in this article are valuable because they bridge the gap between theory and practice. Textbook formulas may explain expected outcomes, but resampling shows the variability in action. Running thousands of samples makes uncertainty visible and concrete.
Designing the Experiment
To keep the experiment controlled, we will work with a synthetic dataset rather than a real-world one. A synthetic dataset allows us to know its true properties in advance, making it easier to check how well resampling reflects them.
We will generate 1,000 observations drawn from a normal distribution with a mean of 50 and a standard deviation of 10. This setup is simple enough to track but realistic enough to resemble many natural datasets.
The resampling procedure follows the bootstrap approach:
- Draw a sample of the same size (1,000) from the dataset with replacement
- Calculate the sample mean
- Store the result
- Repeat the process 10,000 times
The focus will be on the mean of the dataset, which is a common statistic in both research and applied work. Tracking the distribution of sample means will help us see how stable the estimate of the population mean is under repeated sampling.
Expectations before running the experiment:
- The average of the resampled means should be close to the true mean of the dataset (50)
- The spread of the resampled means should reflect the variability expected from a normal distribution
- With 10,000 resamples, the distribution of means should appear smooth and approximate a normal curve centered around 50
Running 10,000 Resamples
Before running the experiment, make sure the required Python libraries are installed. You can set up a virtual environment and install the packages with:
pip install numpy pandas matplotlib seaborn
Let’s translate the design into Python code. We will use NumPy for random sampling and Pandas for managing the results.
import numpy as np
import pandas as pd
import time
# Step 1: Generate the synthetic dataset
np.random.seed(42) # for reproducibility
data = np.random.normal(loc=50, scale=10, size=1000)
# Step 2: Define number of resamples
n_resamples = 10000
sample_size = len(data)
# Step 3: Run the bootstrap resampling
means = [] # to store mean of each resample
start_time = time.time()
for _ in range(n_resamples):
# draw a bootstrap sample with replacement
resample = np.random.choice(data, size=sample_size, replace=True)
# calculate the mean of this resample
resample_mean = np.mean(resample)
# store the result
means.append(resample_mean)
end_time = time.time()
# Step 4: Convert to pandas Series for easier analysis
resampled_means = pd.Series(means)
print("Resampling complete.")
print(f"Runtime: {end_time - start_time:.2f} seconds")
print(f"First five resampled means:\n{resampled_means.head()}")
Explanation of the code
- Dataset generation: We used np.random.normal to create 1,000 observations with a mean of 50 and a standard deviation of 10.
- Resampling loop: For each of the 10,000 iterations, we drew a bootstrap sample and calculated its mean.
- Storage: The results were appended to a list and later converted into a Pandas Series for easy analysis and visualization.
- Runtime tracking: Using the time module helps us see how computationally expensive 10,000 resamples are on standard hardware.
Result:

Computational Aspects
Running 10,000 resamples of a dataset with 1,000 observations is computationally manageable on most modern laptops. The loop takes a few seconds, depending on the machine. If the dataset were much larger (for example, millions of observations), or if we needed 100,000 resamples, the runtime would grow significantly. In such cases, vectorized methods or parallel processing would become important for efficiency.
Visualization of the Result
After running 10,000 bootstrap resamples, we now have a distribution of sample means stored in the resampled_means object. The next step is to visualize this distribution and compare it with what theory suggests.
First, let’s create three plots: a histogram, a kernel density estimate (KDE), and a boxplot.
import matplotlib.pyplot as plt
import seaborn as sns
# Set style for plots
sns.set(style="whitegrid")
# Histogram + KDE
plt.figure(figsize=(10, 6))
sns.histplot(resampled_means, bins=50, kde=True, color="skyblue")
plt.axvline(50, color="red", linestyle="--", label="True Mean (50)")
plt.title("Distribution of Resampled Means (10,000 iterations)")
plt.xlabel("Resampled Mean")
plt.ylabel("Frequency")
plt.legend()
plt.show()
# Boxplot
plt.figure(figsize=(8, 4))
sns.boxplot(x=resampled_means, color="lightgreen")
plt.axvline(50, color="red", linestyle="--", label="True Mean (50)")
plt.title("Boxplot of Resampled Means")
plt.xlabel("Resampled Mean")
plt.legend()
plt.show()
Histogram-KDE-Distribution-of-Resampled-Means.png
Boxplot-of-Resampled-Means.pngExplanation of Results
- Histogram with KDE: The histogram shows the frequency distribution of resampled means across 10,000 iterations. The KDE curve overlays the histogram, providing a smooth estimate of the underlying distribution. The red dashed line marks the true mean (50). The resampled distribution is centered around 50, as expected.
- Boxplot: The boxplot summarizes the spread of the resampled means. Most values fall tightly around the true mean, with whiskers extending only slightly. Outliers are rare, which matches expectations for bootstrap sampling of a normally distributed dataset.
Comparing to Theoretical Expectations
- The Central Limit Theorem predicts that the distribution of sample means will approach normality as the sample size grows. The histogram and KDE confirm this pattern.
- The variance of the resampled means is much smaller than the variance of the original dataset. This is because averaging reduces variability compared to individual data points.
- There is no significant bias: the resampled mean closely aligns with the true mean of 50.
In summary, the empirical results align well with statistical theory.
Key Insights
After resampling the same dataset 10,000 times, several insights stand out:
- Stability of the mean: The distribution of resampled means stabilized quickly. Even with 1,000 resamples, the shape resembled a normal curve. By 10,000, the distribution was nearly identical to theoretical expectations. This confirms that bootstrap methods provide reliable estimates of uncertainty when enough iterations are used.
- Variance shrinks with aggregation: While the original dataset had a standard deviation of about 10, the resampled means clustered within a much narrower range. This illustrates why averages are often more stable than raw data points: randomness cancels out when aggregated across repeated samples.
- No unexpected skew or tails: In this controlled setup, the distribution of means was symmetric and smooth. If the dataset had outliers or a non-normal distribution, we might have seen heavier tails or skew. The absence of such patterns highlights the importance of knowing the underlying data when interpreting resampling results.
Takeaways for Real-World Work
- Resampling is a practical way to quantify uncertainty without relying solely on formulas
- Large numbers of resamples give results that are both stable and interpretable
- Patterns such as skew or outliers in resampled distributions can reveal hidden characteristics of the dataset
Limitations of the Experiment
The results of this experiment are not universal. They depend strongly on the characteristics of the dataset. Here, we worked with a normally distributed synthetic dataset that contained no outliers and had a moderate sample size. If the dataset were smaller, heavily skewed, or filled with extreme values, the resampled distributions could look very different.
Another limitation comes from computation. Running 10,000 resamples on a dataset of 1,000 points is feasible on a laptop, but scaling this to millions of rows or hundreds of thousands of iterations can become expensive. In practice, parallelization or approximate methods may be needed to keep runtimes manageable.
This experiment is empirical. It shows patterns in action but does not replace formal statistical proofs. Resampling demonstrates variability and stability, but theory is still required to explain why those patterns hold across different datasets and conditions.
Practical Applications
Resampling is widely used in real-world analysis when data is limited, noisy, or does not meet the assumptions of traditional formulas. A few areas where it proves useful include:
- Building confidence intervals for machine learning models: Instead of relying on asymptotic formulas, bootstrapping allows analysts to generate confidence intervals for accuracy, precision, or regression coefficients.
- Validating stability of metrics in A/B testing: By repeatedly resampling user data, teams can see whether observed differences in conversion rates or click-through rates are stable or just artifacts of randomness.
- Understanding uncertainty in small datasets: When working with medical studies, rare events, or niche surveys, resampling helps quantify uncertainty even when classical methods fail.
In all these applications, the value of resampling lies in its ability to turn uncertainty into something measurable.
Conclusion
This experiment asked a simple question: What happens if we resample the same dataset 10,000 times? The results showed that the distribution of sample means stabilizes quickly, centers on the true mean, and follows theoretical expectations. The exercise confirmed that averages become more reliable with repetition and highlighted the role of resampling as a bridge between abstract formulas and practical analysis.
Hands-on experiments like this one make statistical concepts more real. Instead of just reading that “sample means are normally distributed,” we saw the pattern emerge through simulation.
If you want to extend this work, try changing the dataset size, introducing outliers, or testing other statistics such as regression coefficients or correlation. Resampling may look like a simple trick, but it remains one of the most versatile and insightful methods in a data scientist’s toolbox.

If you run the code as written, this seed (42) actually produces a mean of 50.193 where the dotted red line is drawn on the histogram. The statement “The resampled distribution is centered around 50, as expected” is a bit off since this actually shows the variation present in resampling!
Thank you Sky for your feedback! We appreciate your contribution to our disussion!