Discrete Distribution
Discrete.RdThese functions provide information about the discrete distribution
where the probability of the elements of values is proportional
to the values given in probs, which are normalized to sum up to
1. ddiscrete gives the density, pdiscrete gives the
distribution function, qdiscrete gives the quantile function
and rdiscrete generates random deviates.
Details
The random number generator is simply a wrapper for
sample and provided for backwards compatibility only.
Examples
## a vector of length 30 whose elements are 1 with probability 0.2
## and 2 with probability 0.8.
rdiscrete (30, c(0.2, 0.8))
#> [1] 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 1 2 2 2 2 1 2 2 2 2 2 2 2
## a vector of length 100 whose elements are A, B, C, D.
## The probabilities of the four values have the relation 1:2:3:3
rdiscrete (100, c(1,2,3,3), c("A","B","C","D"))
#> [1] "D" "C" "C" "C" "B" "A" "D" "D" "B" "C" "C" "C" "D" "B" "B" "A" "A" "C"
#> [19] "C" "D" "D" "C" "C" "B" "D" "B" "D" "C" "B" "D" "C" "C" "C" "D" "A" "C"
#> [37] "C" "D" "C" "C" "D" "C" "C" "D" "C" "C" "B" "C" "C" "C" "D" "D" "C" "A"
#> [55] "C" "D" "B" "D" "A" "D" "C" "B" "B" "D" "C" "B" "D" "C" "B" "B" "C" "D"
#> [73] "C" "B" "C" "C" "C" "B" "B" "B" "D" "B" "A" "C" "C" "B" "C" "C" "B" "C"
#> [91] "D" "A" "B" "D" "C" "B" "D" "D" "D" "C"