If what you want is a lognormal distribution of n values you can use
the following transformations:

lognorm1 <- M*exp((rnorm(n)*sigma)-sigma^2/2.)

which gives a lognormal distribution such that:
mean(lognorm1)=M ;
var(lognorm1)=M^2*(exp(sigma^2)-1);
Changing the sigma (standard deviation) you always obtain the same
arithmetic mean.

Or, alternatively,

lognorm2 <- exp(m + sigma * rnorm(n))
such that:
exp(mean(log(lognorm2))=exp(m) [geometric mean]
mean(lognorm2)=exp(m + sigma^2/2);
var(lognorm2)=exp(2*m + sigma^2)*(exp(sigma^2/2)-1)
In this case, for different sigma values is the geometric mean to stay
constant, not the arithmetic.

Did it answer your question?

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to