To find P(A|B), you divide the probability of both A and B happening by the probability of B alone. The formula is: P(A|B) = P(A and B) / P(B). That’s the core of conditional probability, and everything else builds on it.
The vertical bar “|” is read as “given that,” so P(A|B) means “the probability of A, given that B has already happened.” You’re narrowing your focus to only the situations where B is true, then asking how often A also occurs within that smaller group.
The Formula and What Each Part Means
Here’s what you need:
- P(A|B): the probability of event A happening, given that B has happened. This is what you’re solving for.
- P(A and B): the probability that both A and B occur together. You might also see this written as P(A ∩ B).
- P(B): the probability of event B occurring on its own. This is your denominator, and it must be greater than zero. Division by zero is undefined, so conditional probability doesn’t exist when P(B) = 0.
The logic behind the formula is straightforward. If you already know B happened, you’ve shrunk your universe of possibilities down to only the outcomes where B is true. Within that smaller universe, you want to know what fraction also includes A. That fraction is P(A and B) divided by P(B).
How to Solve a Problem Step by Step
Suppose you’re told that 30% of students at a school play sports, 10% play sports and are on the honor roll, and you want to find the probability that a student is on the honor roll given that they play sports.
Here, A is “on the honor roll” and B is “plays sports.” You have P(B) = 0.30 and P(A and B) = 0.10. Plug into the formula:
P(A|B) = 0.10 / 0.30 = 0.333, or about 33.3%.
The process is always the same:
- Step 1: Identify which event is A (what you want the probability of) and which is B (what you already know happened).
- Step 2: Find P(A and B), the probability both events happen together.
- Step 3: Find P(B), the probability of the “given” event.
- Step 4: Divide P(A and B) by P(B).
The trickiest part is usually Step 2. In textbook problems, P(A and B) is sometimes given directly. Other times you’ll need to calculate it from a table, a Venn diagram, or by multiplying probabilities if you know the events are independent.
When Events Are Independent
Two events are independent if knowing one happened doesn’t change the probability of the other. Flipping a coin and rolling a die, for example. Mathematically, independence means P(A|B) = P(A). Learning that B happened tells you nothing new about A.
When events are independent, P(A and B) = P(A) × P(B). If you plug that into the conditional probability formula, the P(B) cancels out and you’re left with just P(A). So the formula still works for independent events; it just simplifies to something obvious.
When events are dependent, P(A|B) ≠ P(A), and you need the full formula. Most interesting conditional probability problems involve dependent events, which is where the calculation actually changes your answer.
Using Bayes’ Theorem When You Have P(B|A) Instead
Sometimes you don’t have P(A and B) directly, but you do have the reverse conditional probability, P(B|A). This is where Bayes’ theorem comes in:
P(A|B) = P(B|A) × P(A) / P(B)
Each piece has a name that helps you keep track of what’s going on:
- P(A): the prior probability, your starting belief about how likely A is before considering B.
- P(B|A): the likelihood, how probable B is if A were true.
- P(B): the total probability of B across all scenarios.
- P(A|B): the posterior probability, your updated belief about A after learning that B happened.
Bayes’ theorem is especially useful in real-world situations where you naturally know probabilities in one direction but need them in the other. Medical testing is the classic example. Doctors often know how likely a test is to come back positive if a patient has a disease, P(positive|disease). But the patient wants to know the opposite: if my test came back positive, how likely is it that I actually have the disease, P(disease|positive)?
These two numbers can be wildly different. For breast cancer screening with mammography, the test is quite accurate. But because the baseline prevalence of breast cancer is low (around 1% in asymptomatic women), a randomly selected woman who gets a positive mammogram has only about a 7% chance of actually having cancer. The other 93% are false positives. This feels counterintuitive, but the math is clear: when the condition you’re testing for is rare, even a good test produces more false alarms than true catches.
The Most Common Mistake: Flipping A and B
The single biggest error people make with conditional probability is treating P(A|B) and P(B|A) as if they’re the same thing. They are not, and they frequently take very different values.
P(A|B) asks: given B happened, what’s the chance of A? P(B|A) asks: given A happened, what’s the chance of B? Swapping them is called the “confusion of the inverse,” and it leads to serious mistakes outside the classroom too.
In legal settings, this error is known as the prosecutor’s fallacy. The probability of the evidence existing if a person is guilty, P(evidence|guilty), is not the same as the probability the person is guilty given the evidence, P(guilty|evidence). In the case of English solicitor Sally Clark, who was wrongly convicted after two of her infants died, the court confused the very low probability of two infant deaths in one family with the very high probability of guilt. Those are inverse conditional probabilities, and conflating them led to a tragic miscarriage of justice.
Whenever you set up a conditional probability problem, double-check which event is the “given” (after the bar) and which is the one you’re solving for (before the bar). Getting them backwards will give you a completely different answer.
Quick Reference
For most problems, you only need to remember two formulas:
- Basic conditional probability: P(A|B) = P(A and B) / P(B)
- Bayes’ theorem: P(A|B) = P(B|A) × P(A) / P(B)
Use the first when you know (or can find) the overlap between A and B. Use the second when you know the conditional probability in the reverse direction. In both cases, make sure P(B) is greater than zero, and be careful not to swap which event is the “given.”

