Back to homeMathematics · High School Year 3 · Physics-Math · Change subject
Start for free
Prep 3 Tech · Mathematics
Randomness and probability · Probability

Total Probability and Bayes' Theorem

Before you start, make sure you know: Trees (High School Year 1 (semesters 1 and 2))

A probability tree is traversed from cause to effect. But in real life the opposite often happens: the effect has already occurred and you want to know which cause produced it. "My test came back positive: how likely is it that I really have the disease?" This is not answered by looking at the tree forward, but by inverting it. That is what this page is about, and at the end we will come back to that question.

Complete system of events

Diagram representing the sample space divided into three mutually exclusive and exhaustive events B1, B2, and B3. sample space E B₁ B₂ B₃ they neither overlap nor leave gaps: they cover all of E
Practice★☆☆Not started
In an esports tournament, a player reaches the final. They can choose between two strategies: Offensive (chosen $70\%$ of the time) or Defensive ($30\%$). If they play…

In an esports tournament, a player reaches the final. They can choose between two strategies: Offensive (chosen $70\%$ of the time) or Defensive ($30\%$). If they play offensively, they win the game with a probability of $0.6$, whereas if they play defensively, their probability of victory is $0.4$.

Given that the player won the game, calculate the probability that they used a defensive strategy.

0.7 0.3 0.6 0.4 0.4 0.6 Offensive Defensive Wins Loses Wins Loses P(O∩G) = 0.42 P(D∩G) = 0.12
Solve

Total probability theorem

Tree with three causes B1, B2, and B3 and the branches that reach event A; the probability of A is the sum of the three branches. P(B₁)P(B₂)P(B₃) P(A|B₁)P(A|B₂)P(A|B₃) P(A) = sum of the three branches that reach A
Practice★☆☆Not started
In a school, Year 13 students can choose between two platforms to carry out their work in the cloud: $65\%$ use Google Workspace and the rest use Microsoft 365. It is…

In a school, Year 13 students can choose between two platforms to carry out their work in the cloud: $65\%$ use Google Workspace and the rest use Microsoft 365. It is known that $20\%$ of Google users use Artificial Intelligence tools to write drafts, whereas in Microsoft $15\%$ do so.

Calculate the probability that a student chosen at random uses Artificial Intelligence for their drafts.

0.65 0.35 0.20 0.80 0.15 0.85 Google Microsoft AI Not AI AI Not AI
Solve
Practice★☆☆Not started
A courier service uses three routes to deliver parcels in a city: North Route ($50\%$), South Route ($30\%$) and Central Route ($20\%$). Delivery delays occur $2\%$ of…

A courier service uses three routes to deliver parcels in a city: North Route ($50\%$), South Route ($30\%$) and Central Route ($20\%$). Delivery delays occur $2\%$ of the time on the North route, $4\%$ on the South route and $10\%$ on the Central route.

Determine the total percentage of packages delivered late in this city.

Solve
Practice★★☆Not started
In an esports high-performance center, players train on three different platforms: PC, console and mobile devices. $50\ \%$ of players use PC, $30\ \%$ use console and…

In an esports high-performance center, players train on three different platforms: PC, console and mobile devices. $50\ \%$ of players use PC, $30\ \%$ use console and the rest mobile devices. It has been observed that performance decreases due to eye strain in $8\ \%$ of PC players, $5\ \%$ of console players and $12\ \%$ of mobile users.

  1. a) Calculate the probability that a player chosen at random suffers from eye strain.
  1. b) If we select a player and see that they suffer from eye strain, what is the probability that they usually train with a mobile device?
0.50 0.30 0.20 0.08 0.05 0.12 0.92 0.95 0.88 PC Console Mobile Eye strain Eye strain Eye strain No eye strain No eye strain No eye strain
Solve

Bayes' theorem: inverting the tree

Before the formula, let's simulate and see what happens. With the high school data (Google 65%, Microsoft 35%; they use AI 20% and 15%), we want to know: if a student uses AI, how likely is it that they are on Google?

What the simulation did was divide the number of students "on Google and using AI" by all those who use AI. That is exactly Bayes' theorem, written with probabilities.

Tree from causes to effects with a dotted arrow in the opposite direction representing Bayes' question. P(B₁)P(B₂) P(A|B₁)P(A|B₂) Bayes: from A, which branch was the most likely?
Practice★☆☆Not started
A supermarket chain sells yoghurts from two different suppliers. $40\%$ comes from Supplier A and $60\%$ from Supplier B. Quality control indicates that $5\%$ of…

