psi.rbern.Rd
Simulate a random sample from the Bernoulli distribution.
psi.rbern(n, p)
n | number of observations. |
---|---|
p | probability of success. |
A random variable has the Bernoulli(p) distribution if takes the value one with probability \(p\) and the value zero with probability \(1-p\).
The Bernoulli(p) distribution is a particular case of the binomial distribution with \(n=1\).
a numeric vector representing a random sample from Bernoulli(p)
psi.rbern(10, 0.5) # 10 draws of a fair coin#> [1] 1 0 1 0 1 1 0 0 0 0psi.rbern(10, 0.6) # 10 draws of a biased coin#> [1] 0 0 1 1 0 0 1 1 0 1#> [1] 0 0 0 1 1 0 1 0 0 0#> [1] 1 1 1 1 1 1 1 0 0 0