On 5/1/05, Matthias Kohl <[EMAIL PROTECTED]> wrote: > >>>I would like to know whether it is possible with R to define a > >>>discrete random variable different from the ones already defined > >>>inside R and generate random numbers from that user-defined > >>>distribution. > >>> > >>Yes. One generic way is to specify the quantile function (as in > >>qpois() etc.) and do qfun(runif(N)). > > > >If the support discrete but also finite, you can also use sample(), e.g. > > > > sample(myset, N, replace = TRUE, prob = myprob) > > one can also use our R package "distr" to generate discrete random > variables. The subsequent code provides a function which generates an > object of class "DiscreteDistribution" based on a finite support "supp". > If "prob" is missing all elements in "supp" are equally weighted.
Thanks you for all your helpful replies to my question. Paul ______________________________________________ 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