Often we know something has already happened and want to revise the chance of another event. The probability that a student passes changes once we learn that the student attended every class. Conditional probability expresses this revision.

Conditional Probability

The conditional probability of A given that B has occurred is P(A given B) = P(A and B) / P(B), provided P(B) is greater than zero. The knowledge that B happened reduces the sample space to B, and the probability is measured inside it. Rearranging gives the general multiplication rule P(A and B) = P(B) × P(A given B). If A and B are independent, then P(A given B) = P(A).

Definition: Conditional probability. The probability of an event A when it is known that another event B has already occurred, P(A given B) = P(A and B) / P(B).

Total Probability and Bayes' Theorem

Suppose events B1, B2 and B3 are mutually exclusive and exhaustive. The law of total probability gives P(A) = P(B1) P(A given B1) + P(B2) P(A given B2) + P(B3) P(A given B3). Bayes' theorem reverses the conditioning: P(B1 given A) = P(B1) P(A given B1) / P(A). It lets us find the probability of a cause after seeing its effect.

Table 3.3: Quantities in a Bayes problem

Name Symbol Meaning
Prior P(B) Probability of the cause before evidence
Likelihood P(A given B) Probability of the evidence if the cause holds
Total P(A) Probability of the evidence overall
Posterior P(B given A) Probability of the cause after evidence

Example 3.4: Conditional probability with a die

Problem: A die is thrown. Given that the number is even, find the probability that it is greater than 3.

Solution:

  1. Let B = {2, 4, 6} so P(B) = 3/6, and A = {4, 5, 6}.
  2. A and B = {4, 6}, so P(A and B) = 2/6.
  3. P(A given B) = (2/6) / (3/6) = 2/3.

Result: The probability is 2/3.

Example 3.5: Bayes' theorem for defective items

Problem: Machine M1 makes 60 percent of the items and M2 makes 40 percent. Their defective rates are 2 percent and 5 percent. An item is found defective. Find the probability that it came from M2.

Solution:

  1. P(defective) = 0.6 × 0.02 + 0.4 × 0.05 = 0.012 + 0.020 = 0.032.
  2. P(M2 given defective) = 0.020 / 0.032.

Result: The probability is 0.625, so there is a 62.5 percent chance that the item came from M2.

pd = 0.6 * 0.02 + 0.4 * 0.05
print(round(pd, 3), round(0.4 * 0.05 / pd, 3))

Output

0.032 0.625

Common mistakes

  • Confusing P(A given B) with P(B given A).
  • Using P(A) in the denominator instead of P(B) in the conditional formula.
  • Forgetting to compute the total probability before applying Bayes' theorem.

Key takeaways

  • P(A given B) = P(A and B) / P(B).
  • P(A and B) = P(B) × P(A given B).
  • Total probability sums over all causes.
  • Bayes' theorem reverses a conditional probability.

Practice questions

  1. Write the formula for conditional probability.
  2. What does P(A given B) become if A and B are independent?
  3. What does Bayes' theorem find?

Answers to the practice questions

  1. P(A given B) = P(A and B) / P(B).
  2. P(A).
  3. The probability of a cause after the effect is observed.

Sources

  • Official BCA syllabus Probability and Statistics, course code 26BCA403DS01, Unit III