Skip to content

Conditional probability

Conditional probability is the probability of an event when some information is already known. If BB is known to have occurred, then the possible outcomes are restricted to BB. The conditional probability of AA given BB is

P(AB)=P(AB)P(B)provided P(B)>0.\boxed{\operatorname{P}(A\mid B)=\frac{\operatorname{P}(A\cap B)}{\operatorname{P}(B)}} \qquad \text{provided }\operatorname{P}(B)>0.

The symbol ABA\mid B is read as ”AA given BB”. It does not mean division. The event after the vertical bar is the information assumed to be true.

You should be able to:

  • use complements, intersections and unions from probability;
  • distinguish mutually exclusive events from independent events;
  • multiply along branches and add between alternative routes in a probability tree;
  • form fractions from frequencies in a table.

Suppose a fair die is rolled. Let

A={the result is even},B={the result is greater than 3}.A=\{\text{the result is even}\},\qquad B=\{\text{the result is greater than }3\}.

Without extra information, A={2,4,6}A=\{2,4,6\} and P(A)=3/6\operatorname{P}(A)=3/6. If BB is known, the relevant sample space shrinks from {1,2,3,4,5,6}\{1,2,3,4,5,6\} to {4,5,6}\{4,5,6\}. Two of these three outcomes are even, so

P(AB)=23.\operatorname{P}(A\mid B)=\frac23.

The formula gives the same result:

P(AB)=P(AB)P(B)=2/63/6=23.\operatorname{P}(A\mid B) =\frac{\operatorname{P}(A\cap B)}{\operatorname{P}(B)} =\frac{2/6}{3/6} =\frac23.

The denominator is P(B)\operatorname{P}(B) because knowing BB has occurred makes BB the new whole.

Worked example 1: cards without replacement

Section titled “Worked example 1: cards without replacement”

One card is chosen at random from an ordinary pack of 5252 cards. Given that it is a picture card, find the probability that it is a king.

There are 1212 picture cards: four jacks, four queens and four kings. Once “picture card” is known, only these 1212 cards remain relevant. Therefore

P(kingpicture)=412=13.\boxed{\operatorname{P}(\text{king}\mid\text{picture})=\frac4{12}=\frac13.}

Using all 5252 cards in the denominator would ignore the given information.

A student is selected from a group of 1818 students. Ten study physics, seven study chemistry, and four study both. Given that the student studies physics, find the probability that the student also studies chemistry.

Answer

The new whole is the 1010 physics students. Four of them also study chemistry, so

P(CP)=410=25.\boxed{\operatorname{P}(C\mid P)=\frac4{10}=\frac25.}

Rearranging the conditional probability formula gives

P(AB)=P(B)P(AB).\boxed{\operatorname{P}(A\cap B)=\operatorname{P}(B)\operatorname{P}(A\mid B).}

Equally, reversing the roles of the events gives

P(AB)=P(A)P(BA).\boxed{\operatorname{P}(A\cap B)=\operatorname{P}(A)\operatorname{P}(B\mid A).}

These equations describe the same intersection by entering it from different directions. They also explain the multiply rule on a tree diagram: the probability at the end of a route is the product of the branch probabilities along that route.

A bag contains 55 red and 33 blue counters. Two counters are selected without replacement. Find the probability that both are red.

After a red counter is selected first, 44 red counters remain among 77 counters. Thus

P(R1)=58,P(R2R1)=47.\operatorname{P}(R_1)=\frac58, \qquad \operatorname{P}(R_2\mid R_1)=\frac47.

Hence

P(R1R2)=P(R1)P(R2R1)=58×47=514.\begin{aligned} \operatorname{P}(R_1\cap R_2) &=\operatorname{P}(R_1)\operatorname{P}(R_2\mid R_1)\\ &=\frac58\times\frac47\\ &=\boxed{\frac5{14}}. \end{aligned}

The second probability is conditional. Without replacement, the contents of the bag change, so writing 5/8×5/85/8\times5/8 would be incorrect.

The same bag contains 55 red and 33 blue counters. Two are selected without replacement. Find the probability of at least one red counter.

The complement of “at least one red” is “both blue”. Therefore

P(at least one red)=1P(B1B2)=138×27=1328=2528.\begin{aligned} \operatorname{P}(\text{at least one red}) &=1-\operatorname{P}(B_1\cap B_2)\\ &=1-\frac38\times\frac27\\ &=1-\frac3{28}\\ &=\boxed{\frac{25}{28}}. \end{aligned}

