Tutorials › Introduction to Statistics › Using Bayes’ Rule to Reverse a Conditional

Conditional Probability and Bayes’ Rule · Tutorial 337 of 996

Using Bayes' Rule to Reverse a Conditional

Use Bayes’ Rule to find the probability of A after observing B, and see why knowing how common A is matters.

Beginner 9 min read

What You'll Learn

  • Distinguish the conditional probabilities \(P(B\mid A)\) and \(P(A\mid B)\).
  • Calculate a reversed conditional from \(P(B\mid A)\), \(P(A)\), and \(P(B\mid \text{not }A)\).
  • Derive Bayes’ Rule using the law of total probability.
  • Check that the events and probabilities make the calculation valid.
  • Explain how the probability of A changes the answer even when the conditional rates stay fixed.

Why Reversing a Conditional Takes More Information

Suppose an observation B is more likely when event A occurs. It may be tempting to conclude that, once B is observed, A is very likely. But these are different questions. \(P(B\mid A)\) asks how often B occurs among cases where A is true; \(P(A\mid B)\) asks how often A is true among cases where B is observed. The first probability does not, by itself, determine the second.

To reverse the conditional, we also need to know how common A is and how often B occurs when A is false. These quantities determine how much of the observed B comes from each of the two possible cases: A and not A.

Definition: Let A and B be events, with \(P(A)>0\), \(P(A)<1\), and \(P(B)>0\). Bayes’ Rule expresses the reversed conditional probability as
$$ P(A\mid B) = \frac{P(B\mid A)P(A)} {P(B\mid A)P(A)+P(B\mid \text{not }A)P(\text{not }A)}. $$
Here \(P(A)\) is the probability of A before conditioning on B, while \(P(A\mid B)\) is the probability of A among outcomes where B occurs.

The term \(P(B\mid A)P(A)\) is the probability that both A and B occur. The other term in the denominator, \(P(B\mid \text{not }A)P(\text{not }A)\), is the probability that B occurs while A does not. Adding these gives the total probability of B. The denominator is therefore not just a technical feature of the formula: it accounts for every way B can occur.

Where the Formula Comes From

The derivation uses the definition of conditional probability and the law of total probability. The events A and not A are disjoint and together include every outcome. Consequently, B can occur either together with A or together with not A, and these two cases do not overlap.

1
Write the conditional probability definition.
Provided \(P(B)>0\), \(P(A\mid B)=P(A\cap B)/P(B)\).
2
Express the intersection using the other conditional.
Provided \(P(A)>0\), the definition of \(P(B\mid A)\) gives \(P(A\cap B)=P(B\mid A)P(A)\).
3
Find the total probability of B.
Partitioning into A and not A gives \(P(B)=P(B\mid A)P(A)+P(B\mid \text{not }A)P(\text{not }A)\).
4
Substitute and simplify.
Substitute the expressions for the intersection and \(P(B)\) into the conditional probability definition to obtain Bayes’ Rule.

In equations, the argument is

$$ \begin{aligned} P(A\mid B) &= \frac{P(A\cap B)}{P(B)}\\ &= \frac{P(B\mid A)P(A)} {P(B\mid A)P(A)+P(B\mid \text{not }A)P(\text{not }A)}. \end{aligned} $$

Because A and not A are complementary, \(P(\text{not }A)=1-P(A)\). Thus the three supplied probabilities in the tutorial’s focus determine the calculation. No assumption that A and B are independent is needed. In fact, if they were independent, observing B would not change the probability of A.

Applying Bayes’ Rule

Before calculating, name the events and check that the given probabilities answer the correct questions. In particular, identify which number is \(P(B\mid A)\), which is \(P(B\mid \text{not }A)\), and which is \(P(A)\). The two conditional probabilities share B as the event being observed, but condition on opposite cases.

Worked Example: Selecting a Book by Its Cover

Imagine a catalog in which 40% of the books are fiction. Among fiction books, 25% have blue covers; among non-fiction books, 10% have blue covers. If one catalog book is selected and it has a blue cover, what is the probability that it is fiction?

Let A be the event that the selected book is fiction, and let B be the event that its cover is blue. The information is \(P(A)=0.40\), \(P(B\mid A)=0.25\), and \(P(B\mid \text{not }A)=0.10\). The complementary probability is \(P(\text{not }A)=1-0.40=0.60\). These are probabilities for one selection from the stated catalog, and the probability of observing a blue cover is positive.

Apply Bayes’ Rule:

$$ \begin{aligned} P(A\mid B) &=\frac{P(B\mid A)P(A)} {P(B\mid A)P(A)+P(B\mid \text{not }A)P(\text{not }A)}\\ &=\frac{(0.25)(0.40)} {(0.25)(0.40)+(0.10)(0.60)}\\ &=\frac{0.10}{0.10+0.06}\\ &=\frac{0.10}{0.16}=0.625. \end{aligned} $$

Given that the selected book has a blue cover, the probability it is fiction is 0.625, or 62.5%. This is not 25%: 25% is the probability of a blue cover among fiction books, not the probability of fiction among blue-cover books.

Worked Example: Being on Time in a Class Section

Consider a hypothetical course in which 35% of students attend a morning section. Of morning-section students, 90% arrive on time. Of students in other sections, 75% arrive on time. For a student chosen at random from the course who arrived on time, calculate the probability that the student attends the morning section.

