rvdiscrete {rv} | R Documentation |
Generates random variables from a discrete distribution.
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 kerman@stat.columbia.edu http://www.stat.columbia.edu/~kerman
Kerman, Jouni and Gelman, Andrew. Manipulating and Summarizing Posterior Simulations Using Random Variable Objects. Technical report, Columbia University, New York.
# 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. s <- sort(u) # order distribution Pr(s[8]==10)