[R] generate random number
Prof Brian Ripley
ripley at stats.ox.ac.uk
Tue Dec 2 17:41:05 CET 2003
On Tue, 2 Dec 2003, Ragnhild Sørum wrote:
> I would like to generate some(ss) random numbers from a density distribution
> f(x).
> In my case f(x) = a*exp(b*x), ex. a=2, b=0.5, and x is only defined
> between x1 and x2, ex. from -6 to -2.5.
>
> Any suggestions? Can I use rexp?
The inversion method is very simple here: see any good book on Simulation.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list