Let A mean “attends the morning section” and B mean “arrives on time.” Then \(P(A)=0.35\), \(P(B\mid A)=0.90\), and \(P(B\mid \text{not }A)=0.75\). The complement has probability \(P(\text{not }A)=1-0.35=0.65\). The stated rates refer to the same course population and the on-time event has positive probability.

Substitute the values:

$$ \begin{aligned} P(A\mid B) &=\frac{(0.90)(0.35)} {(0.90)(0.35)+(0.75)(0.65)}\\ &=\frac{0.315}{0.315+0.4875}\\ &=\frac{0.315}{0.8025}\\ &\approx 0.3925. \end{aligned} $$

Among students who arrived on time, about 39.3% attend the morning section. Although morning-section students have the higher on-time rate, students in other sections are more numerous in this example. Their on-time arrivals therefore contribute substantially to the group of all on-time students. The calculation describes a conditional probability; it does not show that attending a particular section causes a student to arrive on time.

Why the Probability of A Matters

The probability \(P(A)\) is often called the prior probability or base rate for A. It matters because the question \(P(A\mid B)\) concerns the composition of the group for which B is observed. If A is uncommon, even a substantial value of \(P(B\mid A)\) may not make A common within that group: many B outcomes can still come from the larger group where A is false.

The next example isolates this point. The conditional rates for B will stay fixed, while the probability of A changes. The resulting reversed conditional will change as well.

Worked Example: The Same Evidence With Two Different Base Rates

In two hypothetical settings, let A be membership in a particular club and B be carrying a club badge. In both settings, 80% of members carry a badge, while 20% of nonmembers carry one. In Setting 1, 10% of people are members; in Setting 2, 50% are members. Find \(P(A\mid B)\) in each setting.

The event definitions and conditional rates are the same in both settings: \(P(B\mid A)=0.80\) and \(P(B\mid \text{not }A)=0.20\). Only \(P(A)\) changes. In Setting 1, \(P(A)=0.10\) and \(P(\text{not }A)=0.90\), so

$$ \begin{aligned} P(A\mid B) &=\frac{(0.80)(0.10)} {(0.80)(0.10)+(0.20)(0.90)}\\ &=\frac{0.08}{0.08+0.18} =\frac{0.08}{0.26} \approx 0.3077. \end{aligned} $$

Thus, in Setting 1, about 30.8% of badge carriers are club members. In Setting 2, \(P(A)=0.50\) and \(P(\text{not }A)=0.50\), giving

$$ \begin{aligned} P(A\mid B) &=\frac{(0.80)(0.50)} {(0.80)(0.50)+(0.20)(0.50)}\\ &=\frac{0.40}{0.40+0.10} =\frac{0.40}{0.50} =0.80. \end{aligned} $$

The reversed conditional is 80% in Setting 2, despite exactly the same rates of carrying a badge among members and nonmembers. The difference is the proportion of people who are members before looking at the badge. A conditional rate such as \(P(B\mid A)\) cannot be interpreted as \(P(A\mid B)\) without this additional information.

Checks, Interpretation, and a Common Pitfall

A useful way to verify a calculation is to examine the denominator before dividing. It must be the probability of B, formed from the two disjoint cases. The numerator is only the part of that total in which A is also true. Therefore the resulting ratio is between 0 and 1 whenever the inputs are valid and \(P(B)>0\).

The model for this calculation is an event partition: A and not A are complementary cases, and the supplied conditional probabilities describe the chance of B within each case. The inputs must be valid probabilities, \(P(A)\) must be strictly between 0 and 1 for both conditional terms to be defined in the usual way, and the denominator must be positive so that conditioning on B is possible. These requirements are not independence assumptions.

  • Use the direction that was actually given. A statement “B occurs in 80% of A cases” gives \(P(B\mid A)=0.80\), not \(P(A\mid B)=0.80\).
  • Use both ways B can occur. The denominator includes B among A cases and B among not-A cases.
  • Keep the conditioning population clear. \(P(A)\) describes the initial group; \(P(A\mid B)\) describes the subgroup where B occurred.
  • Check the result’s meaning. State it as a probability of A among outcomes with B, rather than as a probability that A is true in general.

A frequent mistake is to treat \(P(B\mid A)\) as if it were already \(P(A\mid B)\), or to divide the joint probability \(P(B\mid A)P(A)\) by that same joint probability. That denominator would count only outcomes where both A and B occur, making the ratio equal to 1 whenever the joint probability is positive. The correct denominator is \(P(B)\), including outcomes where B occurs and A is false. Bayes’ Rule matters because it makes that full comparison explicit.

Key takeaway: To reverse a conditional, multiply \(P(B\mid A)\) by \(P(A)\) for the numerator, then divide by the total probability of B across A and not A. The probability \(P(A)\) is essential because it tells how much of each case is present before B is observed.

Check Your Understanding

For each question, identify the events and the conditional probability being requested before calculating.

  1. In a population, \(P(A)=0.30\), \(P(B\mid A)=0.70\), and \(P(B\mid \text{not }A)=0.20\). Find \(P(A\mid B)\), showing the denominator.
  2. Explain in words why \(P(B\mid A)\) and \(P(A\mid B)\) answer different questions.
  3. Suppose \(P(B\mid A)=0.60\) and \(P(B\mid \text{not }A)=0.10\). If these rates stay fixed, explain why changing \(P(A)\) can change \(P(A\mid B)\).
  4. What does the denominator in Bayes’ Rule represent, and why does it include a term involving not A?
  5. What condition must hold for \(P(A\mid B)\) to be defined? Why would a zero denominator prevent the calculation?