Conditional Probability Calculator

Find P(A|B) — the probability of A given B — with Bayes' theorem, from the prior P(A), the true-positive rate P(B|A), and the false-positive rate P(B|not A).

Quick Facts

Method
Bayes' theorem: P(A|B) = P(B|A)·P(A) / P(B)
Enter each probability as a decimal between 0 and 1.

Your Results

Calculated
P(A|B) — posterior probability of A given B
-
Chance A is true after observing B
P(B) — total probability of B
-
P(B|A)·P(A) + P(B|not A)·(1 − P(A))
P(A ∩ B) — joint probability
-
P(B|A) × P(A)
P(not A | B) — complement
-
Chance A is false given B

Ready

Enter your probabilities and press Calculate.

Understanding Conditional Probability

Definition:

P(A|B) = P(A ∩ B) / P(B)

Bayes' theorem form (used by this calculator):

P(A|B) = P(B|A)·P(A) / [ P(B|A)·P(A) + P(B|¬A)·(1 − P(A)) ]

The probability of A given that B has occurred, for P(B) > 0

Conditional probability answers the question: given that event B has happened, how likely is event A? It is defined as the joint probability of both events, P(A ∩ B), divided by the probability of the conditioning event, P(B). This is only defined when P(B) is greater than zero — you cannot condition on something that never occurs.

In many real problems you do not directly know the joint probability P(A ∩ B) or the marginal P(B). Instead you know three quantities: the prior P(A) (how common A is before you see any evidence), the sensitivity P(B|A) (how often the evidence B shows up when A is true), and the false-positive rate P(B|¬A) (how often B shows up when A is false). Bayes' theorem stitches these together. The denominator is the law of total probability: P(B) = P(B|A)·P(A) + P(B|¬A)·(1 − P(A)), splitting every occurrence of B into the "A was true" branch and the "A was false" branch. This calculator implements exactly that expression.

How the calculator works

Enter each value as a decimal between 0 and 1. With the default medical-screening example — prior P(A) = 0.01, sensitivity P(B|A) = 0.99, false-positive rate P(B|¬A) = 0.05 — the joint probability is 0.99 × 0.01 = 0.0099, the total probability of a positive is 0.0099 + 0.05 × 0.99 = 0.0594, and the posterior is 0.0099 / 0.0594 ≈ 0.1667, or about 16.7%. A "99% accurate" test on a 1-in-100 condition still leaves you more likely to be healthy than sick after a positive result.

Related probability rules

  • Multiplication rule: P(A ∩ B) = P(A) × P(B|A). Rearranging this definition is where the P(A ∩ B) / P(B) formula comes from.
  • Law of total probability: P(B) = P(B|A)·P(A) + P(B|¬A)·P(¬A). This is the denominator in Bayes' theorem.
  • Complement: P(¬A|B) = 1 − P(A|B). The calculator reports this as the fourth output.
  • Independence: if A and B are independent, P(A|B) = P(A) — knowing B tells you nothing about A. You can check this by setting sensitivity equal to the false-positive rate; the posterior then collapses back to the prior.

Common intuition traps

  • Base-rate neglect: people fixate on the test's accuracy and ignore how rare A is. When the prior is tiny, even an excellent test produces mostly false positives, so P(A|B) stays low.
  • Confusing P(A|B) with P(B|A): "the probability of a positive test given the disease" (sensitivity) is not "the probability of the disease given a positive test" (the posterior). Swapping these is the prosecutor's fallacy.
  • Assuming symmetry: P(A|B) and P(B|A) are only equal when P(A) = P(B). In general they can differ enormously.

Frequently Asked Questions

What is the formula for conditional probability?
Conditional probability is P(A|B) = P(A ∩ B) / P(B), the probability of A given that B has occurred, defined whenever P(B) > 0. When you know the prior P(A), the sensitivity P(B|A), and the false-positive rate P(B|¬A) instead of the joint probability, Bayes' theorem rewrites it as P(A|B) = P(B|A)·P(A) / [P(B|A)·P(A) + P(B|¬A)·(1 − P(A))], which is what this tool computes.
Why is P(A|B) so low even when the test is 99% accurate?
Because the prior P(A) dominates when the condition is rare. If A affects 1 in 100 people, a test with 99% sensitivity and a 5% false-positive rate still flags about 5 healthy people for roughly every 1 true case, so P(A|B) is only about 17%. High accuracy does not overcome a low base rate — this is base-rate neglect.
What is the difference between P(A|B) and P(B|A)?
They answer opposite questions. P(B|A) is how often the evidence appears when the hypothesis is true (sensitivity). P(A|B) is how likely the hypothesis is once you have seen the evidence (the posterior). They are equal only when P(A) = P(B); treating them as interchangeable is the prosecutor's fallacy.
Can conditional probability be greater than the prior?
Yes. Observing B raises the probability of A whenever B is more likely under A than under ¬A, i.e. when P(B|A) > P(B|¬A). If the two rates are equal, B is uninformative and P(A|B) = P(A). If P(B|A) is smaller, observing B actually lowers the probability of A.