ran.unif.exp.norm: Custom random number generators for didactic purposes

Description Usage Arguments Details Value Note Author(s) References See Also Examples

Description

Random generator of uniform RV between a and b, exponential, and standard normal RV

Usage

1
2
3
ran.unif(a,b)
ran.exp(rate)
ran.norm()

Arguments

a

lower value

b

upper value

rate

rate parameter of exponential RV

Details

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).

Value

One value of a RV according to distribution selected

Note

Didactic purposes. Use runif,rexp, rnorm for your real work.

Author(s)

Miguel F. Acevedo Acevedo@unt.edu

References

Acevedo M.F. 2012. Simulation of Ecological and Environmental Models. CRC Press.

See Also

Random number generators runif, rexp, rnorm

Examples

 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") 

seem documentation built on April 14, 2017, 9:12 p.m.