Skip to content
GATEiit

GATE CSE · Engineering Mathematics

Conditional probability and Bayes' theorem

Conditional probability, the multiplication rule, independence versus mutually exclusive events, the law of total probability and Bayes' theorem, with tree diagrams for multi-stage problems.

Before you start

  • Counting →

    Equally likely outcomes reduce probabilities to counting, including draws without replacement.

  • Sets: union, intersection, complement

    Events are sets; P(A∪B)=P(A)+P(B)−P(A∩B) is used constantly.

This topic comes before: Random variables

Concept notes

1. Conditional probability and the multiplication rule

The conditional probability of A given B (with P(B)>0) is P(A∣B)=P(A∩B)P(B). Knowing B happened shrinks the sample space to B. With equally likely outcomes this is just counting: P(A∣B)=∣A∩B∣∣B∣.

Multiplication rule: P(A∩B)=P(B) P(A∣B)=P(A) P(B∣A). For a chain of events, P(A1∩A2∩A3)=P(A1) P(A2∣A1) P(A3∣A1∩A2). This handles draws without replacement: the probability that the first two cards are aces is 452⋅351.

Useful facts:

  • P(⋅∣B) is itself a probability: P(Ac∣B)=1−P(A∣B).
  • In general P(A∣B)≠P(B∣A). Confusing the two is the most common error.
  • Complement rule: P(at least one)=1−P(none).
  • Addition rule: P(A∪B)=P(A)+P(B)−P(A∩B).

The condition matters word by word. "At least one child is a boy" and "the elder child is a boy" are different conditions: given two children, the chance both are boys is 13 in the first case and 12 in the second.

2. Independent and mutually exclusive events

A and B are independent if P(A∩B)=P(A) P(B), equivalently P(A∣B)=P(A): knowing B tells nothing about A.

A and B are mutually exclusive (disjoint) if A∩B=∅, so P(A∩B)=0 and P(A∪B)=P(A)+P(B).

Independent Mutually exclusive
Definition P(A∩B)=P(A)P(B) P(A∩B)=0
Union P(A)+P(B)−P(A)P(B) P(A)+P(B)
Knowing B does not change P(A) makes P(A)=0

Key fact: if P(A)>0 and P(B)>0, mutually exclusive events are never independent, since 0≠P(A)P(B).

If A and B are independent, so are A and Bc, Ac and B, and Ac and Bc.

For three events, mutual independence needs all of P(A∩B)=P(A)P(B), P(B∩C)=P(B)P(C), P(A∩C)=P(A)P(C), P(A∩B∩C)=P(A)P(B)P(C). Pairwise independence (the first three) does not imply the fourth. Example: toss two fair coins; A = first is heads, B = second is heads, C = both show the same face. Each pair is independent, but P(A∩B∩C)=14≠18.

3. Total probability and Bayes' theorem

Events B1,…,Bn form a partition if they are mutually exclusive and together cover the sample space (exactly one of them happens).

Law of total probability: P(A)=∑i=1nP(A∣Bi) P(Bi). Split by the cause, then add.

Bayes' theorem reverses the condition: P(Bj∣A)=P(A∣Bj) P(Bj)∑iP(A∣Bi) P(Bi).

  • P(Bj) is the prior (before seeing A).
  • P(A∣Bj) is the likelihood.
  • P(Bj∣A) is the posterior (after seeing A).

Method with a tree diagram:

  1. First level: the causes Bi with their prior probabilities.
  2. Second level: the outcome A (and not A) with conditional probabilities.
  3. Multiply along each path to get joint probabilities.
  4. P(A) is the sum of the paths ending in A; the posterior of a cause is its path divided by that sum.

The denominator is exactly the total probability of A, so most Bayes questions are "total probability, then one division".

