Back to homeMathematics · High School Year 3 · Social Sciences · Change subject
Start for free
Prep 3 SS · Mathematics
Chance and probability · Probability

Contingency Tables

Before you start, make sure you know: Conditional probability (High School Year 2 (semesters 3 and 4))
Before you start, make sure you know: Contingency tables (High School Year 2 (semesters 3 and 4))

In your high school class, each student is asked whether they prefer TikTok or Instagram. How do you organize the answers to find out whether the preferred app depends on gender? The tool is a two-way table: rows for one variable, columns for the other. Before calculating anything, you need to know how to fill it in and read it, because every probability you're asked for comes from it.

Building and completing a contingency table

Breakfast contingency table: cereal versus fruit, with the cell for both equal to 40 and the totals known. Fruit No fruit Total Cereal No cereal Total 40 ? 120 ? ? ? 100 ? 200
Practice★☆☆Not started
In a study on social media use in a secondary school, 100 2nd year Bachillerato students were surveyed about their preferred platform. The data are shown in the…

In a study on social media use in a secondary school, 100 2nd year Bachillerato students were surveyed about their preferred platform. The data are shown in the following contingency table, although some values have been erased:

TikTok Instagram Total Boys Girls Total 25 35 ? ? 100 ? ? ? ?

Given that there is a total of 45 boys and 55 girls:

  1. a) Complete the missing values in the table.
  2. b) If we choose a student at random, what is the probability that their preferred network is TikTok?
  3. c) What is the probability that it is a girl who prefers Instagram?
Solve
Practice★☆☆Not started
A group of 200 teenagers was asked whether they have cereals or fruit for breakfast. The results were: 120 have cereals for breakfast, 100 have fruit for breakfast and…

A group of 200 teenagers was asked whether they have cereals or fruit for breakfast. The results were: 120 have cereals for breakfast, 100 have fruit for breakfast and 40 have both.

  1. a) Complete the following contingency table to organise the data:
Fruit No Fruit Total Cereals No Cereals Total 40 120 100 200
  1. b) What is the probability that a teenager has neither cereals nor fruit for breakfast?
  2. c) Given that a teenager has cereals for breakfast, what is the probability that they also have fruit for breakfast?
Solve
Practice★★☆Not started
A survey on voting intention and main social concern (Environment, Economy or Health) was conducted, obtaining the following partial probability table: | Concern | Party…

A survey on voting intention and main social concern (Environment, Economy or Health) was conducted, obtaining the following partial probability table:

Concern Party A Party B Totals
Environment $0.15$ $0.10$
Economy $0.25$ $0.45$
Health $0.12$
Totals $1.00$
  1. a) Complete the contingency table.
  2. b) Calculate the probability that a Party A voter is concerned about Health.
  3. c) Are the events "Voting for Party B" and "Being concerned about the Environment" independent? Justify your answer mathematically.
Solve

From percentages to a table

Often the problem doesn't give counts, but percentages or probabilities. The trick is to imagine a convenient group size (100, 500, 1,000, or 10,000 people) and turn each percentage into a number of people. That way the table is filled with whole numbers, no fractions.

Card Cash Total
Student 240 60 300
Non-student 100 100 200
Total 340 160 500

If the problem already gives probabilities (for example $P(A)=0.4$, $P(B)=0.7$), the table is filled in the same way, but the grand total is $1$ instead of $500$.

Practice★☆☆Not started
A survey was conducted on transport habits for going to university. $40\%$ of the students are male ($H$) and $60\%$ are female ($M$). $25\%$ of the males go by car…

A survey was conducted on transport habits for going to university. $40\%$ of the students are male ($H$) and $60\%$ are female ($M$). $25\%$ of the males go by car ($C$), whereas $15\%$ of the females use this mode of transport.

  1. a) Considering a sample of 100 people, construct the contingency table with absolute values.
  2. b) Calculate the probability that a randomly chosen person is female and does not use a car.
  3. c) Calculate the probability that, given they are male, they do not use a car.

You can do it on paper and send a photo with your answer.

Solve
Practice★★☆Not started
In a secondary school, $60\%$ of the 2nd-year Bachillerato students are female. It is known that $20\%$ of the girls take part in the debate club, while $10\%$ of the…

