A website wants to detect if a visitor is a robot or a human. They give the visitor five CAPTCHA tests that are hard for robots but easy for humans. If the visitor fails one of the tests, they are flagged as a robot. The probability that a human succeeds at a single test is 0.95, while a robot only succeeds with probability 0.3. Assume all tests are independent. The percentage of visitors on this website that are robots is 5%; all other visitors are human.
a. If a visitor is actually a robot, what is the probability they get flagged (the probability they fail at least one test)?
1 - (0.3)^5
b. If a visitor is human, what is the probability they get flagged?
1 - (0.95)^5
c. Suppose a visitor gets flagged. Using your answers from part (a) and (b), what is the probability that the visitor is a robot?
How do I reverse engineer the answers to (a) and (b) to find the probability that the visitor is a robot?
d. If a visitor is human, what is the probability that they pass exactly three of the five tests?
Firstly, note the probability a user fails the test is 1 minus the probability they pass the test, so $ \mathbb{P}\left( \text{Flag}|\text{Robot} \right) =1-0.3=0.7$ and $ \mathbb{P}\left( \text{Flag}|\text{Human} \right) =1-0.95=0.05$.
Bayes’ Law gives that for suitable events $A$ and $B$,
$$\mathbb{P}\left( A|B\right) = \dfrac{ \mathbb{P}\left(B|A \right) \mathbb{P}\left( A \right) }{\mathbb{P}\left( B\right) }.$$
If you haven’t seen this before, you can derive it by writing out the definition of conditional probability for both $A|B$ and $B|A$, then equate the two expressions which arise for $\mathbb{P}\left( A\cap B\right) $ with some rearrangement.
The other result we will need from the theory is the ‘partition theorem’, or ‘law of total probability’. These say that if two events $A$ and $B$ are disjoint and together describe all possible events, then the probability of some event $E$ is the sum of the probabilities of $E|A$ and $E|B$, ie all the possible ways $E$ can happen. We can write this for two events as follows:
$$\text{If } A\cap B=\emptyset \text{ and } \mathbb{P}\left(A\cup B \right) =1, \text{ then for some event } E,\\ \mathbb{P}\left( E \right) = \mathbb{P}\left( E|A\right) + \mathbb{P}\left( E|B \right).$$
Now using $E$ to be the event that the system flags a user as being a robot, we have
$$\mathbb{P}\left( \text{Flagged} \right)\\ =\mathbb{P}\left( \text{Flagged} | \text{Robot} \right) + \mathbb{P}\left( \text{Flagged} | \text{Human} \right)\\ = 0.7+0.05=0.75.$$
Finally we can use Bayes’ Theorem with $A$ the event the user is a robot and $B$ the event the user is a human, with the information from the preamble telling us that $\mathbb{P}\left( \text{Human} \right) =0.95,\mathbb{P}\left( \text{Robot} \right) =0.05$. So we see
$$\mathbb{P}\left( \text{Robot} | \text{Flagged}\right) = \dfrac{ \mathbb{P}\left(\text{Flagged} |\text{Robot} \right) \mathbb{P}\left( \text{Robot} \right) }{\mathbb{P}\left( \text{Flagged}\right) }\\ =\dfrac{0.7\times 0.05}{0.75}=\dfrac{7}{150}.$$
Hope this helps! Stay safe