Chapter 9 Pg. 338 Exercise 1

We’ll solve the below problems using simulation. We’ll set up a uniform distirbution and simulate 100 tosses of a fair coin. We’ll do this 10K times and then count up how many times we met our criteria out of 10K to get our probability.

Let \({ S }_{ 100 }\) be the number of heads that turn up in 100 tosses of a fair coin. Use the Central Limit Theorem to estimate

(a)\({ P(S }_{ 100 }\le 45)\):

count <- c()

for (i in seq(1,10000)) {
z <- runif(100, min = 0, max = 1)

count <- c(count, length(z[z>=.5]))


}

final_count <- length(count[count<=45])
final_count/10000
## [1] 0.1832

(b)\({ P(45<S }_{ 100 }<55)\):

count <- c()

for (i in seq(1,10000)) {
z <- runif(100, min = 0, max = 1)

count <- c(count, length(z[z>=.5]))


}

final_count <- length(count[count>45 & count <55])
final_count/10000
## [1] 0.6376

(c)\({ P(S }_{ 100 }>63)\):

count <- c()

for (i in seq(1,10000)) {
z <- runif(100, min = 0, max = 1)

count <- c(count, length(z[z>=.5]))


}

final_count <- length(count[count>63])
final_count/10000
## [1] 0.0024

(d)\({ P(S }_{ 100 }<57)\):

count <- c()

for (i in seq(1,10000)) {
z <- runif(100, min = 0, max = 1)

count <- c(count, length(z[z>=.5]))


}

final_count <- length(count[count<57])
final_count/10000
## [1] 0.9035