Lesson Explainer: Conditional Probability: Two-Way Tables | Nagwa Lesson Explainer: Conditional Probability: Two-Way Tables | Nagwa

Lesson Explainer: Conditional Probability: Two-Way Tables Mathematics

In this explainer, we will learn how to deal with the concept of conditional probability using joint frequencies presented in two-way tables.

When collecting data on nonnumerical variables, we count how many times a particular characteristic occurs. We can then put our results in a table.

For example, a school may collect data on the number of pupils who travel to school by car, by foot, and by bicycle, as shown in the table below.

Mode of TransportCarFootBicycle
Number of Pupils450650200

Our population here is the number of pupils and the variable is the mode of transport, which is a categorical (i.e., nonnumerical) variable. In this data set, the variable has 3 categories: car, foot, and bicycle. We count the number of pupils who take each mode of transport.

We can delve deeper into the data by splitting it according to how many boys or girls took each mode of transport. So, the data varies not only across the mode of transport, but also with respect to whether the pupil is a boy or a girl, as shown below.

Mode of TransportCarFootBicycle
Boys200330120
Girls25032080

Our data is now displayed in a two-way table (which is sometimes also called a contingency table). The two in the two-way table refers to the two variables (which, in our case, are modes of transport and being a boy or a girl). Looking at the table, we can see that, for example, there were 200 boys who traveled by car, but only 120 boys who traveled by bicycle.

We can use two-way tables to calculate the probability of an event occurring as well as the conditional probability of an event occurring given, another event has occurred. To illustrate how this works, we will first recall the formula for conditional probability.

Definition: Conditional Probability

The probability that an event 𝐡 occurs, given that event 𝐴 has already occurred, is 𝑃(𝐡∣𝐴)=𝑃(𝐴∩𝐡)𝑃(𝐴), where 𝑃(𝐡∣𝐴) is the probability that 𝐡 occurred, given 𝐴 occurred, 𝑃(𝐴∩𝐡) is the probability that 𝐴 and 𝐡 occurred (happened) at the same time, and 𝑃(𝐴) is the probability that 𝐴 occurred.

Using the example above, we will discuss how to use a two-way table to find conditional probabilities.

If we want to find the probability that a pupil traveled by car given that they are a girl, then by replacing event 𝐡 with the event that they travel by car and event 𝐴 with the event that they are a girl we get 𝑃(∣)=𝑃(∩)𝑃().cargirlcargirlgirl

To calculate the probability of selecting a girl, we need to find the total number of girls and divide it by the total number of pupils. We can do this by summing the row for the girls and summing all the rows, or all the columns, to get the total number of pupils. Generally, it is helpful to calculate all the totals of the rows, columns, and overall total, as a first step when calculating probabilities from two-way tables.

Mode of TransportCarFootBicycleTotal
Boys200330120650
Girls25032080650
Total4506502001β€Žβ€‰β€Ž300

So, we need now the total number of girls and total number of pupils, as circled on the table below.

So, the total number of girls is 650, and the total number of pupils is 1β€Žβ€‰β€Ž300. So, to calculate the probability that a pupil is a girl, meaning the probability of selecting a girl, we write the following: 𝑃()==6501300.girltotalnumberofgirlstotalnumberofpupils

Next, we find the probability that the pupil selected travels by car and is a girl. We can use the two-way table to find the number of pupils who travel by car and are girls, then divide it by the total number of pupils.

So, the number of girls who travel by car is 250, and the total number of pupils is 1β€Žβ€‰β€Ž300, which means that the probability of selecting a girl who travels by car is 𝑃(∩)==2501300.cargirlnumberofgirlswhotravelbycartotalnumberofpupils

Therefore, by substituting 𝑃()=6501300girl and 𝑃(∩)=2501300cargirl in the formula for conditional probability we get 𝑃(∣)=𝑃(∩)𝑃()==2501300Γ—1300650=250650=513.cargirlcargirlgirl

Therefore, the probability of traveling by car given that the pupil is girl is 513.

Notice that, when calculating the probability of traveling by car given that the pupil is a girl, the total number of pupils, 1β€Žβ€‰β€Ž300, cancels out. This is because we can simply use the table to find the probability of traveling by car, given that a pupil is a girl, by finding the number of girls who travel by car and dividing it by the total number of girls (since it is given that they are a girl, we only consider the girls as the total). For the rest of the explainer, we will use this approach.

Using the table, we get:

So, the number of those who travel by car is 250 and the total number of girls is 650, which means that the probability that a pupil travels by car given that they are a girl is 𝑃(∣)==250650=513.cargirlnumberwhoareagirlandtravelbycartotalnumberofgirls

We will explore this approach further in the next example.

Example 1: Calculating a Conditional Probability from a Two-Way Frequency Table

The two-way table shows the ages and activity choices of a group of participants at a summer camp.

SwimmingClimbingRappelling
14 and Under15248
Over 14183224

A child is selected at random. Given that they chose rappelling, find the probability that the child is over 14.

Answer

To find the probability that a child is over 14 given that they chose rappelling, it is helpful to first calculate the totals of the rows and columns in the table.

SwimmingClimbingRappellingTotal
14 and Under1524847
Over 1418322474
Total335632121

Next, as we are calculating the probability that a child is over 14 given that they chose rappelling, we want to find the number of children over the age of 14 who chose rappelling and divide this by the total number of children who chose rappelling. This can be seen below in the table.

So, the number of children over the age of 14 who chose rappelling is 24, and the total number of children who chose rappelling is 32. Dividing these in order to find the probability that a child is over 14 given that they chose rappelling is 𝑃(14∣)==2432=34.overrappellingnumberover14andchoserappellingtotalnumberwhochoserappelling

Therefore, the probability that a child selected at random is over 14 given that they chose rappelling is 34, or 75%.

In the following example, we will consider how to find the probability of an event and the probability of a conditional event.

Example 2: Conditional Probability from a Two-Way Table

The table below contains data from a survey of core gamers who were asked whether their preferred gaming platform was the smartphone, the console, or the PC. The gamers are split by gender.

  1. Find the probability that a core gamer chosen at random prefers using a console. Give your answer to three decimal places.
  2. Given that a core gamer prefers to play using a console, find the probability that they are male. Give your answer to three decimal places.

Answer

Let us first work out the totals for the rows and columns of our table.

Part 1

To find the probability that a core gamer chosen at random prefers using a console, we find the number of gamers who prefer a console and divide by the total number of gamers.

Let C be the number of gamers who prefer a console; then, 𝑃()==60243=0.2473Cnumberofgamerspreferringconsoletotalnumberofgamerstod.p.

As a percentage, this is 0.247Γ—100=24.7%β‰ˆ25%. Hence, approximately 25% of gamers prefer to use a console.

Part 2

Given that a core gamer prefers to play using a console, we want to find the probability that they are male. Because we are only now interested in gamers who prefer a console, those who prefer to use smart phones or PCs do not figure in this calculation. So we only need to look at the β€œconsole” row in the table (highlighted in blue).

Our conditional probability, 𝑃(∣)MaleConsole, the probability that a gamer chosen at random is male given that they prefer a console, is then 𝑃(∣)==3760=0.6173MaleConsolenumberofmaleswhopreferconsoletotalwhopreferconsoletod.p.

As 0.617Γ—100β‰ˆ62%, we can say, given that a gamer chosen at random prefers a console, that there is approximately a 62% chance that they are male.

In the next example, we will consider how to use a two-way table to find a conditional probability where the given condition is more than two sets of categories.

Example 3: Calculating Conditional Probabilities Using a Two-Way Table

Two boxes contain a number of defective, partially defective (failing after a couple of hours of use), and acceptable light bulbs.

The numbers are given in the table.

Box 1Box 2
Defective123
Partially Defective322
Acceptable2540

A light bulb is chosen at random and put to use. If it does not fail immediately, what is the probability that it is chosen from box 2? Round your answer to three decimal places.

Answer

When working with two-way tables it is helpful to find the totals of the rows and columns first, as follows.

Box 1Box 2Total
Defective12315
Partially Defective32225
Acceptable254065
Total4065105

We are asked if a light bulb does not fail immediately, then we are asked what is the probability that it is chosen from box 2. We need to be careful with categories here, as defective means it fails immediately, partially defective means it fails after a couple of hours, so not immediately, and acceptable means it does not fail. That means that it does not fail immediately if it is acceptable or partially defective. So, we are trying to find the probability that a bulb is chosen from box 2 given that it is either acceptable or partially defective.

To find the probability that a bulb is chosen from box 2 given that it is either acceptable or partially defective, we need to first find how many bulbs are chosen from the box that are either acceptable or partially defective. We can do this by using the table and finding the number of bulbs that are from box 2 and acceptable and the number of bulbs that are from box 2 and partially defective, then adding these together.

Therefore, the number of bulbs that are chosen from box 2 and are either acceptable or partially defective is 22+40=62.

Next, to find the probability that a bulb is chosen from box 2 given that it is either acceptable, or partially defective, we need to find the total number of bulbs that are either acceptable or partially defective. Again, we will use the table to find the total number of bulbs that are acceptable and the total number of bulbs that are partially defective, then add them together.

Therefore, the total number of bulbs that are either acceptable or partially defective is 25+65=90.

Now, we calculate the probability that a bulb is chosen from box 2 given that it is either acceptable or partially defective by dividing the number of bulbs chosen from box 2 and are either acceptable or partially defective by the total number of bulbs that are either acceptable or partially defective. This gives us 𝑃(∣)==6290=0.689.box2acceptableorpartiallydefectivenumberfrombox2andacceptableorpartiallydefectivetotalnumberthatareacceptableorpartiallydefectivecorrectto3decimalplaces

In the following example, we will discuss a question where information not presented in a table is first put in a table and then a conditional probability is found.

Example 4: Two-Way Tables, Conditional Probability, and the Relationship between Categorical Variables

In a group of 96 people, 34 out of the 71 women have a smartphone, and 18 men do not have a smartphone. Determine the probability that a randomly picked smartphone owner in this group will be female.

Answer

We are given some information about 96 people that can be classified into two sets of categories: whether they are men or women and whether they own a smartphone or not. Using a two-way table, we can input the information we know and then work out any missing information.

As we are told that there are 96 people, this number goes in the overall total in the bottom right of the table. Since we know that 34 out of 71 women own a smartphone, then we know that there are 71 women in total; this goes at the bottom of the column for women. We also know that 34 are smartphone owners, this goes in the cell in the row of smartphone owners and the column of women. We also know that 18 men do not have a smartphone, so this goes in the row of not smartphone owners, and the column of men.

MenWomenTotal
Smartphone Owners34
Not Smartphone Owners18
Total7196

We can deduce the other information by adding or subtracting different amounts to fill in blank cells. First, we can work out how many women do not own a smartphone by subtracting 34 from 71, which gives us 37.

Second, we can find the total number of those who do not own smartphones by adding the number of men, 18, and the number of women, 37, who do not own smartphones. This gives us 55.

Third, we can find the total number of men by subtracting the total number of women, 71, from the total number of people, 96, giving us 25.

Fourth, we can find the number of men who own a smartphone by subtracting the number of men who do not own a smartphone, 18, from the total number of men, 25, giving us 7.

Lastly, we can calculate the total number of smartphone owners by adding the number of men who own a smartphone, 7, and the number of women who own a smartphone, 34, which gives us 41.

We can add the total number of smartphone owners, 41 and the total number of those who do not own a smartphone, 55, to check our answers. This gives 96, which is the overall total.

Now that we have filled in all the information into the two-way table, we can calculate the probability that a randomly picked smartphone owner is a woman. In other words, we want to find the probability that a person selected is a woman given that they are a smartphone owner.

To calculate the probability that a person selected is a woman given that they are a smartphone owner, we want to divide the number of women who are smartphone owners by the total number of smartphone owners. We can find this information from the table.

So, the number of women who are smartphone owners is 34, and the total number of smartphone owners is 41. Calculating the probability that a woman is selected given that she is a smartphone owner, we get 𝑃(∣)==3441.womansmartphonenumberofwomenwhoaresmartphoneownersnumberofsmartphoneowners

Therefore, the probability that a randomly selected smartphone owner is a woman is 3441.

In the last example, we will consider another case where the information presented is not in a table and require to be filled in the table and requires unknown information in order to calculate a conditional probability.

Example 5: Calculating Conditional Probabilities by Inputting into a Two-Way Table

A company manufactures a product in two different plants, π‘ƒοŠ§ and π‘ƒοŠ¨. The company supplies three customers, 𝐢, 𝐢, and 𝐢 equally, each with 80 units a month. π‘ƒοŠ§ produces 10 units of this product per month and the company distributes this amount among the three customers 𝐢, 𝐢, and 𝐢 in percentages of 20%, 30%, and 50% respectively. If you select a unit at random from a 𝐢 outlet, find the probability that it is produced by π‘ƒοŠ¨.

Answer

As we have two different variables in this question, the two different plants π‘ƒοŠ§ and π‘ƒοŠ¨, and the three different customers 𝐢, 𝐢, and 𝐢, we can use a two-way table to present the information as follows.