Using a complement avoids separately calculating the routes red then red, red then blue, and blue then red.

Tree diagrams with conditional probabilities

Section titled “Tree diagrams with conditional probabilities”

On a tree diagram:

  • branches leaving the same point must sum to 11;
  • multiply probabilities along one complete route;
  • add probabilities for mutually exclusive routes that satisfy the question.

The second set of branches may depend on the outcome of the first event. Labels should make this dependence explicit.

A factory uses two machines. Machine M1M_1 makes 60%60\% of the components and machine M2M_2 makes the rest. Of the components made by M1M_1, 2%2\% are defective. Of those made by M2M_2, 5%5\% are defective. Find the probability that a randomly selected component is defective.

There are two mutually exclusive routes to a defective component:

M1DorM2D.M_1\cap D \qquad\text{or}\qquad M_2\cap D.

Calculate each route, then add:

P(D)=P(M1)P(DM1)+P(M2)P(DM2)=(0.60)(0.02)+(0.40)(0.05)=0.012+0.020=0.032.\begin{aligned} \operatorname{P}(D) &=\operatorname{P}(M_1)\operatorname{P}(D\mid M_1) +\operatorname{P}(M_2)\operatorname{P}(D\mid M_2)\\ &=(0.60)(0.02)+(0.40)(0.05)\\ &=0.012+0.020\\ &=\boxed{0.032}. \end{aligned}

This is an instance of the law of total probability: split an event into all possible routes leading to it.

For the factory in Example 4, a selected component is known to be defective. Find the probability that it was made by M2M_2.

The question asks for P(M2D)\operatorname{P}(M_2\mid D), not P(DM2)\operatorname{P}(D\mid M_2). Use the route probability from the tree and divide by the total probability of being defective:

P(M2D)=P(M2D)P(D)=(0.40)(0.05)0.032=0.0200.032=0.625.\begin{aligned} \operatorname{P}(M_2\mid D) &=\frac{\operatorname{P}(M_2\cap D)}{\operatorname{P}(D)}\\ &=\frac{(0.40)(0.05)}{0.032}\\ &=\frac{0.020}{0.032}\\ &=\boxed{0.625}. \end{aligned}

Although M2M_2 makes only 40%40\% of all components, it accounts for 62.5%62.5\% of defective components because its defect rate is higher.

A disease affects 1%1\% of a population. A test is positive for 95%95\% of people with the disease and for 4%4\% of people without it. A person tests positive. Find the probability that they have the disease.

Answer

Let DD mean the person has the disease and ++ mean a positive test. First find the two routes to a positive result:

P(D+)=(0.01)(0.95)=0.0095,\operatorname{P}(D\cap +)=(0.01)(0.95)=0.0095, P(D+)=(0.99)(0.04)=0.0396.\operatorname{P}(D'\cap +)=(0.99)(0.04)=0.0396.

Therefore

P(D+)=0.00950.0095+0.0396=0.00950.04910.193.\begin{aligned} \operatorname{P}(D\mid +) &=\frac{0.0095}{0.0095+0.0396}\\ &=\frac{0.0095}{0.0491}\\ &\approx\boxed{0.193}. \end{aligned}

The result is much smaller than 0.950.95. The 95%95\% is P(+D)\operatorname{P}(+\mid D), which is the reverse conditional probability.

Conditional probability from a two way table

Section titled “Conditional probability from a two way table”

Tables are particularly useful when data are given as frequencies. Restrict attention to the row or column representing the condition, then form a proportion within that total.

A survey records how 200200 people travel to work.

CarPublic transportTotal
Under 405466120
40 or over483280
Total10298200

Let CC mean travels by car and UU mean under 40.

Given that a person is under 40, the relevant total is 120120:

P(CU)=54120=0.45.\operatorname{P}(C\mid U)=\frac{54}{120}=\boxed{0.45}.

Given that a person travels by car, the relevant total is 102102:

P(UC)=54102=917.\operatorname{P}(U\mid C)=\frac{54}{102}=\boxed{\frac9{17}}.

Both calculations use the same intersection frequency, 5454, but their denominators differ because the conditions differ.

Using the table above, find:

  1. P(UC)\operatorname{P}(U\mid C');
  2. P(CU)\operatorname{P}(C'\mid U').
Answer
  1. CC' means public transport. Of the 9898 public transport users, 6666 are under 40:

    P(UC)=6698=3349.\boxed{\operatorname{P}(U\mid C')=\frac{66}{98}=\frac{33}{49}}.
  2. UU' means aged 40 or over. Of these 8080 people, 3232 use public transport:

    P(CU)=3280=25.\boxed{\operatorname{P}(C'\mid U')=\frac{32}{80}=\frac25}.

Events AA and BB are independent if knowing that one has occurred does not change the probability of the other. Provided the relevant conditional probability is defined,

P(AB)=P(A).\boxed{\operatorname{P}(A\mid B)=\operatorname{P}(A).}

Using the multiplication rule, this is equivalent to

P(AB)=P(A)P(B).\boxed{\operatorname{P}(A\cap B)=\operatorname{P}(A)\operatorname{P}(B).}

Either statement can be used to test independence. The product test is often most convenient when joint and marginal probabilities are given.

For the travel survey in Example 6, determine whether being under 40 and travelling by car are independent.

From the table,

P(C)=102200=0.51\operatorname{P}(C)=\frac{102}{200}=0.51

but

P(CU)=54120=0.45.\operatorname{P}(C\mid U)=\frac{54}{120}=0.45.

Since 0.450.510.45\ne0.51, knowing that a person is under 40 changes the probability that they travel by car. Therefore CC and UU are not independent.

We could instead compare

P(CU)=54200=0.27\operatorname{P}(C\cap U)=\frac{54}{200}=0.27

with

P(C)P(U)=102200×120200=0.306.\operatorname{P}(C)\operatorname{P}(U) =\frac{102}{200}\times\frac{120}{200} =0.306.

These are unequal, giving the same conclusion.

Worked example 8: finding an unknown using independence

Section titled “Worked example 8: finding an unknown using independence”

Events AA and BB are independent, with

P(A)=0.4,P(AB)=0.7.\operatorname{P}(A)=0.4, \qquad \operatorname{P}(A\cup B)=0.7.

Find P(B)\operatorname{P}(B).

Let P(B)=p\operatorname{P}(B)=p. Independence gives

P(AB)=0.4p.\operatorname{P}(A\cap B)=0.4p.

Use the addition rule:

P(AB)=P(A)+P(B)P(AB)0.7=0.4+p0.4p0.3=0.6pp=0.5.\begin{aligned} \operatorname{P}(A\cup B) &=\operatorname{P}(A)+\operatorname{P}(B)-\operatorname{P}(A\cap B)\\ 0.7&=0.4+p-0.4p\\ 0.3&=0.6p\\ p&=0.5. \end{aligned}

Therefore

P(B)=0.5.\boxed{\operatorname{P}(B)=0.5.}

Events AA and BB satisfy

P(A)=0.3,P(B)=0.6,P(AB)=0.18.\operatorname{P}(A)=0.3,\qquad \operatorname{P}(B)=0.6,\qquad \operatorname{P}(A\cap B)=0.18.

Are AA and BB independent? Find P(AB)\operatorname{P}(A\mid B).

Answer

Since

P(A)P(B)=(0.3)(0.6)=0.18=P(AB),\operatorname{P}(A)\operatorname{P}(B)=(0.3)(0.6)=0.18 =\operatorname{P}(A\cap B),

the events are independent. Also,

P(AB)=0.180.6=0.3,\operatorname{P}(A\mid B)=\frac{0.18}{0.6}=\boxed{0.3},

which equals P(A)\operatorname{P}(A), as expected.

Conditional probability can determine an unknown parameter. Keep probabilities exact where possible and check that every solution lies between 00 and 11.

Suppose

P(A)=0.55,P(B)=0.40,P(AB)=0.70.\operatorname{P}(A)=0.55,\qquad \operatorname{P}(B)=0.40,\qquad \operatorname{P}(A\cup B)=0.70.

Find P(AB)\operatorname{P}(A\mid B).

First use the addition rule to find the intersection:

P(AB)=P(A)+P(B)P(AB)=0.55+0.400.70=0.25.\begin{aligned} \operatorname{P}(A\cap B) &=\operatorname{P}(A)+\operatorname{P}(B)-\operatorname{P}(A\cup B)\\ &=0.55+0.40-0.70\\ &=0.25. \end{aligned}

Now condition on BB:

P(AB)=0.250.40=0.625.\operatorname{P}(A\mid B) =\frac{0.25}{0.40} =\boxed{0.625}.

Worked example 10: reconstructing a probability tree

Section titled “Worked example 10: reconstructing a probability tree”

A student either walks or takes a bus to college. The probability that the student walks is ww. If the student walks, the probability of arriving late is 0.10.1. If the student takes the bus, it is 0.30.3. The overall probability of arriving late is 0.220.22. Find ww.

The probabilities of walking and taking the bus are ww and 1w1-w. Add the two routes to being late:

0.22=0.1w+0.3(1w)0.22=0.1w+0.30.3w0.08=0.2ww=0.4.\begin{aligned} 0.22&=0.1w+0.3(1-w)\\ 0.22&=0.1w+0.3-0.3w\\ -0.08&=-0.2w\\ w&=0.4. \end{aligned}

Thus

P(walks)=0.4.\boxed{\operatorname{P}(\text{walks})=0.4.}

As a check, (0.4)(0.1)+(0.6)(0.3)=0.04+0.18=0.22(0.4)(0.1)+(0.6)(0.3)=0.04+0.18=0.22.

P(AB)\operatorname{P}(A\mid B) restricts the sample space to BB. It is not usually equal to P(BA)\operatorname{P}(B\mid A). In context, write both probabilities in words.

The denominator is the probability of the event after the bar:

P(AB)=P(AB)P(B).\operatorname{P}(A\mid B)=\frac{\operatorname{P}(A\cap B)}{\operatorname{P}(B)}.

Multiplying P(A)\operatorname{P}(A) by P(B)\operatorname{P}(B) is valid only for independent events. In general, use

P(AB)=P(A)P(BA).\operatorname{P}(A\cap B)=\operatorname{P}(A)\operatorname{P}(B\mid A).

Alternative complete routes on a tree are mutually exclusive, so they can be added. For general events that overlap, use

P(AB)=P(A)+P(B)P(AB).\operatorname{P}(A\cup B) =\operatorname{P}(A)+\operatorname{P}(B)-\operatorname{P}(A\cap B).

Keep route probabilities and totals exact until the final line. Early rounding can noticeably alter a reverse conditional probability because one rounded value is divided by another.

  1. A box contains 66 green and 44 yellow balls. Two balls are selected without replacement. Find the probability that the second ball is yellow given that the first is green.
  2. Given P(A)=0.7\operatorname{P}(A)=0.7, P(B)=0.5\operatorname{P}(B)=0.5 and P(AB)=0.35\operatorname{P}(A\cap B)=0.35, determine whether AA and BB are independent.
  3. A shop receives 70%70\% of its batteries from supplier XX and the remainder from supplier YY. The failure rates are 1%1\% for XX and 3%3\% for YY. Find the probability that a failed battery came from YY.
  4. Events AA and BB satisfy P(AB)=0.6\operatorname{P}(A\mid B)=0.6 and P(B)=0.25\operatorname{P}(B)=0.25. Find P(AB)\operatorname{P}(A\cap B).
Answers
  1. After a green ball is removed, 44 of the remaining 99 balls are yellow:

    P(Y2G1)=49.\boxed{\operatorname{P}(Y_2\mid G_1)=\frac49}.
  2. Since

    P(A)P(B)=(0.7)(0.5)=0.35=P(AB),\operatorname{P}(A)\operatorname{P}(B)=(0.7)(0.5)=0.35 =\operatorname{P}(A\cap B),

    the events are independent.

  3. The failed routes have probabilities

    (0.70)(0.01)=0.007and(0.30)(0.03)=0.009.(0.70)(0.01)=0.007 \quad\text{and}\quad (0.30)(0.03)=0.009.

    Hence

    P(YF)=0.0090.007+0.009=0.5625.\operatorname{P}(Y\mid F) =\frac{0.009}{0.007+0.009} =\boxed{0.5625}.
  4. Rearrange the conditional probability formula:

    P(AB)=P(B)P(AB)=(0.25)(0.6)=0.15.\operatorname{P}(A\cap B) =\operatorname{P}(B)\operatorname{P}(A\mid B) =(0.25)(0.6) =\boxed{0.15}.

The essential ideas are:

P(AB)=P(AB)P(B),\operatorname{P}(A\mid B) =\frac{\operatorname{P}(A\cap B)}{\operatorname{P}(B)}, P(AB)=P(B)P(AB),\operatorname{P}(A\cap B) =\operatorname{P}(B)\operatorname{P}(A\mid B),

and, for independent events,

P(AB)=P(A)P(B).\operatorname{P}(A\cap B) =\operatorname{P}(A)\operatorname{P}(B).

Conditioning changes the sample space. On trees, multiply along routes and add alternative routes. In tables, use the total belonging to the condition. Never reverse the events on either side of the bar without justification.