We examine the TotalPrice variable from the
Diamonds dataset.
# Population parameters
mu <- mean(Diamonds$TotalPrice)
sigma <- sd(Diamonds$TotalPrice)
mu
## [1] 7450.012
sigma
## [1] 7780.894
# Population Histogram
ggplot(Diamonds, aes(x = TotalPrice)) +
geom_histogram(fill = "skyblue", color = "black", bins = 30) +
labs(title = "Population Distribution of Diamond Total Price",
x = "Total Price ($)", y = "Count") +
theme_minimal()
Interpretation: The population distribution of
TotalPrice is strongly right-skewed with a mean of 7450.01
and standard deviation of 7780.89.
We simulate 1,000 random samples of size \(n = 30\) with replacement to construct the empirical sampling distribution of sample means, and overlay the theoretical CLT model \(N(\mu, SE)\).
set.seed(123)
n <- 30
num_sims <- 1000
# Simulate sampling distribution
sample_means <- replicate(num_sims, {
sample_data <- sample(Diamonds$TotalPrice, size = n, replace = TRUE)
mean(sample_data)
})
df_sample_means <- data.frame(sample_means)
# Theoretical SE
SE <- sigma / sqrt(n)
# Plot Sampling Distribution with CLT Normal Overlay
ggplot(df_sample_means, aes(x = sample_means)) +
geom_histogram(aes(y = after_stat(density)), fill = "lightgreen", color = "black", bins = 30) +
stat_function(fun = dnorm, args = list(mean = mu, sd = SE), color = "red", linewidth = 1) +
labs(title = "Sampling Distribution vs. CLT Normal Model (n = 30)",
x = "Sample Mean Total Price ($)", y = "Density") +
theme_minimal()
## Warning: Ignoring unknown parameters: linewidth
# Summary statistics comparison
mean_sim <- mean(sample_means)
sd_sim <- sd(sample_means)
data.frame(
Metric = c("Mean", "Standard Error / SD"),
Theoretical_CLT = c(mu, SE),
Simulated_Empirical = c(mean_sim, sd_sim)
)
## Metric Theoretical_CLT Simulated_Empirical
## 1 Mean 7450.012 7459.631
## 2 Standard Error / SD 1420.590 1405.478
Interpretation: Despite the original population being right-skewed, the sampling distribution of sample means (\(n = 30\)) is nearly symmetric and bell-shaped, aligning closely with the CLT’s theoretical normal curve.
We calculate the probability that a sample mean exceeds \(10,000\).
cutoff <- 10000
# Theoretical CLT Probability
prob_clt <- 1 - pnorm(cutoff, mean = mu, sd = SE)
# Empirical Simulated Proportion
prop_sim <- mean(sample_means > cutoff)
c(Theoretical_CLT = prob_clt, Simulated_Empirical = prop_sim)
## Theoretical_CLT Simulated_Empirical
## 0.03632525 0.05000000
Interpretation: The theoretical probability of drawing a sample mean greater than \(10,000\) is approximately 0.0363. The simulated proportion (0.05) matches closely, with minor variation due to random sampling.
We determine the price cutoff above which 90% of sample means lie (the 10th percentile).
# Theoretical 10th Percentile Cutoff
cutoff_clt <- qnorm(0.10, mean = mu, sd = SE)
# Empirical 10th Percentile Cutoff
cutoff_sim <- quantile(sample_means, 0.10)
c(Theoretical_CLT = cutoff_clt, Simulated_Empirical = cutoff_sim)
## Theoretical_CLT Simulated_Empirical.10%
## 5629.452 5816.595
Interpretation: According to the Central Limit Theorem, 90% of random samples of size \(n = 30\) will have an average total price of at least $5629.45.
This analysis demonstrates the Central Limit Theorem in action: 1. The sampling distribution of sample means approaches normality as sample size increases, even when drawn from a heavily skewed population. 2. The center of the sampling distribution approximates the population mean (\(\mu\)). 3. The variability of sample means is governed by the standard error (\(SE = \sigma / \sqrt{n}\)).