Chapter 9

Exercise 10.

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

n<-100000
trials<-rep(NA, n)

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

#histogram
hist(trials)

pnorm(931, mean=1000, sd=sqrt(10000*1/10*9/10), lower.tail = TRUE)
## [1] 0.01072411

Answer: 1.097% probability that 3 appears not more than 931 times.