In a secondary school, $60\%$ of the 2nd-year Bachillerato students are female. It is known that $20\%$ of the girls take part in the debate club, while $10\%$ of the boys also do.

  1. a) Build a contingency table of relative frequencies (probabilities).
  1. b) If we select a student at random, what is the probability that they belong to the debate club?
  1. c) If the chosen student does not belong to the debate club, what is the probability that they are male?

You can do it on paper and send a photo with your answer.

Solve
Practice★★☆Not started
An e-commerce platform classifies its customers into "Frequent" and "Occasional", and their purchases into "Electronics" or "Fashion". It is known that $30\%$ of…

An e-commerce platform classifies its customers into "Frequent" and "Occasional", and their purchases into "Electronics" or "Fashion". It is known that $30\%$ of customers are Frequent. Of all purchases made, $40\%$ are Electronics. Furthermore, $10\%$ of total customers are Frequent who bought Fashion.

  1. a) Construct the complete contingency table of probabilities.
  2. b) What is the probability that a frequent customer buys Electronics?
  3. c) Given that a customer bought Electronics, what is the probability that they are an Occasional customer?

You can do it on paper and send a photo with your answer.

Solve

Marginal and joint probabilities

Padel tournament table with the interior cell man and league highlighted as joint and the total of men as marginal. In league Total (marginal) Men Women 20 (joint) 32 12 48 grand total: 80
Practice★☆☆Not started
A streaming platform analyses its users' preferences according to their age. A random sample is selected, and the following results are obtained: | | Films | Series |…

A streaming platform analyses its users' preferences according to their age. A random sample is selected, and the following results are obtained:

Films Series Total
Under 25 years old $0.15$ $0.35$ $0.50$
Over 25 years old $0.30$ $0.20$ $0.50$
Total $0.45$ $0.55$ $1.00$

Calculate the following probabilities when choosing a user at random:

  1. a) $P(\text{Series})$, that is, the probability that they prefer series.
  2. b) $P(\text{Films} \cap \text{Under 25})$.
  3. c) $P(\text{Over 25} \cup \text{Films})$.
Solve
Practice★☆☆Not started
In a padel tournament organized by the local municipality, 80 people participate. It is known that 32 are men and the rest women. Of the men, 20 are federated, whereas…

In a padel tournament organized by the local municipality, 80 people participate. It is known that 32 are men and the rest women. Of the men, 20 are federated, whereas among the women only 12 are federated.

  1. a) Organize the information in a contingency table.
  2. b) If we select a participant at random, calculate the probability that they are not federated.
  3. c) What is the probability that the participant is female, given that she is federated?
Solve
Practice★★☆Not started
A sports center offers Yoga, Pilates and Crossfit classes. The distribution of the $300$ members by activity and age group is as follows: | Activity | Young people…

A sports center offers Yoga, Pilates and Crossfit classes. The distribution of the $300$ members by activity and age group is as follows:

Activity Young people (16-30) Adults (>30)
Yoga $20$ $50$
Pilates $30$ $60$
Crossfit $110$ $30$
  1. a) If we choose a member at random, what is the probability that they practice Yoga or are Young?
  2. b) Among Adult members, which activity is the most probable?
  3. c) If a Crossfit practitioner is chosen, what is the probability that they are Young?
Solve

Conditional probability read from the table

Table with the women row highlighted: when conditioning on being a girl, only the cases in that row are considered. Car Other Total Boys Girls 15 45 60 27 63 90 Conditioning on "girl" = looking only at this row
Practice★☆☆Not started
Observe the following table classifying a company's employees according to their department and whether they have requested remote working: Calculate with reasoning…

Observe the following table classifying a company's employees according to their department and whether they have requested remote working:

Dept. Mode Sales (V) R&D (I) Total Remote working (T) In-person (P) Total 12 18 28 22 30 50 40 40 80

Calculate with reasoning using the table:

  1. a) $P(T | V)$, the probability that an employee works remotely if they belong to the Sales department.
  2. b) $P(I | T)$, the probability that an employee is from R&D given that they have requested remote working.
  3. c) What is more likely: that a Sales employee works remotely or that an R&D employee works remotely?
Solve
Practice★★☆Not started
In a study on digital content consumption habits among $200$ teenagers, it has been observed that $120$ are subscribed to a streaming platform. Of those who are…

In a study on digital content consumption habits among $200$ teenagers, it has been observed that $120$ are subscribed to a streaming platform. Of those who are subscribed, $80$ prefer watching series over films. Among those who do not pay for a subscription, $30$ prefer films.

  1. a) Organise the above information in a contingency table.
  2. b) If we choose a teenager at random, what is the probability that they prefer watching series?
  3. c) Given that the chosen teenager prefers films, what is the probability that they are not subscribed to any platform?
Series Films Total Subscribed Not subscribed Total 80 30 120 200 - - - - -
Solve
Practice★★☆Not started
In a medical study on the effectiveness of a vaccine, the following data are obtained from a sample of $1000$ patients: | | Became ill | Did not become ill | Totals | |…

In a medical study on the effectiveness of a vaccine, the following data are obtained from a sample of $1000$ patients:

Became ill Did not become ill Totals
Vaccinated $20$ $600$
Unvaccinated $280$
Totals $1000$
  1. a) Complete the table.
  2. b) Calculate the probability of becoming ill having been vaccinated.
  3. c) Calculate the probability of becoming ill having not been vaccinated.
  4. d) In view of the results, do you consider that the vaccine is effective? Justify your answer by comparing conditional probabilities.
Solve

Reading it backwards: tests and false alarms

Data are often given in one direction ("if there is fraud, the system detects it $98\%$ of the time") and the question goes the other way ("if the system flagged the transaction, how likely is it to be fraud?"). The table with a large sample solves this without new formulas: it is the reading of $P(B\mid A)$ versus $P(A\mid B)$.

Positive Negative Total
Sick 90 10 100
Healthy 495 9,405 9,900
Total 585 9,415 10,000

Only about $15\%$ of the positives are actually sick, even though the test is right $90\%$ of the time with sick people. The reason is that there are far more healthy people than sick ones, and the $5\%$ false alarms over so many healthy people outweigh the $90$ correct detections.

Practice★★★Not started
A cybersecurity department analyses the email traffic of a large technology company. It is known that $12\%$ of the emails entering the server are phishing attempts…

A cybersecurity department analyses the email traffic of a large technology company. It is known that $12\%$ of the emails entering the server are phishing attempts (fraud). The smart filtering system labels emails as "Suspicious" or "Safe".

The system is able to correctly detect $95\%$ of phishing emails. However, due to overcautiousness, $3\%$ of legitimate emails are wrongly labelled as "Suspicious".

  1. a) Organise the information in a contingency table using a theoretical sample of $10\,000$ emails.
  1. b) If an employee receives an email labelled as "Suspicious", what is the probability that it is actually a legitimate email?
  1. c) Are the events "Phishing Email" and "Labelled as Suspicious" independent events? Justify your answer by calculating probabilities.
12% 88% 95% 5% 3% 97% Total Emails 10 000 Phishing ? Legitimate ? Suspicious ? Safe ? Suspicious ? Safe ? a) Contingency Table Suspicious Safe Total Phishing ? ? ? Legitimate ? ? ? Total ? ? 10 000 b) Posterior probability P(Legitimate | Suspicious) = ? c) Independence Analysis P(Phishing ∩ Susp.) ≟ P(Phishing) · P(Susp.)
Solve
Practice★★★Not started
A mobile payment platform uses an automated fraud detection system. System data indicate that it correctly detects $98\%$ of actually fraudulent transactions ($F$). On…

A mobile payment platform uses an automated fraud detection system. System data indicate that it correctly detects $98\%$ of actually fraudulent transactions ($F$). On the other hand, it generates a "false alarm" (labels a legitimate transaction, $L$, as suspicious) in $4\%$ of cases. On the platform, it is estimated that $5\%$ of transactions are fraudulent.

  1. a) Create a contingency table for a sample of $10\,000$ transactions.
  1. b) If a transaction has been flagged as suspicious, what is the actual probability that it is fraudulent? Comment on the result obtained in relation to the reliability of the system.
  1. c) If the system does not flag a transaction, what is the probability that it is actually legitimate?
5% 95% 98% 2% 4% 96% 10 000 ? ? ? ? ? ? Fraud (F) Legitimate (L) Alert (+) Alert (-) Alert (+) Alert (-) Fraud (F) Legitimate (L) Total Alert (+) Alert (-) Total ? ? ? ? ? ? ? ? 10 000 b) Actual probability if flagged: P(F | +) = ? c) Actual probability if not flagged: P(L | -) = ?
Solve
Practice★★★Not started
A second-hand clothing sales platform analyzes the behavior of its users. $60\%$ of the users are "Repeat Buyers" ($C$), while the rest are "Occasional Buyers". It is…

