Find the probability that among 10,000 random digits the digit 3 appears not more than 931 times
Trying to Solve using simulation
n=100000
datalist = list()
for (i in 1:n) {
samp = sample(c(0:9), 10000, rep = T)
dat <- data.frame(i,length(samp[samp==3])) # checking how many 3 are there and storing it.
datalist[[i]] <- dat
}
big_data = do.call(rbind, datalist)
colnames(big_data)[2] = "trial" # Renaming the column name
lesstrial = subset(big_data, big_data$trial<=931)
prob = nrow(lesstrial)/10000
prob
## [1] 0.1099
#
Approximately 0.1099
% probability that 3 appears not more than 931 times.