Skip to content
Statistics

Conditional Probability Calculator

Find any conditional probability from what you know. Choose your input mode: enter P(A and B) and P(B) directly, use the Bayesian approach with a prior and likelihoods, or enter raw event counts from a frequency table. The calculator returns all four conditional probabilities, their complements, and a check for statistical independence.

Your details

Pick the data you have. All three modes produce the same conditional-probability outputs.
Probability that BOTH A and B occur. Must be between 0 and P(B).
Probability of event B occurring. Must be greater than 0.
Optional. P(A∩B̅). When provided, the calculator also outputs P(A|B̅), P(Ã|B), and P(Ã|B̅). Leave blank or 0 to skip.
P(A | B)Less likely
40%

Probability of A given that B has occurred.

P(A | B) decimal0.4
P(Ã | B)60%
P(A | B̅)11.43%
P(Ã | B̅)88.57%
P(B)30%
P(B̅)70%
IndependenceDependent
Posterior P(A|B)40%
40% %
Unlikely<25Less likely25-50More likely than not50-75Very likely75+

Given B, the probability of A is 40%.

  • Given that B occurred (P(B) = 30%), the probability of A is 40%.
  • P(A|B) = P(A and B) / P(B) = 0.4 in decimal form.
  • A and B are statistically dependent: knowing B changes the probability of A.

Next stepCompare P(A|B) with P(A|not-B) to see how strongly B separates the two cases.

Formula

P(AB)=P(AB)P(B),P(B)>0P(A \mid B) = \dfrac{P(A \cap B)}{P(B)}, \qquad P(B) > 0

Worked example

Medical testing example: suppose 5% of people have a disease, a test is 91% sensitive (P(B|A) = 0.91), and 95% specific (P(B|notA) = 0.05). Switch to Bayesian mode and enter P(A) = 0.05, P(B|A) = 0.91, P(B|notA) = 0.05. The calculator derives P(B) = 0.05 x 0.91 + 0.95 x 0.05 = 0.0455 + 0.0475 = 0.093, then P(A|B) = 0.0455 / 0.093 = 0.489, or about 49%. Even with a positive test result, there is only a 49% chance the patient truly has the disease, because the disease is rare.

What conditional probability actually measures

Conditional probability answers the question: given that B has already happened, how likely is A? Instead of weighing A against every possible outcome, it restricts attention to only the outcomes where B is true and asks what fraction of those also contain A. The formula P(A|B) = P(A and B) / P(B) captures this idea: the numerator counts the overlap where both events occur, and the denominator rescales it against the reduced world in which B is certain. The result is a probability between 0 and 1, measured inside a narrowed sample space.

Three ways to calculate P(A|B)

This calculator offers three input modes. The first is the classic approach: enter the joint probability P(A and B) and the marginal probability P(B) directly, then the formula gives P(A|B) immediately. The second is the Bayesian approach: enter a prior P(A), a likelihood P(B|A), and a false-positive rate P(B|not-A); the law of total probability derives P(B), and Bayes theorem produces the posterior P(A|B). This is the standard approach in medical testing, spam filtering, and any situation where you update a prior belief with new evidence. The third mode accepts raw event counts from a 2x2 frequency table, converts them to probabilities, then applies the same formula. All three modes produce the same set of outputs.

Complement outputs and the full four-cell table

Because every probability has a complement, there are actually four conditional probabilities in any two-event system: P(A|B), P(not-A|B), P(A|not-B), and P(not-A|not-B). This calculator computes all four when the inputs are sufficient. Knowing all four is useful for comparing how strongly B separates the two cases: if P(A|B) is much larger than P(A|not-B), then B is a strong predictor of A. If the two values are similar, B carries little information about A, which is exactly the independence condition.

Independence and Bayes

When A and B are independent, knowing B tells you nothing new about A, so P(A|B) equals the unconditional P(A). The calculator flags this with an independence readout. Conditional probability is also the foundation of Bayes theorem, which flips the conditioning direction to compute P(B|A) from P(A|B). This relationship powers spam filters, medical test interpretation, and any setting where new evidence should update a prior belief in a disciplined, quantitative way. The Bayesian input mode makes this pipeline explicit: enter your prior and likelihoods, and read off the posterior directly.

Conditional probability inputs and outputs at a glance

ModeInputs you provideKey outputs
Joint probabilitiesP(A and B), P(B)P(A|B), P(not-A|B)
Joint + full tableP(A and B), P(B), P(A and not-B)All four: P(A|B), P(A|not-B), P(not-A|B), P(not-A|not-B)
BayesianP(A), P(B|A), P(B|not-A)Posterior P(A|B), P(B) via total probability
Event countsn(A and B), n(A and not-B), n(not-A and B), n(not-A and not-B)All four conditionals from frequency table

All three modes produce the same four conditional outputs. Choose the mode that matches your data.

Frequently asked questions

What is the formula for conditional probability?

Conditional probability is P(A|B) = P(A and B) / P(B), where P(A and B) is the joint probability that both A and B occur and P(B) is the probability of the conditioning event. It is only defined when P(B) is greater than zero. Equivalently, if you know P(A), P(B|A), and P(B|not-A), you can use the Bayesian form: P(A|B) = [P(B|A) x P(A)] / [P(B|A) x P(A) + P(B|not-A) x P(not-A)].

What is the difference between P(A|B) and P(A and B)?

P(A and B) is the joint probability that A and B both occur, measured against all possible outcomes. P(A|B) is the probability of A measured only within the outcomes where B already occurred, so it equals the joint probability divided by P(B). The conditional value is usually larger because its denominator is smaller. For example, if P(A and B) = 0.12 and P(B) = 0.30, then P(A|B) = 0.40, which is larger than 0.12.

When does P(A|B) equal P(A)?

When A and B are statistically independent. Independence means observing B gives no information about A, so the conditional probability P(A|B) equals the unconditional probability P(A). If the two values differ, the events are dependent and B carries useful information about A. This calculator computes an independence check automatically.

What is the Bayesian input mode and when should I use it?

The Bayesian mode is for situations where you know a prior probability and two likelihoods rather than joint probabilities directly. For example, a disease prevalence P(A) = 5%, a test sensitivity P(B|A) = 91%, and a false-positive rate P(B|not-A) = 5%. The calculator applies the law of total probability to find P(B), then uses Bayes theorem to find the posterior probability that the patient truly has the disease given a positive test. This mode is standard in medical testing, spam detection, and machine-learning evaluation.

Can I use raw counts instead of probabilities?

Yes. Switch to the event counts mode and enter the four cells of your 2x2 contingency table: how many times A and B both occurred, A without B, B without A, and neither. The calculator divides each count by the grand total to get probabilities, then applies the conditional probability formula. This is useful when working directly with survey data, experiment results, or classification confusion matrices.

Why does the calculator return all four conditional probabilities?

In a two-event system there are always four conditional probabilities: P(A|B), P(not-A|B), P(A|not-B), and P(not-A|not-B). Reporting all four lets you compare how much B shifts the probability of A. A large gap between P(A|B) and P(A|not-B) means B is a strong predictor of A. A small gap means the events are nearly independent.

Sources

Written by Dr. Hannah Brandt, PhD Statistician · Munich, Germany

Applied statistician translating rigorous probability theory into clear, accurate tools for researchers and practitioners.

Search 3,500+ calculators

Loading search…