Learn R Programming

baker (version 1.0.4)

rvbern: Sample a vector of Bernoulli variables.

Description

Sample a vector of Bernoulli variables with higher speed (same length with "p"). The Bernoulli random variables can have different means.

Usage

rvbern(p)

Value

A vector of 1s (head) and 0s (tail)

Arguments

p

A vector of probabilities, each being the head probability of an independent coin toss

Examples

Run this code
rvbern(c(0.9,0.1,0.2,0.3))

Run the code above in your browser using DataLab