[R] generate random number of any given distribution
Spencer Graves
spencer.graves at pdf.com
Sat Jan 17 01:47:40 CET 2004
Hello, Yan:
Are you aware that for all the standard distributions, R provides
the probability density, the cumulative distribution function, the
quantile function, and random number generation? When you said,
"besides uniform and gaussian", I wondered. The convention is that the
first letter of the function is d, p, q, and r, for these 4 functions,
followed by the name or abbreviation of the distribution. Thus, rexp =
random numbers for the exponential distribution, rbeta = beta r.n., rt =
Student's t, rf = F distribution, etc.
hope this helps.
spencer graves
Liaw, Andy wrote:
>If you can compute the quantile function of the distribution (i.e., the
>inverse of the integral of the pdf), then you can use the probability
>integral transform: If U is a U(0,1) random variable and Q is the quantile
>function of the distribution F, then Q(U) is a random variable distributed
>as F.
>
>This is not necessarily the most efficient way of generating the random
>number, but it may be the only way in some cases.
>
>HTH,
>Andy
>
>
>
>>From: Yan Yu
>>
>>Hello,
>>Is there a function in R to generate random number of any given
>>distribution (its pdf is given), besides uniform and gaussian
>>distribution?
>>
>>Thanks,
>>yan
>>
>>
>
>
>------------------------------------------------------------------------------
>Notice: This e-mail message, together with any attachments,...{{dropped}}
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
>
More information about the R-help
mailing list