Compute P(A|B) and P(B|A) from joint and marginal probabilities. Visualize event overlap, test independence, and explore Bayesian reasoning.
Conditional probability measures the likelihood of an event given that another event has occurred. Formally, P(A|B) = P(A∩B) / P(B), provided P(B) > 0. This concept is foundational in statistics, machine learning, medical diagnosis, and risk assessment. Our calculator not only computes P(A|B) and P(B|A) but also determines whether A and B are independent (P(A∩B) = P(A)P(B)) or mutually exclusive (P(A∩B)=0).
From these, we derive Bayes' theorem: P(A|B) = P(B|A)·P(A) / P(B). This inversion formula is a cornerstone of modern inference, enabling us to update beliefs in light of new evidence.
Given P(A), P(B), and P(A∩B), the tool computes:
All calculations use double-precision floating point. The Venn diagram is drawn with two intersecting circles (fixed geometry for clarity) and dynamically annotated with current probabilities to reinforce conceptual understanding.
A disease affects 1% of the population (P(D)=0.01). A test has 99% sensitivity (P(Pos|D)=0.99) and 5% false positive rate (P(Pos|¬D)=0.05). Using our calculator, set P(A)=0.01 (disease), P(B)=P(Pos)=? First compute P(Pos)=P(Pos|D)P(D)+P(Pos|¬D)P(¬D)=0.99*0.01+0.05*0.99=0.0594. Joint P(D∩Pos)=0.0099. Then P(D|Pos)=0.0099/0.0594 ≈ 0.1667. The calculator reproduces this result, showing that even with a highly accurate test, the posterior probability is only ~16.7% — a classic demonstration of base rate fallacy.
Click any preset button to load realistic probability sets:
| Scenario | P(A) | P(B) | P(A∩B) | P(A|B) | Interpretation |
|---|---|---|---|---|---|
| Medical test (disease given positive) | 0.01 | 0.0594 | 0.0099 | 0.1667 | Low prevalence reduces predictive value |
| Rain & traffic delay | 0.30 | 0.25 | 0.10 | 0.4000 | 40% chance of traffic if raining |
| Fair die (even & >3) | 0.50 | 0.50 | 0.25 | 0.5000 | Independent events |
| Exclusive events (A and B disjoint) | 0.30 | 0.40 | 0.00 | 0.0000 | Knowing B occurs makes A impossible |
prob package and manual calculations. All edge cases (zero probabilities, near‑zero joint, independence threshold) are handled with double precision and tolerance checks. You can reproduce any result using the formulas shown above.