How to Animate Bayes' Theorem | QuantumSketch

Animate Bayes' theorem with a shrinking population grid: start with everyone, filter by the test result, and the surviving squares reveal the true probability.

By Shihab
2 min read

Animate Bayes' theorem with a shrinking population grid: start with everyone, color who's actually affected, apply the test, then keep only the positives โ€” the surviving squares reveal the real probability. This makes the false-positive paradox unforgettable.

The theorem

P(AโˆฃB)=P(BโˆฃA)โ€‰P(A)P(B)P(A \mid B) = \frac{P(B \mid A)\,P(A)}{P(B)}

"The probability of A given evidence B." Abstract โ€” until you count people.

The grid animation, beat by beat

  1. Draw 10,000 squares = the whole population.
  2. Color 1% (100 people) as having the disease.
  3. Apply a 99%-accurate test: ~99 sick test positive (true positives); ~99 of the 9,900 healthy also test positive (false positives).
  4. Keep only the positives โ€” fade the rest away.
  5. Count: ~99 truly sick out of ~198 positives โ†’ only ~50% are actually sick.

Why this shocks people

| Intuition | Reality | |---|---| | "99% accurate โ†’ I'm 99% sick" | Only ~50% | | Ignores base rate | The healthy group is huge |

The animation shows why: the small disease group can't outweigh false positives from the large healthy group. This is the base-rate fallacy, seen.

Manim building blocks

A grid of Squares in a VGroup, color fills for each subgroup, and FadeOut to filter. A DecimalNumber shows the updating probability. Pairs with Animate the Central Limit Theorem.

The prompt

"Show 10,000 people as a grid, 1% with a disease, apply a 99%-accurate test, then keep only positives and reveal that only ~50% are truly sick."

โ†’ Render it at quantumsketch.app.


Written by Shihab Shahriar Antor ยท Shahriar Labs

FAQ

Q.What's the most intuitive way to visualize Bayes' theorem?

Use a grid of people. Draw a grid where each square is a person, color the small fraction who actually have a condition, then show test results: most sick people test positive (true positives) and a small fraction of healthy people also test positive (false positives). When you then keep only the squares that tested positive and ask 'what fraction of these are actually sick,' the answer is often surprisingly low because the healthy group is so much larger. This grid-filtering animation makes Bayes' theorem โ€” updating a probability after evidence โ€” concrete, and it explains the famous false-positive paradox.

Q.How do I animate the false-positive paradox?

Describe it as a prompt: 'Show 10,000 people as a grid, mark 1% as having a disease, apply a 99%-accurate test, then keep only the positives and reveal that fewer than half are truly sick.' QuantumSketch renders this as a narrated Manim animation. Manim's grids of squares, color fills, and fade animations let the population shrink step by step as you filter, so viewers watch the counts that drive Bayes' theorem rather than just reading the formula P(A|B) = P(B|A)P(A)/P(B).

Tags:#math#animation#statistics
S

Shihab Shahriar

AI Engineer & Founder of Shahriar Labs. Exploring the intersection of design, cognition, and machine learning.