Random Variables
Random numbers
r
for random numnerd
for densityp
for cumulative distributionq
for quantile function
More about functions is here.
The random numbers are not actually random. You can reproduce them by setting seed.
> set.seed(1)
> rnorm(5)
[1] -0.6264538 0.1836433 -0.8356286 1.5952808 0.3295078
> set.seed(1)
> rnorm(5)
[1] -0.6264538 0.1836433 -0.8356286 1.5952808 0.3295078
Sampling
> set.seed(1)
> sample(1:10, 4)
[1] 3 4 5 7
> sample(letters, 4)
[1] "f" "w" "y" "p"
> sample(letters, replace=T)
[1] "q" "b" "f" "e" "r" "j" "u" "m" "s" "z" "j" "u" "y" "f" "q" "d" "g" "k" "a" "j" "w" "i" "m" "p" "m" "e"
With
replace
set to true, the values can repeate.
Last updated
Was this helpful?