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

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Fri 27 Jan 2006 - 18:45:05 EST

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@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

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Fri Jan 27 18:59:59 2006

This archive was generated by hypermail 2.1.8 : Fri 27 Jan 2006 - 20:06:38 EST