Total Probability and Bayes' Theorem
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
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.
Total probability theorem
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.
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.
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.
- a) Calculate the probability that a player chosen at random suffers from eye strain.
- 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?
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.
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?
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.
- a) If a user is chosen at random, what is the probability that they listen to music for 2 hours or less per day?
- 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?
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.
- a) Represent the situation with a tree diagram, detailing the probabilities of each branch.
- b) Calculate the probability that the alert issued is actually a false alarm.
- c) If it is confirmed that the alert was a false alarm, what is the probability that it was generated by system $S_3$?
Bayes step by step: strategy
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.
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).
- a) Calculate the probability that a citizen chosen at random arrives on time for work.
- b) Given that a worker arrived late, what is the probability that they travelled in their private car?
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 \%$.
- a) Calculate the percentage of defective parts produced by machine $M_3$.
- b) If we take a part and find that it is defective, which machine is most likely to have manufactured it?
Extension: diagnostic tests
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.
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?
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.
- a) What percentage of the total population will test positive?
- 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.
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).
- a) If an athlete tests positive in the control, what is the probability that they have actually consumed the substance?
- 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.
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$:
- a) Determine the value of the probability $p$ associated with type $T_3$ bacteria.
- b) Using the value of $p$ obtained, calculate the probability that, when choosing a sample at random, it does not develop resistance.