Compute P(Bag B | red) via Bayes
MicrosoftData Scientist · Technical ScreenLast updated
This question evaluates understanding of Bayes' rule and conditional probability by requiring computation of the posterior probability that a particular bag was chosen given a red draw.
Three bags contain red (r) and green (g) balls:
- Bag A: 4 r, 6 g
- Bag B: 6 r, 4 g
- Bag C: 3 r, 7 g Process: pick a bag uniformly at random, then draw one ball from that bag. Given the drawn ball is red, compute the posterior probability that it came from Bag B, i.e., P(B | red). Show all steps using Bayes’ rule. Follow-up: if instead the bag is chosen with probabilities P(A)=0.2, P(B)=0.5, P(C)=0.3, recompute P(B | red) and explain the intuition for how the prior changes the result.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.