AB 0.60.4 0.020.98 0.050.95 D: 0.6 × 0.02 = 0.012 not D: 0.588 D: 0.4 × 0.05 = 0.020 not D: 0.380 P(D) = 0.012 + 0.020 = 0.032; P(A | D) = 0.012 / 0.032 = 0.375
Tree for two machines A (60% of output, 2% defective) and B (40%, 5% defective): multiply along branches, add the D paths, then divide.

4. Base rates and common patterns

Base-rate effect. When the prior of a cause is small, even an accurate test gives a modest posterior. A disease with prevalence 1%, a test that detects it 99% of the time and gives a false positive 5% of the time: P(disease∣+)=0.01×0.990.01×0.99+0.99×0.05=0.00990.0594=16. Most positives come from the large healthy group.

Patterns that recur:

  • Which source? Several machines, boxes or senders produce an item; given a property of the item, find the source. Use Bayes.
  • Sequential draws without replacement: use the multiplication rule. By symmetry, the probability that the k-th ball drawn is red equals the probability the first is red.
  • Conditioning on a later draw: P(1st red∣2nd red) is found by Bayes or by symmetry; it equals P(2nd red∣1st red).
  • Repeated independent trials: "at least one success in n trials" is 1−(1−p)n.
  • Coin or die chosen at random, then tossed: a two-level tree.

Checks: posteriors over all causes add to 1; every probability lies in [0,1]; P(A∣B)=1 when B⊆A.

Write fractions as long as possible and divide once at the end; it keeps rounding errors out of NAT answers.

Formulas to remember

Conditional probability
P(A∣B)=P(A∩B)P(B)
Multiplication rule
P(A∩B)=P(B) P(A∣B)
Addition rule
P(A∪B)=P(A)+P(B)−P(A∩B)
Independence
P(A∩B)=P(A) P(B)
Total probability
P(A)=∑iP(A∣Bi) P(Bi)
Bayes' theorem
P(Bj∣A)=P(A∣Bj) P(Bj)∑iP(A∣Bi) P(Bi)
At least one successn independent trials, success probability p
P(at least one)=1−(1−p)n

Common mistakes

  • Confusing P(A | B) with P(B | A); Bayes' theorem is the bridge between them.
  • Treating mutually exclusive events as independent; with non-zero probabilities they never are.
  • Ignoring the base rate (prior) in test and detection questions.
  • Multiplying probabilities of draws without replacement as if they were independent.
  • Assuming pairwise independence of three events gives mutual independence.
  • Misreading the condition: 'at least one is a boy' is not the same as 'the elder is a boy'.

Worked examples

Try each step yourself, then reveal the working.

Example 1: Conditioning by counting

numerical

Two fair dice are rolled. Find the probability that the sum is 8, given that the first die shows an even number.

  1. Step 1: Count the reduced sample space.

    Try it on paper first.

Example 2: Which machine made the defective item?

numerical

Machine A makes 60% of the items and 2% of its items are defective. Machine B makes 40% and 5% of its items are defective. An item is found defective. Find the probability it came from A.

  1. Step 1: Find the total probability of a defective item.

    Try it on paper first.

Example 3: A positive test for a rare condition

numerical

1% of a population has a condition. A test is positive for 99% of those with it and for 5% of those without it. A person tests positive. Find the probability they have the condition.

  1. Step 1: Write the two paths that end in a positive test.

    Try it on paper first.

Example 4: Can disjoint events be independent?

conceptual

A and B are mutually exclusive with P(A)=0.3 and P(B)=0.4. Are they independent?

  1. Step 1: Compute P(A ∩ B) from the definition of disjoint.

    Try it on paper first.

Previous year questions

12 official GATE CSE questions on this topic, newest first.

Practise these 12 PYQs →

Topic test

10 questions: up to 4 official PYQs and original practice questions, with GATE marking (MCQ wrong answers lose marks). Score 60% or more to pass. A new set is drawn each time.

Mark as mastered

Loading your progress…

My revision notes

Notes written by the GATEiit team against the official GATE CSE syllabus; being checked by a reviewer. Updated 2026-11-21. Spotted a mistake? Use Report an issue on any question, or contact us.