Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Visual Demo | Section
Statistics for Data Analysis

bookVisual Demo

Sveip for å vise menyen

Understanding the Central Limit Theorem (CLT) is much easier when you see it in action. Visualization allows you to watch how the distribution of sample means changes as you increase your sample size. By plotting both the original population and the sample means for different sample sizes, you can see how the CLT works and why it is so important in statistics.

123456789101112131415161718192021222324252627282930
import numpy as np import matplotlib.pyplot as plt # Set random seed for reproducibility np.random.seed(42) # Generate a non-normal population: exponential distribution (skewed) population = np.random.exponential(scale=2, size=10000) fig, axes = plt.subplots(1, 4, figsize=(20, 4)) # Plot the original population distribution axes[0].hist(population, bins=50, color="skyblue", edgecolor="black") axes[0].set_title("Population (Exponential)") axes[0].set_xlabel("Value") axes[0].set_ylabel("Frequency") sample_sizes = [2, 10, 30] for i, n in enumerate(sample_sizes, 1): sample_means = [] for _ in range(1000): sample = np.random.choice(population, size=n) sample_means.append(np.mean(sample)) axes[i].hist(sample_means, bins=30, color="salmon", edgecolor="black") axes[i].set_title(f"Sample Means (n={n})") axes[i].set_xlabel("Sample Mean") axes[i].set_ylabel("Frequency") plt.tight_layout() plt.show()
copy
12345678910111213141516171819202122
import seaborn as sns sample_sizes = [2, 10, 30] sample_means_dict = {} for n in sample_sizes: sample_means = [] for _ in range(1000): sample = np.random.choice(population, size=n) sample_means.append(np.mean(sample)) sample_means_dict[n] = sample_means plt.figure(figsize=(10, 6)) colors = ["#FFA07A", "#20B2AA", "#9370DB"] for n, color in zip(sample_sizes, colors): sns.histplot(sample_means_dict[n], bins=30, kde=True, color=color, label=f"n={n}", stat="density", alpha=0.6) plt.title("Overlay of Sample Means Distributions") plt.xlabel("Sample Mean") plt.ylabel("Density") plt.legend() plt.show()
copy

As you saw in the visualizations, the original population distribution was highly skewed and not normal. However, as you increased the sample size, the distribution of the sample means became more symmetric and bell-shaped. Even when the underlying population is not normal, the sample means approach a normal distribution as sample size grows. This is the essence of the Central Limit Theorem: regardless of the population's shape, the distribution of sample means will tend toward normality as the sample size increases.

question mark

Which statement best describes what you observed in the visual demonstration of the Central Limit Theorem?

Select the correct answer

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 1. Kapittel 30

Spør AI

expand

Spør AI

ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

Seksjon 1. Kapittel 30
some-alt