Description Usage Arguments Details Value Note Author(s) References See Also Examples
Random generator of uniform RV between a and b, exponential, and standard normal RV
1 2 3 |
a |
lower value |
b |
upper value |
rate |
rate parameter of exponential RV |
For didactic purposes, we show how to build custom random number generators from the basic uniform distribution between 0 and 1. The following function defines a uniform generator between a and b using the scaling and shifting of U(0,1).
One value of a RV according to distribution selected
Didactic purposes. Use runif,rexp, rnorm for your real work.
Miguel F. Acevedo Acevedo@unt.edu
Acevedo M.F. 2012. Simulation of Ecological and Environmental Models. CRC Press.
Random number generators runif
, rexp
, rnorm
1 2 3 4 5 6 7 8 9 10 11 | yunif <- array(); a <- 5;b <- 15
for(i in 1:10) yunif[i] <- ran.unif(a,b)
hist(yunif,prob=TRUE); title(sub="Uniform in 5,15")
yexp <- array(); rate <- 1/10
for(i in 1:10) yexp[i] <- ran.exp(rate)
hist(yexp,prob=TRUE); title(sub="Exponential of rate 0.1")
ynorm <- array();
for(i in 1:10) ynorm[i] <- ran.norm()
hist(ynorm,prob=TRUE); title(sub="Std Normal")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.