Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate random numbers with a specified lognormal distribution in R?

I would like to get 20 randomly generated numbers from a lognormal distribution with the geometric mean of 10 and geometric standard deviation of 2.5.

Which R function should I use to accomplish this task?

like image 572
user1009166 Avatar asked Nov 08 '11 22:11

user1009166


1 Answers

The rlnorm function:

rlnorm(20, log(10), log(2.5))

More generally distributions in R are generally available in d(ensity),p(robability),q(uantile),r(andom) forms with those letters coming first followed by the particular distribution stem: norm, lnorm, unif, gamma, ... etc. Their help pages will contain the specifics of the parameters, which can be essential if working with weibull or other distribution for which conventions are not completely standardized (as it were).

like image 184
IRTFM Avatar answered Sep 21 '22 01:09

IRTFM