using the law of total probability and bayes theorem to solve problem about pupils at school
My teacher gives no answer to example questions. Could you please tell me if I have solved it right?
A school has four classes, A, B, C, D, with 10, 20, 30, 30 pupils respectively. The percentage of boys in each of the classes is 70%, 50%, 30%, 20%, respectively. We randomly select one class out of the four classes, where the probabilities to select each class are 0.2, 0.2, 0.2, 0.4 (i.e., class D has a twice as high probability to be selected than the other three classes). From the randomly selected class, we randomly select one pupil such that all pupils within a class have an equal probability to get selected.
a. What is the probability that the selected pupil is a boy (P(pupil=boy))?
I use here law of total probability:
a. (0.2*0.7) + (0.2 * o.5) + (0.2 * o.3) + (0.4 * 0.2) = 1.64 1.64 + (0.2 *0.3) + (0.2 * 0.5) + (0.2 * 0.7) + (0.2 * 0.8) = 2.64 1.64/2.64 = 0.62 (P(pupil = boy))
b. Given that the selected pupil is a boy, what is the probability that the pupil is selected from class A (P(class A| pupil=boy))?
P(class A given pupil = boy) = P(pupil = boy given class A) * P(class A) = 0.028 0.028/0.62 = 0.045
the number of pupils per class is not relevant.
$$\mathbb{P}[\text{Boy}]=0.2\times 0.7+0.2\times0.5+0.2\times 0.3+0.4\times0.2=0.38$$
$$\mathbb{P}[A|\text{Boy}]=\frac{0.14}{0.38}= \frac{7}{19}$$