A second-hand clothing sales platform analyzes the behavior of its users. $60\%$ of the users are "Repeat Buyers" ($C$), while the rest are "Occasional Buyers".

It is observed that $70\%$ of repeat buyers use the mobile app for their transactions, whereas only $30\%$ of occasional buyers use it (preferring the website).

  1. a) If we select a user at random, what is the probability that they use the website to make their purchases?
  1. b) If we know that a user has made a purchase via the website, what is the probability that they are a repeat buyer?
  1. c) Represent the situation using a contingency table for a population of $500$ users.
0.6 0.4 0.7 0.3 0.3 0.7 Users Repeat Occasional App Web App Web 0,6 × 0,7 = ? 0,6 × 0,3 = ? 0,4 × 0,3 = ? 0,4 × 0,7 = ? N=500 App Web Total Repeat Occasional Total ? ? ? ? ? ? ? ? 500 a) P(Web) = ? b) P(Recurrente | Web) = ?
Solve

Checking independence with a table

Two boxes: same proportion in each row means independent; different proportion depending on the row means dependent. same proportion in each row independent different proportion depending on the row dependent

When the problem says two events are independent, use that to fill in the table: each interior cell is the product of its marginals.

Practice★☆☆Not started
In a language academy, students are divided by level (Basic or Advanced) and by language (English or German). The probability of a student being in the advanced level is…

In a language academy, students are divided by level (Basic or Advanced) and by language (English or German). The probability of a student being in the advanced level is $0.4$. The probability of studying English is $0.7$. It is known that the probability of a student studying German and being at the basic level is $0.2$.

  1. a) Draw up a contingency table with probabilities (where the total is $1$).
  2. b) Calculate the probability that a randomly chosen student is at the advanced level and studies English.
  3. c) If a student studies English, what is the probability that they are at the basic level?
Solve
Practice★★☆Not started
A technology company analyses the relationship between the use of a new model of wireless headphones and customer satisfaction. Of the $500$ users surveyed, $350$ bought…

A technology company analyses the relationship between the use of a new model of wireless headphones and customer satisfaction. Of the $500$ users surveyed, $350$ bought the "Pro" model and the rest the "Basic" model. It is known that event $S$ (being satisfied) and event $M$ (Pro model) are independent. If the probability of being satisfied is $P(S) = 0.8$:

  1. a) Complete the contingency table with the expected number of people for each category.
  2. b) Calculate the probability that a user bought the "Basic" model and is not satisfied.
  3. c) What does it mean in this context for the events to be independent?
Solve
Practice★★★Not started
In a survey conducted at a music festival about musical genre preference and age, the following data were obtained from a sample of $200$ attendees: | | Pop ($P$) | Rock…

In a survey conducted at a music festival about musical genre preference and age, the following data were obtained from a sample of $200$ attendees:

Pop ($P$) Rock ($R$) Indie ($I$)
Under 25 years old ($M$) $40$ $30$
25 years old or older ($A$) $50$

Knowing that the total number of Pop lovers is $65$ and that attendees under 25 represent $45\%$ of the total sample:

  1. a) Complete the contingency table with the absolute values.
  1. b) Calculate the probability that a randomly chosen attendee is older than 25 and likes Indie.
  1. c) If an attendee likes Rock, what is the probability that they are under 25 years old?
Solve

Chi-square test of independence

In the previous section, the proportions came out exactly equal. In a real sample that almost never happens, even if the variables are independent: there is always some chance variation. The χ² test decides whether the difference is large enough to stop blaming it on chance.

$\nu$ 1 2 3 4
Critical value ($\alpha=0.05$) 3.841 5.991 7.815 9.488
Table with observed frequencies and, in parentheses, expected ones for gender and preferred social app. Instagram TikTok Total Girls Boys 50 (40) 50 (60) 100 30 (40) 70 (60) 100

Summary

Back to the beginning: to find out whether the preferred app depends on gender in your class, you fill in the table, compare the proportions by row, and, if the differences look large, apply the χ² test.

See all the exercises in this section