Skip to content

Instantly share code, notes, and snippets.

@kohske
Created April 23, 2018 23:20
Show Gist options
  • Save kohske/03cd30a1ef1c9a7d065bdcd25f943708 to your computer and use it in GitHub Desktop.
Save kohske/03cd30a1ef1c9a7d065bdcd25f943708 to your computer and use it in GitHub Desktop.
dist of mean of dist
R=10000; N=1000
xm = numeric(R)
for (i in 1:R) {
#好きなように
xm[i] = mean(rlnorm(N))
# xm[i] = mean(rexp(N))
# xm[i] = mean(runif(N))
}
hist(xm, breaks = 100, probability = TRUE)
library(MASS)
fit = fitdistr(xm, densfun = "normal")
curve(dnorm(x, fit$estimate[1], fit$estimate[2]), add = TRUE, col = "red")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment