Bayes' Theorem Visualizer Back
Probability & Statistics

Bayes' Theorem Visualizer

Adjust prior probability, true positive rate, and false positive rate to calculate posterior probability in real time. Intuitively understand probability updating from evidence in medical testing, quality control, and machine learning.

Parameters

P(D|+) Posterior probability (positive predictive value)
16.7%

While paused, move the sliders to update the result instantly.

Live Readouts
16.7%
Posterior P(D|+)
9.9
True positives / 1000
49.5
False positives / 1000
1.00%
Prior P(D)
Population Animation (1000 people)
True positive TP False positive FP False negative FN True negative TN

Among everyone who tests positive (green + orange), only the green dots are truly diseased. That fraction is the posterior P(D|+). When prevalence is low, false positives outnumber true positives, so even a highly sensitive test gives a low predictive value (the base-rate effect).

Known-Solution Check
With prevalence 1%, sensitivity 99%, specificity 95%: P(D|+) = 0.99×0.01 / (0.99×0.01 + 0.05×0.99) = 16.7%✓ matches
Theory & Key Formulas

Bayes' theorem (medical test):

$P(D|+) = \dfrac{P(+|D)\,P(D)}{P(+|D)P(D) + P(+|\neg D)P(\neg D)}$
$P(+|\neg D) = 1 - \text{specificity}$,   positive test rate $P(+) = P(+|D)P(D) + P(+|\neg D)P(\neg D)$

Validation: prevalence 1%, sensitivity 99%, specificity 95% → P(D|+) ≈ 16.7%.

💬 Conversation about Bayes' Theorem

🙋
Bayes' theorem sounds difficult, but what is it in simple terms?
🎓
It is a formula for calculating how much an original expectation (prior probability) should be updated after new evidence is observed. A physician revising a diagnosis after a test result, or a spam filter updating spam probability from new email features, are both Bayesian ways of thinking.
🙋
In the "rare disease test" preset, even with a prevalence of 1% and sensitivity of 99%, the positive predictive value is only about 17%. That's puzzling.
🎓
That is the base-rate fallacy. In a population of 1000 people with 1% prevalence, a test with 99% sensitivity and 95% specificity finds about 9.9 true positives among 10 patients, but also about 49.5 false positives among 990 healthy people. Of the 59.4 positives, only 9.9 are true positives, about 17%. Even with high sensitivity, positive predictive value stays low when the prior probability is low.
🙋
I heard Bayes' theorem can be used repeatedly. What does that mean?
🎓
This is Bayesian updating. The posterior probability from the first test can be used as the prior probability for the second test. Repeating the same test increases confidence. The same principle appears in online learning in machine learning, where parameter probability distributions are updated as data are added one by one.
🙋
Is it also used in CAE and simulation?
🎓
It is used in uncertainty quantification (UQ). For example, when a material elastic modulus is not known exactly, engineers set a prior distribution, compare it with experimental measurements, and update the parameter distribution through Bayesian estimation. This ultimately quantifies confidence intervals for simulation outputs. It is an important approach in digital twins and model verification and validation (V&V).

Frequently Asked Questions

If the prior probability is set to 0% or 100%, the posterior probability will not change regardless of the presence or absence of evidence (test results). Also, if the true positive rate and false positive rate are the same, the evidence has no discriminatory power, so the posterior probability matches the prior probability. Please return the slider to an intermediate value and try again.
Because the prevalence (prior probability) is as low as 1%, the absolute number of false positives (healthy individuals incorrectly identified as positive) exceeds that of true positives. Specifically, out of 1000 people, about 10 of the 10 patients are true positives, and about 49.5 of the 990 healthy people are false positives, resulting in a positive predictive value of approximately 17%.
You can simulate sequential Bayesian updates by manually setting the posterior probability calculated in one step as the prior probability on the slider for the next step. For example, by setting the positive predictive value obtained from the first test as the prior probability and then inputting the result of a second test, you can experience the effect of accumulating evidence.
In CAE, 'Bayesian calibration' is performed to probabilistically correct the parameters of a simulation model using experimental data. The flow of 'prior probability → evidence → posterior probability' learned with this tool is precisely the process of updating the uncertainty of design parameters based on experimental results.

What is Bayes Theorem Visualizer?

Bayes Theorem Visualizer is a fundamental topic in engineering and applied physics. This interactive simulator lets you explore the key behaviors and relationships by directly manipulating parameters and observing real-time results.

By combining numerical computation with visual feedback, the simulator bridges the gap between abstract theory and physical intuition — making it an effective learning tool for students and a rapid-verification tool for practicing engineers.

Physical Model & Key Equations

The simulator is based on the governing equations behind Bayes' Theorem Visualizer. Understanding these equations is key to interpreting the results correctly.

Each parameter in the equations corresponds to a slider in the control panel. Moving a slider changes the equation's solution in real time, helping you build a direct connection between mathematical expressions and physical behavior.

Real-World Applications

Engineering Design: The concepts behind Bayes' Theorem Visualizer are applied across mechanical, structural, electrical, and fluid engineering disciplines. This tool provides a quick way to estimate design parameters and sensitivity before committing to full CAE analysis.

Education & Research: Widely used in engineering curricula to connect theory with numerical computation. Also serves as a first-pass validation tool in research settings.

CAE Workflow Integration: Before running finite element (FEM) or computational fluid dynamics (CFD) simulations, engineers use simplified models like this to establish physical scale, identify dominant parameters, and define realistic boundary conditions.

Common Misconceptions and Points of Caution

Model assumptions: The mathematical model used here relies on simplifying assumptions such as linearity, homogeneity, and isotropy. Always verify that your real system satisfies these assumptions before applying results directly to design decisions.

Units and scale: Many calculation errors arise from unit conversion mistakes or order-of-magnitude errors. Pay close attention to the units shown next to each parameter input.

Validating results: Always sanity-check simulator output against physical intuition or hand calculations. If a result seems unexpected, review your input parameters or verify with an independent method.

How to Use

  1. Enter P(A), the prior probability of your hypothesis (e.g., 0.01 for rare disease prevalence)
  2. Set P(B|A), the likelihood of observing evidence given the hypothesis is true (e.g., 0.95 for test sensitivity)
  3. Set P(B|¬A), the likelihood of observing the same evidence when hypothesis is false (e.g., 0.10 for false positive rate)
  4. The visualizer computes posterior probability P(A|B) showing how evidence updates your belief

Worked Example

Medical screening: Disease prevalence P(A) = 0.005, test sensitivity P(B|A) = 0.98, false positive rate P(B|¬A) = 0.03. Posterior P(A|B) = 0.141, meaning a positive test indicates only 14.1% actual disease probability despite high test accuracy. This demonstrates why screening rare conditions produces misleading results without Bayesian reasoning.

Practical Notes

  1. Quality control context: P(A) = defect rate 0.02, inspection catches 96% of defects, 5% false alarms on good parts yields posterior probability of 0.28 given failed inspection
  2. Base rate neglect is critical—low priors dominate posteriors even with strong evidence, especially in manufacturing with rare failure modes
  3. Adjust P(B|¬A) sensitivity to model diagnostic uncertainty; higher false positive rates drastically reduce posterior confidence in hypothesis