Please go to Dropbox folder (link in Course Introduction and Materials) and find the R Markdown file (.RmD extension) for the Central Limit Theorem (CLT) code.
set.seed(seed = 15)
The Law of Large Numbers states that as the number of independent trials within a sample increases, the sample mean will get closer to the true mean (\(lim_{trials \to \infty}\)). For example, flipping a coin has a true expected for landing on heads of 50%. If you flip it 10 times and get heads 7 times, the observed result is 70%. If you flip it another 10 times and get heads twice, the observed result is now 45%. As you continue to flip more coins, the observed result will continue to get closer to 50%.
You can, and should read your textbook and/or online references to understand what is CLT, its uses, et cetera. Furthermore, if you find any useful resource, include it in your post so that the rest of the class can have a look at it to.
The Central Limit Theorem (CLT) states that if you take repeated random samples from any population, regardless of the shape of that population’s distribution, and calculate the mean of each sample, the distribution of those sample means will approach a normal distribution as sample size grows larger (\(lim_{samples \to \infty}\)). For example, if you roll a six-sided die 30 times and calculate the average of those rolls, roll another 30 and calculate the average of all 60 rolls, and continue that process many times, the distribution of those averages will form a bell curve around the true mean of 3.5.
| Similarities | Differences |
|---|---|
|
|
Please describe this distribution first in 5 lines.
?dhyper
## starting httpd help server ... done
The hypergeometric distribution is a discrete probability distribution model that uses dependent Bernoulli trials. It models the total number of successes in a fixed-size sample drawn without replacement from a finite population. This distribution has three parameters: M for the size of the population, K for the number of items with the desired characteristic within that population, and n for the number of samples that are drawn. \(dhyper\) gives the density of the distribution, \(phyper\) is the cumulative distribution function, and \(qhyper\) is the quantile function. \(rhyper\) generates random samples.
N <- 1000
K <- 400
n <- 50
p <- K / N
num_sims <- 10000
set.seed(seed = 15)
simulated_successes <- rhyper(num_sims, m = K, n = N - K, k = n)
sample_means <- simulated_successes / n
step <- 1 / n
all_possible_means <- seq(0, 1, by = step)
hist_breaks <- seq(-step/2, 1 + step/2, by = step)
expected_mean <- p
fpc <- (N - n) / (N - 1)
theoretical_var <- (p * (1 - p) / n) * fpc
theoretical_sd <- sqrt(theoretical_var)
hist(sample_means,
breaks = hist_breaks, probability = TRUE,
xaxt = "n",
xlim = c(.15, .65),
main = "",
xlab = "Sample Mean (X̄)",
col = "lightblue",
border = "white")
axis(side = 1, at = seq(0.15, .65, by = .05))
abline(v = expected_mean, col = "darkgreen", lty = 2, lwd = 1.5)
curve(dnorm(x, mean = expected_mean, sd = theoretical_sd),
add = TRUE, col = "darkred", lwd = 1)
legend("topright", legend = c("Simulated Means", "Normal Curve", "True Mean (0.4000)"),
fill = c("lightblue", NA, NA), border = c("white", NA, NA),
lty = c(NA, 1, 2), col = c(NA, "darkred", "darkgreen"), lwd = c(NA, 2, 1.5))
The Central Limit Theorem (CLT) holds up for this distribution because the sample size used is large enough, the success rate for the population is relatively close to 0.50, it properly applies the Finite Population Correction (FPC) factor, and there is a high number of simulations. Normally, a sample size of at least 30 is considered sufficient to satisfy the CLT. In this distribution, sample sizes of 50 are used. For the application of the CLT, the probability of success (K/N) cannot be extremely close to 0 or 1. For this distribution, the success probability is 0.40 and therefore the expected number of successes and failures are each at least 10. Due to multiplying the theoretical variance by \(\frac{N - n}{N - 1} = \frac{1000 - 50}{1000 - 1}\), this distribution correctly applies the FPC. Since the CLT guarantees the theoretical shape of the sampling distribution as \(\lim_{n \to \infty}\), running 10,000 simulations is more than enough to ensure that random sampling noise is eliminated.