Last active
July 15, 2019 08:34
-
-
Save toyeiei/d43186b16bd59828a2e17b19fd0ffdf2 to your computer and use it in GitHub Desktop.
Central Limit Theorem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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