Example 5. A certain product is manufactured by two factories. The production volume of the second factory exceeds that of the first by 3 times. The defect rate of the first factory is $2 \%$, and that of the second is $1 \%$. Products manufactured by the factories over the same period of time were mixed and sent for sale. What is the probability that the purchased product came from the second factory if it turned out to be defective?
Solution. Let $A$ be the event that a defective item has been purchased, and let $H_{1}$ and $H_{2}$ be the events that the item was produced by the first and second factory, respectively.

Since the volume of production of the second factory is three times the volume of production of the first, then

$$
P\left(H_{1}\right)=\frac{1}{4}, \quad P\left(H_{2}\right)=\frac{3}{4}
$$

From the problem statement, it follows that

$$
P\left(A / H_{1}\right)=0.02, \quad P\left(A / H_{2}\right)=0.01
$$

By the formula of total probability, we get

$$
P(A)=\frac{1}{4} \cdot 0.02+\frac{3}{4} \cdot 0.01=0.0125
$$

According to Bayes' formula, we find the required probability

$$
P\left(H_{1} / A\right)=\frac{P\left(H_{1}\right) P\left(A / H_{1}\right)}{P(A)}=\frac{(1 / 4) \cdot 0.02}{0.0125}=0.4
$$

Similarly, we can find

$$
P\left(H_{2} / A\right)=\frac{P\left(H_{2}\right) P\left(A / H_{2}\right)}{P(A)}=\frac{(3 / 4) \cdot 0.01}{0.0125}=0.6
$$