I want to generate data from a log-normal distribution, with mean zero and variance equal to 1, in R.
I have tried this so far:
(rlnorm(n = 100000, mean = 0, sdlog = 1) - exp(1/2))/(exp(1)*(exp(1)-1))
Using the wikipedia page, to get the mean and variance on the standard scale. I think that I have centred correctly, as when I calculate the sample mean for this generated data I get a value close to zero. However, the sample variance is not close to 1.
Can just use the formula of the mean and variance for the log-normal distribution on the log scale using the moments on the standard scale, to generate data with variance equal to 1 on the standard scale.
And then centre.
data = ((rlnorm(meanlog = log(1/sqrt(2)), sdlog = sqrt((log(2))), n = 100000) - 1))
mean(data)
var(data)