Conditional Probability Formula: How to Calculate P(A|B)
The conditional probability formula finds the chance of event A after you know that event B has occurred. The central rule is P(A|B) = P(A ∩ B) ÷ P(B), provided that P(B) is greater than zero. In plain language, restrict the possible outcomes to B, then ask what share of that smaller group also belongs to A.
Conditional probability formula at a glance
P(A|B) = P(A ∩ B) ÷ P(B), where P(B) > 0. The symbol A|B is read as “A given B.” The numerator is the probability that both events happen; the denominator is the probability of the condition B.
For example, if 8 of the 20 outcomes in group B are also in group A, then P(A|B) = 8 ÷ 20 = 0.40, or 40%. The denominator is not the entire sample of 100 outcomes because the question has already told us to focus on B.
What conditional probability means
A conditional probability is a probability with extra information attached. Ordinary probability asks how likely A is in the full sample space. Conditional probability asks how likely A is inside the reduced set of outcomes where B is known to be true.
Think of a school survey with 100 responses. Event A could mean “the respondent chose option A,” while event B could mean “the respondent is in a particular age group.” Once B is known, the relevant denominator is the number of respondents in that age group. You are no longer comparing A with all 100 responses.
This idea appears in medical testing, weather forecasts, quality control, card problems, data analysis, and machine learning. The notation does not say that A causes B. It only describes the probability of A under the condition that B has been observed.
How to calculate conditional probability step by step
Use the following sequence whenever the question includes wording such as “given that,” “among,” “if we know,” or “for cases where.”
- Define the events: write down exactly what A and B represent. Keep the order visible because P(A|B) and P(B|A) are usually different.
- Find the overlap: calculate P(A ∩ B), the probability that both A and B occur together.
- Find the condition: calculate P(B), the probability of the group or condition after the vertical bar.
- Divide: divide the overlap by the condition. Convert the decimal to a percentage only after the ratio is correct.
If you have counts instead of probabilities, the same rule becomes number in A and B ÷ number in B. This count version is often easier to check because the denominator is visible. Keep the units or population definition consistent and avoid rounding the counts before dividing.
Worked conditional probability examples
Example 1: a two-way table
Suppose an illustrative group contains 100 people. Of the 10 people in B, 8 are also in A. The conditional probability of A given B is therefore 8 ÷ 10 = 0.80, or 80%. The joint probability of A and B is 8 ÷ 100 = 8%, so the two numbers answer different questions.
| B | Not B | Total | |
|---|---|---|---|
| A | 8 | 12 | 20 |
| Not A | 2 | 78 | 80 |
| Total | 10 | 90 | 100 |
For P(A|B), use the B column: 8 cases satisfy both A and B, and the B group contains 10 cases in this table, so P(A|B) = 8 ÷ 10 = 80%. If the condition is defined as the first row’s B group of 20 in a different table, use that definition consistently. The lesson is to identify the exact condition before choosing the denominator.
Example 2: cards
Draw one card from a standard 52-card deck. Let A be “the card is a heart” and B be “the card is red.” There are 26 red cards, and 13 of them are hearts. Therefore P(A|B) = 13 ÷ 26 = 50%. Knowing that the card is red removes all black cards from the reference group.
Conditional vs. joint vs. marginal probability
These terms are closely related but should not be substituted for one another. A clear label prevents the most common denominator error.
| Measure | Question answered | Typical expression |
|---|---|---|
| Marginal probability | How likely is one event in the full sample? | P(A) |
| Joint probability | How likely are A and B together? | P(A ∩ B) |
| Conditional probability | How likely is A inside the cases where B is true? | P(A|B) |
The relationship is P(A ∩ B) = P(A|B) × P(B). Rearranging that equation gives the conditional probability formula. If your result is larger than 1 or the denominator does not match the words in the question, stop and re-check which probability is joint and which is conditional.
Independence and the multiplication rule
Events A and B are independent when knowing B does not change the probability of A. In that special case, P(A|B) = P(A), and the joint probability can be written as P(A ∩ B) = P(A) × P(B).
Independence is an assumption, not a synonym for “two events.” For example, two separate fair coin tosses can be modelled as independent. Drawing two cards without replacement is generally dependent because the first card changes the composition of the deck. A repeated-trial calculator may also assume independence, so check the model before using its result.
Bayes’ theorem: reversing the condition
People often confuse P(A|B) with P(B|A). Bayes’ theorem shows how to reverse the direction when you know the relevant probabilities:
This matters when evidence is easier to describe in one direction than the other. In a screening example, P(positive test|condition) is not the same as P(condition|positive test). The second value also depends on the underlying rate of the condition and on other outcomes. Always write the event after the vertical bar as the denominator group before interpreting the percentage.
Bayes’ theorem does not make a result certain. It combines a prior probability with evidence and produces an updated conditional probability. For more complex data, show the assumptions, base rate, and test characteristics rather than presenting one percentage without context.
Common mistakes and edge cases
- Reversing the events: P(A|B) and P(B|A) use different condition groups and usually produce different answers.
- Using the full sample as the denominator: once B is known, divide by the size or probability of B, not the entire population.
- Confusing “and” with “given”: “A and B” is a joint event; “A given B” is a conditional event.
- Dividing by zero: P(A|B) is undefined when P(B) = 0 because there is no non-empty condition group.
- Assuming causation: a conditional relationship can describe an association without proving that B causes A.
- Rounding too early: retain the original counts or decimals and round the final percentage.
For a quick numerical check, use the site’s probability calculator for simple probability, at-least-one results, and binomial calculations. That tool is useful for those supported models; this guide explains the conditional-probability notation and denominator choice, including cases that need a table or a separate statistical model.
FAQ: conditional probability formula
What is the conditional probability formula?
Use P(A|B) = P(A ∩ B) ÷ P(B), provided P(B) is greater than zero. It means the chance of A among the outcomes where B is true.
How do I calculate conditional probability from counts?
Divide the number of outcomes in both A and B by the number of outcomes in B. For 8 overlap cases in a B group of 20, the result is 8 ÷ 20 = 40%.
Is P(A|B) the same as P(B|A)?
No. The two expressions use different condition groups. They are equal only under particular relationships, so keep the event after the vertical bar explicit.
What is the difference between joint and conditional probability?
Joint probability measures A and B together in the full sample space. Conditional probability measures A inside the B group, so it divides the joint probability by P(B).
What happens if P(B) is zero?
The ordinary formula is undefined because it divides by zero. There is no observed B group from which to calculate a proportion.
How is conditional probability related to independence?
If A and B are independent, knowing B does not change A, so P(A|B) equals P(A). If the values differ, the events are not independent under that model.
Summary
The conditional probability formula is P(A|B) = P(A ∩ B) ÷ P(B). Define the events, find the overlap, identify the condition after the vertical bar, and use that condition as the denominator. Keep conditional, joint, and marginal probability separate, check the independence assumption, and do not treat a conditional relationship as proof of causation. For another formula-based comparison topic, see the weighted average formula guide.