Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Probability  ›  Lesson

Bayes' Theorem

Bayes Theorem 15 minBayes' theorem reverses a conditional probability by weighting the likelihood with the prior and dividing by how common the evidence is.

Bayes' Theorem

The agency buys a fake-listing detector. It catches 90% of fake listings and wrongly flags only 10% of genuine ones. A listing gets flagged. Is it 90% likely to be fake? Most people say yes, and most people are badly wrong. Bayes' theorem shows why.

The rule

Reverse a condition: likelihood times prior, divided by evidence.

The detector tells you P(flag∣fake)P(\text{flag} \mid \text{fake}). You want the reverse, P(fake∣flag)P(\text{fake} \mid \text{flag}). Bayes' theorem connects them:

P(A∣B)=P(B∣A) P(A)P(B)P(A \mid B) = \frac{P(B \mid A) \, P(A)}{P(B)}
  • Prior P(A)P(A): how common the cause is before any evidence. Here 5% of listings are fake.
  • Likelihood P(B∣A)P(B \mid A): how often the evidence appears when the cause is true. Here 0.9.
  • Evidence P(B)P(B): how often the evidence appears at all, from any cause.
  • Posterior P(A∣B)P(A \mid B): the updated belief after seeing the evidence.

Check it on last lesson's 20 flats: P(near∣fast)=0.75×0.4/0.6=0.5P(\text{near} \mid \text{fast}) = 0.75 \times 0.4 / 0.6 = 0.5, the same answer the table gave by counting.

Bayes' theorem also chains. If a second, independent check flags the same listing, today's posterior of 0.32 becomes the prior for that update, and the belief climbs again. Learning from evidence is repeated Bayesian updating.

A naive Bayes classifier uses this rule directly: it multiplies the likelihoods of each feature (each word in a listing, say) with the prior for each class, and picks the class with the higher result.

The shortcut

Natural frequencies. Imagine a round number of cases, such as 1000, and split them down a tree. Then the posterior is a simple fraction you can read off, with no formula to misremember.

Is a flagged listing fake?Step 1 of 4
  1. Start with 1000

    5% are fake: 50 fake listings and 950 genuine ones.

The detector is good, but fakes are rare, so a small false-alarm rate applied to the large genuine group produces more flags than the real fakes do. Ignoring the prior is called base-rate neglect, and it is the trap this lesson is about.

Drills

Answer fast — trust the rule.

quick drill

From the 20-flat table, P(fast given near) = 0.75, P(near) = 0.4 and P(fast) = 0.6. What is P(near given fast)?

quick drill

Out of 1000 listings (50 fake), how many genuine listings does the detector wrongly flag?

quick drill

What is the chance that a flagged listing is actually fake?

quick drill

If fakes were 50% of listings, with the same detector, what would P(fake given flag) be?

quick drill

In this problem, which quantity is the prior?

Remember

  • Reverse a condition: likelihood times prior, divided by evidence.
  • Shortcut: imagine 1000 cases, split them down a tree, read off the fraction.
  • Trap: base-rate neglect, forgetting how rare the cause is.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainIs a flagged listing fake?

A detector flags 90% of fake listings and 10% of genuine ones, and 5% of listings are fake. Explain, with natural frequencies, the chance that a flagged listing is actually fake, and why the answer is so much lower than 90%.