Uniform Random Variables |
---|
\[
f(x) = \begin{cases}
\frac{1}{b-a} , & \quad\mbox{when} \quad a \le x \le b ,
0 , & \quad\mbox{otherwise.} \end{cases}
\]
Here is R code to select ten random numbers between one and five:
[1] 1.784369 1.746213 4.291362 2.145651 3.703616 1.986017 1.449424 1.513132 4.585961
[10] 3.108796
The following functions provide information about the uniform distribution on
the interval from min
to max
: dunif gives the
density, punif gives the distribution function qunif gives the
quantile function and runif generates random deviates. Iheir usage is
demostrated below:
- dunif(x, min = 0, max = 1, log = FALSE)
- punif(q, min = 0, max = 1, lower.tail = TRUE, log.p = FALSE)
- qunif(p, min = 0, max = 1, lower.tail = TRUE, log.p = FALSE)
- runif(n, min = 0, max = 1)
min
or max
are not specified, they assume the
default values of 0 and 1 respectively.
The uniform distribution has density
\[
f(x) = \frac{1}{\mbox{max} - \mbox{min}} .
\]