N <- 100
M <- 6
# Part (a)
for(K in 1:100) {
prob_accept <- dhyper(0, M, N-M, K)
if(prob_accept < 0.10) {
cat("K =", K, "Prob =", round(prob_accept, 6), "\n")
break
}
}
## K = 32 Prob = 0.091819
# Part (b)
for(K in 1:100) {
prob_accept <- dhyper(0, M, N-M, K) + dhyper(1, M, N-M, K)
if(prob_accept < 0.10) {
cat("K =", K, "Prob =", round(prob_accept, 6), "\n")
break
}
}
## K = 51 Prob = 0.093314
n_customers <- 1000
p <- 0.5
confidence <- 0.99
# Part (a)
N_binomial <- qbinom(confidence, n_customers, p)
N_binomial
## [1] 537
# Part (b)
mu <- n_customers * p
sigma <- sqrt(n_customers * p * (1 - p))
z_value <- qnorm(confidence)
N_normal <- ceiling(mu + z_value * sigma)
N_normal
## [1] 537
#part a
n <- 60
p <- 1/90
1 - pbinom(4, n, p)
## [1] 0.000556628
# Part b
n_schools_ny <- 310
p_school <- 0.0006
p_at_least_one_ny <- 1 - dbinom(0, n_schools_ny, p_school)
cat("Probability at least one school in NY has the event:", p_at_least_one_ny, "\n")
## Probability at least one school in NY has the event: 0.1697728
#part c
n_states <- 500
p_state <- p_at_least_one_ny
p_at_least_one_national <- 1 - dbinom(0, n_states, p_state)
cat("Probability at least one state has the event in 10 years:", p_at_least_one_national, "\n")
## Probability at least one state has the event in 10 years: 1