[R] generating random numbers from the logit-normal distribution ?

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Jan 27 08:45:05 CET 2006


On Thu, 26 Jan 2006, Taka Matzmoto wrote:

> Hi R users
>
> I like to generate random numbers from the logit-normal distribution.

which is not a standard distribution.  I guess you mean a random variable 
whose logit is normal (but that is not the only meaning in use).

> Are there available simple commands  I can use?
>
> I used to generate using
>
> exp(rnorm(1000,0,1))/(1+exp(rnorm(1000,0,1)))

That would be incorrect.  I think you mean

> xx <- rnorm(1000, 0, 1)
> exp(xx)/(1+exp(xx))

> I am looking for a simple command such as rnorm().

> plogis(rnorm(1000))

And if that is not simple enough for you, you can write a function 
wrapper like

> rlgnorm <- function(...) plogis(rnorm(...))

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list