A factory produces bolts with a defective rate that changes randomly and independently from day to day but is constant throughout any given day. Let $p_i$ denote the defective rate on day i, and suppose that $p_1,p_2 ~iid Beta(1,19)$.
For every bolt produced on day i, assume that there is a probability of $p_i$ that it is defective, irrespective of which other bolts produced by the factory are defective.
(a) A random sample of 100 bolts is taken from the output of the factory on day 1. Find the probability that none of these 100 bolts are defective.
(b) A random sample of 200 bolts is taken from the output of the factory on days 1,...,100, two bolts per day. Calculate, or approximate as best you can, q, the probability that at least 20 of these 200 bolts are defective.
I have some trouble finding the $\mu, \sigma^2$ of Yi, which I define to be the number of defectives on day i, i=1,...,100. I know $Y_i|p_i~follows~Bin(2,p_i)$, but I am unclear how to apply law of iterated expectation to this question here.
Any help would be much appreciated! Thanks a lot!
This is a beta-binomial hierarchical model. Each $p_i$ is a realization of a beta random variable, and conditioned on $p_i$, $Y_i$ is binomial with parameters $n_i$ and $p_i$ where $n_i$ is the number of bolts sampled on day $i$. The model specification is $$P \sim \operatorname{Beta}(1, 19) \\ Y \mid P \sim \operatorname{Binomial}(n, P)$$ where $n$ is known. For a fixed $n = 2$, the unconditional distribution of $Y$ is $$\begin{align} \Pr[Y = y] &= \int_{p=0}^1 \Pr[Y = y \mid P = p] f_P(p) \, dp \\ &= \int_{p=0}^1 \binom{2}{y} p^y (1-p)^{2-y} 19 (1-p)^{18} \, dp \\ &= 19 \binom{2}{y} \frac{\Gamma(21-y)\Gamma(1+y)}{\Gamma(22)} \\ &= \begin{cases} 19/21, & y = 0 \\ 19/210, & y = 1 \\ 1/210, & y = 2. \end{cases} \end{align}$$ This is a special case of a beta-binomial PMF with parameters $n = 2$, $\alpha = 1$, $\beta = 19$.
Consequently, the probability that at least $20$ bolts out of $200$ sampled are defective is simply $$\Pr\left[\sum_{i=1}^{100} Y_i \ge 20\right]$$ where each $Y_i$ is iid distributed as $Y$ above. This is well-approximated by a suitable normal distribution, which I leave to you as an exercise.