Skip to content

generate random number of any given distribution

2 messages · Liaw, Andy, Spencer Graves

#
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
------------------------------------------------------------------------------
Notice:  This e-mail message, together with any attachments,...{{dropped}}
#
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: