Conditional Probability Calculator
Calculate P(A|B) using the conditional probability formula or a contingency table. Determine if events are independent and find both P(A|B) and P(B|A). See also our Bayes' Theorem Calculator, Probability Calculator, and Chi-Square Test Calculator.
How to Use the Conditional Probability Calculator
Conditional probability P(A|B) is the probability of event A occurring given that event B has already occurred. It answers the question: "If we know B happened, how likely is A?" This concept is central to statistics, machine learning, medical diagnosis, and everyday reasoning about uncertain events.
You can input data in two ways: (1) Direct formula mode — enter P(A∩B) (the probability both A and B occur) and P(B) (the probability B occurs). (2) Contingency table mode — enter counts for all four combinations (A&B, A¬ B, not A&B, not A¬ B). The table mode automatically calculates both P(A|B) and P(B|A) and checks for independence.
Two events are independent if P(A|B) = P(A), meaning knowing B occurred doesn't change the probability of A. Equivalently, P(A∩B) = P(A)×P(B) for independent events. The calculator checks this condition and reports whether the events appear to be independent or dependent based on your data.
Formula
Conditional Probability:
P(A|B) = P(A∩B) / P(B), where P(B) > 0
Reverse Conditional:
P(B|A) = P(A∩B) / P(A)
Independence Test:
Events are independent if P(A∩B) = P(A) × P(B)
Multiplication Rule:
P(A∩B) = P(A|B) × P(B) = P(B|A) × P(A)
Example Calculation
Contingency table: 100 students surveyed
Studied & Passed: 60, Studied & Failed: 10
Not Studied & Passed: 15, Not Studied & Failed: 15
P(Pass) = 75/100 = 0.75
P(Study) = 70/100 = 0.70
P(Pass ∩ Study) = 60/100 = 0.60
P(Pass|Study) = 0.60/0.70 = 0.857 (85.7%)
P(Pass|Not Study) = 15/30 = 0.50 (50%)
Independence: 0.60 ≠ 0.75×0.70 = 0.525 → Dependent
Reference Table
| Scenario | P(A∩B) | P(B) | P(A|B) |
|---|---|---|---|
| Card (King given Face) | 4/52 | 12/52 | 4/12 = 0.333 |
| Rain given Cloudy | 0.15 | 0.40 | 0.375 |
| Pass given Studied | 0.60 | 0.70 | 0.857 |
| Defect given Machine A | 0.02 | 0.40 | 0.050 |
| Win given Home Team | 0.30 | 0.50 | 0.600 |
| Late given Traffic | 0.08 | 0.20 | 0.400 |
| Flu given Fever | 0.03 | 0.10 | 0.300 |
| Hired given Interview | 0.05 | 0.25 | 0.200 |
Frequently Asked Questions
What is conditional probability?
Conditional probability P(A|B) is the probability of event A occurring given that event B is known to have occurred. It restricts the sample space to only those outcomes where B is true, then asks how likely A is within that restricted space. For example, P(rain|cloudy) asks: among all cloudy days, what fraction also have rain? It is different from P(rain) which considers all days regardless of cloud cover.
Is P(A|B) the same as P(B|A)?
No! This is a common error called the "confusion of the inverse." P(A|B) and P(B|A) are generally different. For example, P(wet ground|rain) ≈ 1.0, but P(rain|wet ground) is much less (sprinklers, dew, etc. also cause wet ground). They are related by Bayes' theorem: P(A|B) = P(B|A)×P(A)/P(B). They are equal only when P(A) = P(B), which is a special case.
What does independence mean in probability?
Two events A and B are independent if knowing one occurred gives no information about the other: P(A|B) = P(A) and P(B|A) = P(B). Equivalently, P(A∩B) = P(A)×P(B). Examples: successive coin flips are independent; drawing cards without replacement is not independent. Independence is an assumption in many statistical methods, and violations can lead to incorrect conclusions.
How do I read a contingency table?
A contingency table (also called a cross-tabulation) shows the frequency of combinations of two categorical variables. Rows represent one variable, columns represent another, and cells contain counts. Marginal totals (row and column sums) give individual frequencies. To find conditional probability, divide the cell count by the appropriate marginal total. For P(A|B), divide the A∩B cell by the column total for B.
What is the multiplication rule?
The multiplication rule states P(A∩B) = P(A|B)×P(B) = P(B|A)×P(A). It calculates the joint probability of both events occurring. For independent events, this simplifies to P(A∩B) = P(A)×P(B). For dependent events, you must use the conditional probability. Example: P(two aces from a deck) = P(first ace) × P(second ace|first ace) = (4/52)×(3/51) = 12/2652 ≈ 0.0045.
How is conditional probability used in real life?
Conditional probability appears everywhere: medical diagnosis (probability of disease given symptoms), weather forecasting (rain probability given atmospheric conditions), spam filtering (spam probability given email content), insurance (accident probability given driver profile), quality control (defect probability given machine), and criminal justice (guilt probability given evidence). Understanding conditional probability helps avoid common reasoning errors like the prosecutor's fallacy.