- Use R to simulate the random outcomes from flipping a fair coin 10 times.
Answer: the probability experiment is flipping a coin once; this experiment
is repeated 10 times. A binomial random variable is the sum of
a specified number of
independent outcomes from a Bernoulli random variable. We will see why this type
of random variable is called a binomial random variable later.
// Here are the meanings of the R arguments:
// n = number of times the experiment is repeated
// size = number of Bernoulli outcomes in one experiment
// prob = the probability of success for Bernoulli rv.
rbinom(n=10, size=1, prob=0.5)
[1] 1 0 0 1 1 1 1 0 0 1
- Use R to simulate 20 repetitions of flipping a coin 2 times.
Answer: in this case, n = 20, size = 2, and prob = 0.5.
> rbinom(n=20, size=2, prob=0.5)
# or
> rbinom(20, 2, 0.5)
[1] 1 2 1 2 0 1 1 1 0 2 0 2 2 2 0 1 1 1 1 1
- Use R to simulate flipping a fair coin one million times.
Repeat the experiment twice. Answer:
> > rbinom(2, 1000000, 0.5)
[1] 500664 499815
- Elena Delle Donne is the best free throw shooter in WNBA history with a
career average of 93.4%. Simulate 10 seasons of shooting 90 free throws per
season with a success rate of 93.4%. Answer:
> rbinom(10, 90, 0.934)
[1] 79 82 84 87 86 81 85 86 82 87