CHAPTER 9. CENTRAL LIMIT THEOREM

Exercise 10 Page 339

Find the probability that among 10,000 random digits the digit 3 appears not more than 931 times.

Solution

n <- 100000                  # Num of simulations
trial <- rep(0, n)

for(i in 1:n){
  run <- sample(c(0:9),10000, replace=TRUE)
  cnt <- length(run[run == 3])   # Count of run having digit 3
  trial[i] <- cnt               # Save Count
}
hist(trial,col="orange")

As we do this 10,0000 times, according to CLT we would expect the average of these sample means to around 1000.

mu <- mean(trial)
print(mu)
## [1] 1000.018
sigma <- sd(trial)
print(sigma)
## [1] 30.05878
prob <- pnorm(931, mean=mu, sd=sigma, lower.tail = TRUE)

Probability that among 10,000 random digits the digit 3 appears not more than 931 times :- prob = 0.0108349