Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Central Limit Theorem
## look at dataframe diamonds
library(tidyverse)
glimpse(diamonds)
## assume this is all prices (population)
pop_prices <- diamonds$price
## sample n=30, repeats 1000 times
sam_prices <- replicate(
1000, mean(sample(pop_prices, size = 30))
)
## check if the mean of sample means is close to the population mean
summary(pop_prices)
summary(sam_prices)
## look at the histogram
hist(sam_prices, xlim = c(1000, 7000))
## let's change line 10, size=1000. Look at the histogram again.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment