Gundala Viswanath
2009-Feb-11 02:34 UTC
[R] Generating Numbers With Certain Distribution in R
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
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 - IndonesiaTechnically 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
Gustaf Rydevik
2009-Feb-11 13:35 UTC
[R] Generating Numbers With Certain Distribution in R
On Wed, Feb 11, 2009 at 2:15 PM, Ben Bolker <bolker at ufl.edu> wrote:> Bernardo Rangel Tura wrote: > >> 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? > > Yes.No. Bernardo misplaced the parenthesis around (x-min(x)) Correct version is: x <- rlnorm(1e6,meanlog=1,sdlog=1) ## pick any parameters you like y <- round((x-min(x))/diff(range(x))*199999+1) /Gustaf -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40,112 66 Stockholm, SE skype:gustaf_rydevik
Gundala Viswanath
2009-Feb-12 03:18 UTC
[R] Generating Numbers With Certain Distribution in R
Dear all, Thanks so much, the latest version by Gustav work just fine. In the first version, the outcome is more digital than contiguous. - Gundala Viswanath Jakarta - Indonesia On Wed, Feb 11, 2009 at 10:35 PM, Gustaf Rydevik <gustaf.rydevik at gmail.com> wrote:> On Wed, Feb 11, 2009 at 2:15 PM, Ben Bolker <bolker at ufl.edu> wrote: >> Bernardo Rangel Tura wrote: >> >>> 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? >> >> Yes. > > > No. > Bernardo misplaced the parenthesis around (x-min(x)) > Correct version is: > > x <- rlnorm(1e6,meanlog=1,sdlog=1) ## pick any parameters you like > y <- round((x-min(x))/diff(range(x))*199999+1) > > > /Gustaf > > > -- > Gustaf Rydevik, M.Sci. > tel: +46(0)703 051 451 > address:Essingetorget 40,112 66 Stockholm, SE > skype:gustaf_rydevik >