Message-ID: <1234344106.14671.30.camel@R1-Thux>
Date: 2009-02-11T09:21:46Z
From: Bernardo Rangel Tura
Subject: Generating Numbers With Certain Distribution in R
In-Reply-To: <loom.20090211T040413-356@post.gmane.org>
On Wed, 2009-02-11 at 04:07 +0000, Ben Bolker wrote:
> Gundala Viswanath <gundalav <at> gmail.com> writes:
>
> >
> > Dear all,
> >
> > Is there a way to generate K numbers of integer (K = 10^6).
> > The maximum value of the integer is 200,000 and minimum is 1.
> >
> > And the occurrences of this integer follows
> > a lognormal distribution.
> >
> > - Gundala Viswanath
> > Jakarta - Indonesia
>
> Technically speaking, I don't think this is possible
> since lognormal variates range from 0 to infinity
> and are continuous. However, perhaps something like
>
> x <- rlnorm(1e6,mulog=1,sdlog=1) ## pick any parameters you like
> y <- round((x-min(x))/diff(range(x)))*199999+1
>
> That probably doesn't do exactly what you want,
> but you will probably need to specify your problem more
> precisely (and perhaps give some context) if you want
> a better answer ...
>
> Ben Bolker
Ben,
I think your routine need a little fix
x <- rlnorm(1e6,meanlog=1,sdlog=1) ## pick any parameters you like
y <- round((x-min(x)/diff(range(x)))*199999+1)
What you think?
--
Bernardo Rangel Tura, M.D,MPH,Ph.D
National Institute of Cardiology
Brazil