8.5 Random Number from Exponential Distribution
Rexp
## function (n, alpha)
## {
## return(-log(runif(n))/alpha)
## }
## <bytecode: 0x000001e2a7bf5b88>
## <environment: namespace:math>
Test script
Rexp(1, 0.1)
## [1] 11.41
Rexp(2, 0.1)
## [1] 0.6316 10.7984
= Rexp(10000, 0.1)
x summary(x)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.00 2.83 6.79 9.86 13.72 104.50
sd(x)
## [1] 9.98