1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| \ \ x <- log(rlnorm(1000))*500 h <- hist(x, ylim = c(0, 300)) xfit <- seq(min(x),max(x),length=500) yfit <- dnorm(xfit, mean=mean(x), sd=sd(x)) yfit <- yfit*diff(h$mids[1:2])*length(x) lines(xfit, yfit, col="blue", lwd=2)
\ \ x <- rlnorm(1000)*1000 h <- hist(x, ylim = c(0, 1000), breaks = 25) xfit <- seq(min(x),max(x),length=500) yfit <- dlnorm(xfit, meanlog=log(mean(x)), sdlog=sd(log(x))) yfit <- yfit*diff(h$mids[1:2])*length(x) lines(xfit, yfit, col="blue", lwd=2)
\ \ x <- rlnorm(1000)*1000 h <- hist(x, breaks = 25) xfit <- seq(min(x),max(x),length=500) yfit <- density(x, n = length(xfit))$y yfit <- yfit*diff(h$mids[1:2])*length(xfit) lines(xfit, yfit, col="blue", lwd=2)
|