Reasoning Under Uncertainty (7hrs) · Introduction to AI

Bayes' theorem and its application to AI reasoning

Watch lectures

Bayes' Theorem and Its Application to AI Reasoning — Beginner-Friendly Notes

1. The Theorem (one line + one formula)

P(H∣E)=P(E∣H)⋅P(H)P(E)P(H|E) = \frac{P(E|H) \cdot P(H)}{P(E)}
  • P(H)P(H) — prior: belief in hypothesis before evidence.
  • P(E∣H)P(E|H) — likelihood: how likely evidence is if hypothesis true.
  • P(H∣E)P(H|E) — posterior: belief after seeing evidence (what we want).
  • P(E)P(E) — evidence normaliser: P(E)=ΣhP(E∣h)P(h)P(E)=\Sigma_h P(E|h)P(h).

Intuition: Posterior ∝ Prior × Likelihood — evidence updates belief.

2. Derivation in One Step

From P(H∧E)=P(H∣E)P(E)=P(E∣H)P(H)P(H \land E)=P(H|E)P(E)=P(E|H)P(H) → rearrange.

3. Mini Example — Spam Filter (AI core use)

Want P(spam∣words)P(spam | words):

  • Prior P(spam)=0.2P(spam)=0.2 (20% mails are spam)
  • Likelihood P(words="offerwin"∣spam)=0.3P(words="offer win" | spam)=0.3, P(words∣ham)=0.01P(words | ham)=0.01
  • P(spam∣words)=0.3⋅0.20.3⋅0.2+0.01⋅0.8≈0.060.068=0.88P(spam|words) = \frac{0.3 \cdot 0.2}{0.3\cdot0.2 + 0.01\cdot0.8} ≈ \frac{0.06}{0.068}=0.88 → classify as spam.

Same pattern for diagnosis, speech, vision — Bayes turns generative knowledge (P(E∣H)P(E|H) easy to model) into diagnostic knowledge (P(H∣E)P(H|E) needed).

4. Naive Bayes (most common AI application — preview Module 5)

Assume words independent given class: P(E1,E2∣H)=P(E1∣H)⋅P(E2∣H)P(E1,E2|H)=P(E1|H)\cdot P(E2|H) → then

P(H∣E1,...,En)∝P(H)⋅ΠiP(Ei∣H)P(H|E1,...,En) \propto P(H) \cdot \Pi_i P(Ei|H)

— simple, surprisingly good for text.

5. AI Reasoning Uses

Task HH EE What Bayes gives
Diagnosis disease symptoms P(disease∣symptoms)P(disease|symptoms)
Spam spam words P(spam∣words)P(spam|words)
Robot localisation position sensor reading P(pos∣sensor)P(pos|sensor)
Speech words spoken audio P(words∣audio)P(words|audio)

6. Common Pitfall

$P(E|H)
eq P(H|E)$ — "90% of spam has 'offer'" does NOT mean "90% of 'offer' mails are spam" — base rate matters (see previous topic's 0.15 example).

7. One-Line Summary

Bayes' theorem P(H∣E)=P(E∣H)P(H)/P(E)P(H|E)=P(E|H)P(H)/P(E) inverts likelihood to posterior, letting AI update prior beliefs with evidence and powering classifiers, diagnosis and state estimation.

8. Quick Self-Check

  1. Compute posterior if P(H)=0.01P(H)=0.01, P(E∣H)=0.9P(E|H)=0.9, $P(E|
    eg H)=0.05$.
  2. Why is P(E)P(E) computed by summing over hypotheses?
Free AppAndroid App

Coursify Android App

Generate AI courses, take quick quizzes between classes, and master complex engineering concepts on the go.

← All Introduction to AI modules