Description Usage Arguments Details Author(s) References Examples
Generates random variables from a discrete distribution (from a finite population with replacement).
1 | rvdiscrete(n = 1, x, prob = NULL)
|
n |
integer: number of scalars to generate |
x |
values of the distribution |
prob |
probabilities (optional, default: all equal) |
Computes a random vector of length n
, consisting of identicallly
distributed discrete random scalars with the discrete distribution with
values x
and corresponding probabilities prob
. If prob
is not given, all values are considered equally distributed.
Jouni Kerman jouni@kerman.com
Kerman, J. and Gelman, A. (2007). Manipulating and Summarizing Posterior Simulations Using Random Variable Objects. Statistics and Computing 17:3, 235-244.
See also vignette("rv")
.
1 2 3 4 5 6 7 8 9 10 11 12 | ## Not run:
# 8 people draw a number each from 1..10 with replacement.
# What is the probability that the highest number of the eight is "10"?
u <- rvdiscrete(n=8, x=1:10) # 8 iid variables from the discrete uniform 1:10.
Pr(max(u)==10)
# What is the probability that the person with the 3rd smallest number
# has at least "3"?
s <- sort(u) # order distribution
Pr(s[3]>=3)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.