Chapter 9, Ex 10

  1. Find the probability that among 10,000 random digits the digit 3 appears not more than 931 times.
n <- 1000
trials <- rep(0, n)

for(i in 1:n){
  rnd <- sample(c(0:9),10000, replace=TRUE)
  count <- length(rnd[rnd == 3])
  trials[i] <- count
}

mu <- mean(trials)
sd <- sd(trials)
pnorm(931, mean=mu, sd=sd, lower.tail = TRUE)
## [1] 0.01505047