pg. 338
2. Let S200 be the number of heads that turn up in 200 tosses of a fair coin.
Estimate
(a) P(S200 =100).
(b) P(S200 =90).
(c) P(S200 =80).
# Number of tosses
n <- 200
# Probability of getting a head
p <- 0.5
# Calculate the mean and standard deviation of the binomial distribution
mu <- n * p
sigma <- sqrt(n * p * (1 - p))
exp_P <- function(x) {
z <- (x - mu) / sigma
(P <- dnorm(x, mean = mu, sd=sigma))
#The dnorm function takes in three arguments: x, mean, and sd, which represent the value at which to evaluate the density, the mean of the distribution, and the standard deviation of the distribution, respectively.
}
(a) P(S200 = 100)
exp_P(100)
## [1] 0.05641896
# The estimated probability of getting exactly 100 heads in 200 tosses of a fair coin
(b) P(S200 = 90)
exp_P(90)
## [1] 0.02075537
# The estimated probability of getting exactly 90 heads in 200 tosses of a fair coin
(c) P(S200 = 80)
exp_P(80)
## [1] 0.001033349
# The estimated probability of getting exactly 80 heads in 200 tosses of a fair coin