Conditional Probability Calculator

StatisticsLast updated: August 22, 2026

Conditional probability is the probability of one event once another event is known to have occurred, and it is computed as P(A|B) = P(A ∩ B) / P(B). The new information narrows the sample space: instead of every outcome, only the outcomes in which B occurred are counted. The probability of disease given a test result, the purchase rate among people who saw a campaign, and the chance that a unit from a particular production line is defective are all found this way.

This calculator accepts your values in two different forms: enter P(A), P(B), and P(A ∩ B) directly, or type the observed counts of a 2×2 contingency table. The output is not limited to P(A|B): it also reports the reverse conditional P(B|A), the union P(A ∪ B), the complement condition P(A|Bʹ), the lift, and — most importantly — an independence check that compares P(A ∩ B) with P(A)·P(B).

Pick the first if you have proportions, the second if you have raw counts.
Used as a label in the results. Left blank, it appears as A.
This is the event taken as the condition in P(A|B).
Enter a value between 0 and 1: use 0.4 for 40%.
The probability of the conditioning event; it cannot be zero.
The probability that A and B occur together. It cannot exceed either P(A) or P(B).

Conditional Probability Formulas

Conditional probability:  P(A|B) = P(A ∩ B) / P(B),   P(B) > 0
Multiplication rule:      P(A ∩ B) = P(A|B) · P(B) = P(B|A) · P(A)
Independence:             P(A ∩ B) = P(A) · P(B)  ⇔  P(A|B) = P(A)
Union:                    P(A ∪ B) = P(A) + P(B) − P(A ∩ B)
Complement condition:     P(A|Bʹ) = [P(A) − P(A ∩ B)] / [1 − P(B)]
From a contingency table: P(A|B) = n(A ∩ B) / n(B)
Lift:                     L = P(A|B) / P(A)
Bayes link:               P(A|B) = P(B|A) · P(A) / P(B)

In a conditional probability the denominator is not the whole sample space but only the conditioning event. That is why P(A|B) and P(B|A) usually differ, and why swapping them produces the mistake known as the base rate fallacy.

How to Calculate

  1. Choose the input format: 'Probabilities' if you have proportions, 'Contingency table' if you have raw counts.
  2. Optionally name the events (for example 'Purchased' and 'Saw the campaign'); the results are labeled with those names.
  3. In probability mode, enter P(A), P(B), and the intersection P(A ∩ B) as values between 0 and 1; in contingency table mode, enter the observation count of each of the four cells.
  4. Compare the resulting P(A|B) with P(A): the gap shows how much the information about B is worth.
  5. Read the independence line; if P(A ∩ B) equals P(A)·P(B), the events are independent.
  6. Check the four disjoint regions and the marginal totals in the summary table to confirm that your inputs are consistent.

Worked Examples

Campaign and purchase (probability input)

40% of customers make a purchase, 25% see the campaign, and 15% do both. Among those who saw the campaign, the probability of purchase rises to 0.15 / 0.25 = 60%, while among those who did not it stays at 33.33%. Independence would predict P(A)·P(B) = 10%, but the actual intersection is 15%, so the events are positively dependent and the lift is 1.500.

P(Satın aldı | Kampanyayı gördü): 60.00% · P(Kampanyayı gördü | Satın aldı): 37.50% · P(Satın aldı | not Kampanyayı gördü): 33.33%

Conditional probability from a contingency table

In a table of 300 people, 45 of the 75 who report a cough smoke: P(A|B) = 45/75 = 60%. Of the 100 smokers, 45 report the complaint, so P(B|A) = 45%. Because the overall smoking rate is 33.33%, the jump to 60% among those with the complaint shows that the two events are dependent; the lift is 1.800.

P(Sigara içiyor | Öksürük şikâyeti): 60.00% · P(Öksürük şikâyeti | Sigara içiyor): 45.00% · P(Sigara içiyor | not Öksürük şikâyeti): 24.44%

Two independent events

With P(A) = 0.5 and P(B) = 0.2, the intersection is exactly 0.5 × 0.2 = 0.1. Then P(A|B) = 0.1 / 0.2 = 50%, which is identical to P(A): knowing B changes nothing, so the events are independent. The lift is 1.000 and the union probability is 60%.

P(A | B): 50.00% · P(B | A): 20.00% · P(A | not B): 50.00%

Frequently Asked Questions

Why are P(A|B) and P(B|A) different?
They share the same numerator (the intersection) but have different denominators: one divides by P(B), the other by P(A). That is why the result changes dramatically when a rare event is taken as the condition. Using one in place of the other is the classic mistake known as the prosecutor's fallacy or the base rate fallacy; the correct way to move between them is Bayes' theorem.
How do I tell whether two events are independent?
The criterion for independence is P(A ∩ B) = P(A)·P(B), which is equivalent to P(A|B) = P(A) and P(B|A) = P(B). This calculator makes that comparison automatically and shows the difference. If you are working with sample data, small deviations may be due to chance; to test independence statistically you need the chi-square test of independence.
Are mutually exclusive events independent?
No, quite the opposite. For mutually exclusive events P(A ∩ B) = 0; when one occurs the probability of the other drops to zero, which is the strongest possible dependence. Independence and mutual exclusivity are used interchangeably far too often even though they are opposites: two events with non-zero probabilities cannot be both mutually exclusive and independent.
How do I read a conditional probability off a contingency table?
Whichever event is the condition, its row or column total becomes the denominator. For P(A|B) you divide by the total of the B column: if 45 of the 75 people in the B column also have A, then P(A|B) = 45/75 = 0.60. In Excel you get this with SUMIF/SUMIFS, and in SPSS with the row or column percentages in the Crosstabs menu.
What does the lift value mean?
Lift is the ratio of the conditional probability to the unconditional one: L = P(A|B) / P(A). L = 1 indicates independence, L > 1 a positive association, and L < 1 a negative association. Market basket analysis and recommender systems use exactly this measure to gauge how strongly two products tend to be bought together.
What happens if P(B) = 0?
The conditional probability is undefined; an event that never occurs cannot be used as a condition because the denominator would be zero. In that case the calculator returns a clear error message instead of a result. In practice, results are also very unstable when P(B) is merely close to zero; the remedy is to increase the number of observations in the conditioning group.
Does the calculator warn me if my inputs are inconsistent?
Yes. The intersection probability cannot exceed either P(A) or P(B), and the sum P(A) + P(B) − P(A ∩ B) cannot exceed 1. When either rule is broken, the calculator stops and tells you exactly which limit was crossed, with the number.