Foundations of Probability in R
David Robinson
Chief Data Scientist, DataCamp
50% chance of heads
50% chance of tails
rbinom(1, 1, .5)
# [1] 1
rbinom(1, 1, .5)
# [1] 0
rbinom(10, 1, .5)
# [1] 0 1 1 0 1 1 1 0 1 0
rbinom(10, 1, .5)
# [1] 0 0 0 1 0 1 0 1 0 0
rbinom(1, 10, .5)
# [1] 4
rbinom(10, 10, .5)
# [1] 3 6 5 7 4 8 5 6 4 5
rbinom(10, 10, .8)
# [1] 6 7 9 10 7 7 8 9 9 8
rbinom(10, 10, .2)
# [1] 2 2 1 2 2 4 3 1 0 2
$$X_{1\ldots n} \sim \text{Binomial}(\text{size}, p)$$
Foundations of Probability in R