A supermarket chain sells yoghurts from two different suppliers. $40\%$ comes from Supplier A and $60\%$ from Supplier B. Quality control indicates that $5\%$ of yoghurts from Supplier A have packaging defects, whereas for Supplier B this defect only appears in $2\%$ of cases.

If we buy a yoghurt and find that it has a packaging defect, what is the probability that it came from Supplier A?

Solve
Practice★★☆Not started
A music streaming service classifies its users into three categories: "Free" (with ads), "Premium" and "Family". $60\ \%$ are Free users, $30\ \%$ Premium and $10\ \%$…

A music streaming service classifies its users into three categories: "Free" (with ads), "Premium" and "Family". $60\ \%$ are Free users, $30\ \%$ Premium and $10\ \%$ Family. It is known that $80\ \%$ of Free users listen for more than 2 hours daily, whereas this percentage is $90\ \%$ for Premium users and $95\ \%$ for Family users.

  1. a) If a user is chosen at random, what is the probability that they listen to music for 2 hours or less per day?
  1. b) If we select a user who listens to more than 2 hours of music daily, what is the probability that they belong to the "Premium" category?
Solve
Practice★★★Not started
A cybersecurity company uses three artificial intelligence systems ($S_1$, $S_2$ and $S_3$) to detect unauthorized access attempts on a corporate network. System $S_1$…

A cybersecurity company uses three artificial intelligence systems ($S_1$, $S_2$ and $S_3$) to detect unauthorized access attempts on a corporate network. System $S_1$ handles $45 \%$ of the alerts, $S_2$ handles $35 \%$ and $S_3$ handles the rest.

It is known from previous audits that, among the alerts issued by each system, the following are false alarms (a legitimate access is reported as an attack): $2 \%$ of those from $S_1$, $5 \%$ of those from $S_2$ and $8 \%$ of those from $S_3$. The remaining alerts from each system correspond to real attacks. Moreover, the probability that a system ignores a real attack (false negative) is $1 \%$ in all cases; this is information you will not need for this problem.

At a given moment, an alert goes off on the control panel indicating an attack.

  1. a) Represent the situation with a tree diagram, detailing the probabilities of each branch.
  1. b) Calculate the probability that the alert issued is actually a false alarm.
  1. c) If it is confirmed that the alert was a false alarm, what is the probability that it was generated by system $S_3$?
Solve

Bayes step by step: strategy

Four chained steps: causes, effect A, tree with P(A), and Bayes. 1. causes 2. effect A 3. tree → P(A) 4. Bayes
Practice★☆☆Not started
An electric car dealership sells three models: Compact ($40\,\%$), Sedan ($35\,\%$) and SUV ($25\,\%$). It has been observed that $3\,\%$ of Compacts, $2\,\%$ of Sedans…

An electric car dealership sells three models: Compact ($40\,\%$), Sedan ($35\,\%$) and SUV ($25\,\%$). It has been observed that $3\,\%$ of Compacts, $2\,\%$ of Sedans and $5\,\%$ of SUVs need a software update in the first month. The figure shows the tree diagram of the situation.

If a customer calls because their car has needed a software update in the first month, which model is most likely to have been purchased? Justify your answer by calculating the corresponding probabilities.

Tree diagram: three car models with their sales percentages and, for each one, the software update branch and the no update branch Compact Sedan SUV 40 % 35 % 25 % 3 % 2 % 5 % Update Update Update No update No update No update
Solve
Practice★★☆Not started
A study on sustainable mobility in a city indicates that $45\ \%$ of journeys are made by public transport, $35\ \%$ by bicycle or e-scooter, and $20\ \%$ by private…

A study on sustainable mobility in a city indicates that $45\ \%$ of journeys are made by public transport, $35\ \%$ by bicycle or e-scooter, and $20\ \%$ by private car. The probability of arriving late for work is estimated to be 0.15 if using public transport, 0.05 if using bicycle/e-scooter, and 0.30 if using private car (due to traffic jams).

  1. a) Calculate the probability that a citizen chosen at random arrives on time for work.
  1. b) Given that a worker arrived late, what is the probability that they travelled in their private car?
Solve
Practice★★★Not started
Three machines, $M_1$, $M_2$ and $M_3$, manufacture precision parts. $M_1$ produces twice as many parts as $M_2$, and $M_3$ produces the same number as $M_1$ and $M_2$…