𝐢𝐢𝐢Total
π‘ƒοŠ§
π‘ƒοŠ¨
Total

We are told that the company supplies each of the three customers with 80 units each per month. This means the total for the columns of 𝐢, 𝐢, and 𝐢 are each 80. It also means that the overall total is the sum of these, which is 240.

𝐢𝐢𝐢Total
π‘ƒοŠ§
π‘ƒοŠ¨
Total808080240

Next, we are told that π‘ƒοŠ§ produces 10 units per month, which means that the total for the row π‘ƒοŠ§ is 10. Since we know that the 10 units are distributed to 𝐢, 𝐢, and 𝐢 in percentages of 20%, 30%, and 50%, then we know that the number of π‘ƒοŠ§ that 𝐢 has is 20% of 10, which is 2, the number of π‘ƒοŠ§ that 𝐢 has is 30% of 10, which is 3, and the number of π‘ƒοŠ§ that 𝐢 has is 50% of 10, which is 5. We can then input this information in the row of π‘ƒοŠ§.

𝐢𝐢𝐢Total
π‘ƒοŠ§23510
π‘ƒοŠ¨
Total808080240

We can find the remaining information needed in the table by adding or subtracting rows and columns. We can find the amounts of π‘ƒοŠ¨ that each of the customers ordered by subtracting π‘ƒοŠ§ from the total. This gives us 80βˆ’2=78 for 𝐢, 80βˆ’3=77 for 𝐢, and 80βˆ’5=75 for 𝐢. We can then input this information in the row of π‘ƒοŠ¨.

𝐢𝐢𝐢Total
π‘ƒοŠ§23510
π‘ƒοŠ¨787775
Total808080240

To find the total of π‘ƒοŠ¨ we can sum each amount that 𝐢, 𝐢, and 𝐢 ordered, giving us 78+77+75=230. We can see that, by subtracting the total of π‘ƒοŠ§, 10, from the overall total, 240, that this is correct.

𝐢𝐢𝐢Total
π‘ƒοŠ§23510
π‘ƒοŠ¨787775230
Total808080240

Now that we have found all of the information in the two-way table, we can calculate the probability that if a unit is selected from 𝐢, it is produced by π‘ƒοŠ¨, or, in other words, the probability of selecting a unit produced by π‘ƒοŠ¨ given that it is selected for 𝐢. To calculate this, we need to calculate the number of units produced by π‘ƒοŠ¨ for 𝐢 and divide it by the total number of units produced by π‘ƒοŠ¨. We find this information from the table as follows.

So, the number of units per month produced by π‘ƒοŠ¨ for 𝐢 is 75, and the total number of units produced for 𝐢 is 80. Therefore, the probability of selecting a unit produced by π‘ƒοŠ¨ given that it is selected for 𝐢 is 𝑃(π‘ƒβˆ£πΆ)=𝑃𝐢𝐢=7580=0.9375.numberfromfortotalnumberfor

Therefore, the probability that a unit selected from a 𝐢 outlet is produced by π‘ƒοŠ¨ is 0.9375.

In this explainer, we have learned how to use two-way tables to find conditional probabilities. Let’s recap the key points.

Key Points

  • The two in two-way table refers to the fact that there are two variables under consideration.
  • In a two-way table, we organize the counts, or frequencies, for the categories of two categorical variables.
  • Values (or categories) of the row variable label the rows running across the table, and values (or categories) of the column variable label the columns running down the table.
  • We use two-way tables to examine the relationship between two categorical variables. In particular, we can look at conditional probabilities.
  • Conditional probabilities can be read directly from two-way tables.
  • The probability of event 𝐡 given that event 𝐴 has occurred, 𝑃(𝐡∣𝐴), is a fraction where the denominator is the total for event 𝐴 and the numerator is the number of occurrences of 𝐡∩𝐴: 𝑃(𝐡∣𝐴)=𝐡𝐴𝐴.numberofoccurrencesofandtotal
  • We can also use the conditional probability formula, 𝑃(𝐡∣𝐴)=𝑃(𝐴∩𝐡)𝑃(𝐴), where 𝑃(𝐴∩𝐡) is the probability of both 𝐴 and 𝐡 occurring at the same time.

Join Nagwa Classes

Attend live sessions on Nagwa Classes to boost your learning with guidance and advice from an expert teacher!

  • Interactive Sessions
  • Chat & Messaging
  • Realistic Exam Questions

Nagwa uses cookies to ensure you get the best experience on our website. Learn more about our Privacy Policy