rvbern {rv} | R Documentation |
rvbern
generates a random vector where each
simulation comes from a Bernoulli sampling distribution.
rvbern(n=1, prob, logical=FALSE)
n |
number of random scalars to draw |
prob |
probability of ``success"; may be a random vector itself |
logical |
logical; return a logical random variable instead |
rvbern
is a special case of rvbinom
with the argument size=1.
If logical
is TRUE
, the function returns a logical
random variable which has TRUE for 1, FALSE for 0.
(The printed summary of this object is slightly different from a regular
continuous numeric random variable.)
A random vector (an rv object) of length n
.
The resulting vector will not be
independent and identically distributed Bernoulli unless
prob
is a fixed number.
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.
rvbern(10, prob=0.5) rvbinom(10, size=1, prob=0.5) # Equivalent print(rvbern(1, 0.5)) print(rvbern(1, 0.5, logical=TRUE)) # won't show the quantiles print(as.logical(rvbern(1, 0.5))) # equivalent