In: Statistics and Probability
Use R to tackle the following problem
. A box initially contains 8 blue balls and 4 red balls. Terry closes his eyes and randomly picks a ball and then follows the following procedure: if it is a blue ball, he puts the blue ball back in, and also adds another blue ball; if it is a red ball, then he removes the red ball from the bin and in addition, removes another red ball. Suppose you did not see what Terry did and close your eyes and pick a ball at random and it is red; then what is the probability that Terry picked a blue ball?
Prob (Blue) = 8/12 = 0.667
Prob (red) = 4/12 =0.333
Prob (red | blue) = 4/(12+1) = 0.307692 (As another blue ball will be added by Terry)
Prob (red | red) = 2/ (12-2) = 0.2 (As Terry will remove two red balls if red is picked)
Prob (red picked by you) = P(red | blue) * Prob (Blue) + Prob (red | red) * Prob (red)
= 0.307692*0.6667 + 0.2*0.3333
= 0.20513 + 0.06667 = 0.2718
So using Baye's formula
Probability (blue | red) = (Prob (Blue) * Prob (Red | Blue))/ Prob (Red)
= (0.6667 * 0.307692) / 0.2718 = 0.7547
So the updated probability that Terry picked a blue ball if you pick a red ball at random is 75.47%.
Hope this is clear.