The answer is a quick one using pnorm: 1.072%. But, that is not satisfying…
n <- 10000
d_3 <- 1/10
d_rest <- 9/10
round(pnorm(931, mean=1000, sd=sqrt(n*d_3*d_rest), lower.tail = TRUE),5)*100
## [1] 1.072
First, lets find out how may times we can expect a “3” in 10,000 random numbers
n <- 10000
trials <- as.tibble(round(runif(n, 1, 9),digits=0))
## Warning: `as.tibble()` is deprecated, use `as_tibble()` (but mind the new semantics).
## This warning is displayed once per session.
trials_3 <- trials%>%
filter(value == 3)%>%
count(value)
count_t <- trials_3$n
count_t
## [1] 1215
count_t/n*100
## [1] 12.15
Next, lets create the 10,000 sim trials
n<-10000
trials_2<-rep(NA, n)
for(i in 1:n){
count_t<-sample(c(0:9),10000, replace=TRUE)
count<-length(count_t[count_t==3])
trials_2[i]<-count
}
(length(trials_2[trials_2<=931])/length(trials_2))*100
## [1] 1
Trial_plot<- as.tibble(trials_2)
ggplot(Trial_plot, aes(x=value)) +
geom_histogram(binwidth=5, color="black", fill="white")