Three machines, $M_1$, $M_2$ and $M_3$, manufacture precision parts. $M_1$ produces twice as many parts as $M_2$, and $M_3$ produces the same number as $M_1$ and $M_2$ combined. The percentage of defective parts is $2 \%$ for $M_1$ and $4 \%$ for $M_2$.

It is known that, when taking a part at random from the total production, the probability of it being defective is $2.5 \%$.

  1. a) Calculate the percentage of defective parts produced by machine $M_3$.
  2. b) If we take a part and find that it is defective, which machine is most likely to have manufactured it?
Solve

Extension: diagnostic tests

Comparison between the tiny bar of true positives and the much larger bar of false positives in a healthy population. population: 0.1% sick, 99.9% healthy test positives: almost all come from the huge healthy majority ← the few true positives are here

Go back to the beginning: given a positive result, the probability of being sick is not the sensitivity of the test, but $P(E\mid +)$, which also depends on how common the disease is.

Practice★☆☆Not started
A study is carried out on a new fitness app. It is estimated that $1\%$ of teenagers in a city use it. The app has a "daily challenge" feature that is successfully…

A study is carried out on a new fitness app. It is estimated that $1\%$ of teenagers in a city use it. The app has a "daily challenge" feature that is successfully completed $95\%$ of the time if the user is consistent, but if they are not ($99\%$ of the population does not use the app), the probability of completing a similar challenge by chance is only $0.05$.

If we select a young person at random and see that they have successfully completed the challenge, what is the probability that they are a consistent user of the app?

Solve
Practice★★☆Not started
A pharmaceutical laboratory develops a rapid test to detect a vitamin deficiency affecting $5\ \%$ of the young population. Clinical trials show that the test gives a…

A pharmaceutical laboratory develops a rapid test to detect a vitamin deficiency affecting $5\ \%$ of the young population. Clinical trials show that the test gives a positive result in $96\ \%$ of people who actually have the deficiency. However, it also gives a "false positive" in $2\ \%$ of healthy people.

  1. a) What percentage of the total population will test positive?
  1. b) If a young person takes the test and the result is positive, what is the actual probability that they suffer from this vitamin deficiency? Comment on whether you find the result high or low in relation to the reliability of the test.
Solve
Practice★★★Not started
In a high-performance sports center, athletes undergo doping control. $1 \%$ of the athletes consume a banned substance. The test used has a reliability of $98 \%$…

In a high-performance sports center, athletes undergo doping control. $1 \%$ of the athletes consume a banned substance. The test used has a reliability of $98 \%$ (probability of testing positive if the substance has been consumed). However, the test also produces $3 \%$ "false positives" (testing positive in athletes who have not consumed anything).

  1. a) If an athlete tests positive in the control, what is the probability that they have actually consumed the substance?
  2. b) The committee decides to perform a second independent test on the same athlete if the first one comes back positive. If this second test (with the same reliability) also turns out positive, what is the probability now that the athlete is guilty? Justify whether the confidence in the verdict has increased significantly.
POPULATION REAL STATE TEST PROBABILITY 0.01 0.99 0.98 0.02 0.03 0.97 C C' + - + - P(C ∩ +) = 0.0098 P(C ∩ -) = 0.0002 P(C' ∩ +) = 0.0297 P(C' ∩ -) = 0.9603 C Consumes (1%) C' Does not consume (99%) + Positive Test - Negative Test
Solve
Practice★★★Not started
In a biotechnology laboratory, three types of bacteria are handled: $T_1$, $T_2$ and $T_3$. There is a container with 100 samples: 20 of $T_1$, 30 of $T_2$ and 50 of…

In a biotechnology laboratory, three types of bacteria are handled: $T_1$, $T_2$ and $T_3$. There is a container with 100 samples: 20 of $T_1$, 30 of $T_2$ and 50 of $T_3$. The probability of a sample developing antibiotic resistance within 24 hours is $0.2$ for $T_1$, $0.4$ for $T_2$ and an unknown value $p$ for $T_3$.

A sample is drawn at random and observed to have developed resistance after 24 hours. Given that the probability of this sample being of type $T_2$ is $0.375$:

  1. a) Determine the value of the probability $p$ associated with type $T_3$ bacteria.
  2. b) Using the value of $p$ obtained, calculate the probability that, when choosing a sample at random, it does not develop resistance.
Solve

Summary

See all the exercises in this section