Bayes' Theorem
A lab test comes back positive: what is the probability that the person really has the condition? You can't answer that by looking at the tree forward, as in total probability, but by inverting it: you already know the effect happened and you are asking about the cause. That inversion is Bayes' theorem, and it works just as well for finding out which factory a defective part came from, which channel a customer arrived through, or whether an email filter made a mistake.
Bayes' theorem
In a tree, each complete path is calculated by multiplying its branches. When you already know the effect happened, you only care about the paths that end in it. The question is: of all those paths, what share goes through the cause you are interested in?
The denominator is the total probability of the effect: the branches of all the causes, not just the one for the cause you are asking about. The idea is the same as in conditional probability: one part out of the total of the cases that satisfy what you already know.
To get to the center, a student can go by bus ($80\,\%$ of the time) or by bicycle ($20\,\%$). When traveling by bus, they arrive late $10\,\%$ of the time due to…
To get to the center, a student can go by bus ($80\,\%$ of the time) or by bicycle ($20\,\%$). When traveling by bus, they arrive late $10\,\%$ of the time due to traffic. When traveling by bicycle, they only arrive late $5\,\%$ of the time. If on a given day the student arrives late for class, calculate the probability that they traveled by bus.
A sneaker brand manufactures its models in two different factories: $70\,\%$ in factory $A$ and $30\,\%$ in factory $B$. Quality control has detected that $2\,\%$ of the…
A sneaker brand manufactures its models in two different factories: $70\,\%$ in factory $A$ and $30\,\%$ in factory $B$. Quality control has detected that $2\,\%$ of the sneakers from factory $A$ have a stitching defect, whereas in factory $B$ defects appear in $5\,\%$ of production. A customer buys a pair of sneakers and discovers that they have a stitching defect. Calculate the probability that they were manufactured in factory $B$.
In a software development company, $70\,\%$ of the programmers use the Python language and $30\,\%$ use Java. It is estimated that $10\,\%$ of the code written in Python…
In a software development company, $70\,\%$ of the programmers use the Python language and $30\,\%$ use Java. It is estimated that $10\,\%$ of the code written in Python contains critical syntax errors, while in Java this percentage is $15\,\%$. If a critical syntax error is detected in a piece of code, what is the probability that it was written in Python?
Strategy: the four steps
An email filter automatically classifies messages as spam. The filter correctly marks $98\,\%$ of emails that are truly spam as spam. However, it also sends $4\,\%$ of…
An email filter automatically classifies messages as spam. The filter correctly marks $98\,\%$ of emails that are truly spam as spam. However, it also sends $4\,\%$ of legitimate emails to the spam folder. It is estimated that $10\,\%$ of incoming email to an inbox is spam. If a randomly chosen email has been marked as spam, calculate the probability that it is actually spam.
At a health center, a study is being conducted on the efficacy of a diagnostic test for a food allergy that affects $8\,\%$ of the youth population. Clinical data…
At a health center, a study is being conducted on the efficacy of a diagnostic test for a food allergy that affects $8\,\%$ of the youth population. Clinical data indicate that if a person suffers from the allergy, the test gives a positive result in $95\,\%$ of cases. On the other hand, if the person does not suffer from the allergy, the test gives a "false positive" (positive result without being ill) in $4\,\%$ of instances. If a young person is chosen at random and their test result is positive, calculate the probability that they actually suffer from that allergy.
In a city, $70\,\%$ of citizens use a mobile app to pay for public transportation, whereas the rest use a physical card. It is observed that $15\,\%$ of those using the…
In a city, $70\,\%$ of citizens use a mobile app to pay for public transportation, whereas the rest use a physical card. It is observed that $15\,\%$ of those using the app have reading issues at the ticket validator, compared to $5\,\%$ of those using a physical card. If a validator emits a reading error signal, what is the probability that the user is trying to pay with the mobile app?
Three or more causes: which one is most likely?
A manufacturer of electronic components for smartphones has three production lines: A, B, and C. Line A produces $45\,\%$ of the components, line B produces $30\,\%$,…
A manufacturer of electronic components for smartphones has three production lines: A, B, and C. Line A produces $45\,\%$ of the components, line B produces $30\,\%$, and line C produces $25\,\%$. It is known that the probability of a component being defective is $1\,\%$ on line A, $2\,\%$ on line B, and $3\,\%$ on line C. If a component is selected at random and turns out to be defective, determine with justification which production line is most likely to have manufactured it.
A last-mile logistics company delivers packages in a city using three types of vehicles: electric vans ($60\,\%$), motorbikes ($30\,\%$), and cargo bicycles ($10\,\%$).…
A last-mile logistics company delivers packages in a city using three types of vehicles: electric vans ($60\,\%$), motorbikes ($30\,\%$), and cargo bicycles ($10\,\%$). The probability that a package arrives late is $2\,\%$ if delivered by van, $5\,\%$ if by motorbike, and $8\,\%$ if by bicycle. If a customer calls to complain because their package has arrived late, what is the probability that the courier was on a cargo bicycle?
Three streaming channels ($N$, $H$, and $D$) share the subscriber market in a city in proportions of $40\%$, $30\%$, and $30\%$, respectively. The probability that a…
Three streaming channels ($N$, $H$, and $D$) share the subscriber market in a city in proportions of $40\%$, $30\%$, and $30\%$, respectively. The probability that a subscriber of $N$ cancels their subscription this month is $0.05$; for $H$ it is $0.08$, and for $D$ it is $0.12$. If we choose at random a citizen who has just cancelled their subscription to one of these channels, what is the probability that they were a customer of $D$?
Diagnostic tests: the case that causes the most confusion
A very clear way to see it is a table with an imaginary population of $10{,}000$ young people. Take an allergy that affects $8\,\%$, with a test that comes back positive in $95\,\%$ of people with the allergy and gives a false positive in $4\,\%$ of those without it:
| Positive | Negative | Total | |
|---|---|---|---|
| With allergy | 760 | 40 | 800 |
| Without allergy | 368 | 8,832 | 9,200 |
| Total | 1,128 | 8,872 | 10,000 |
Of the $1{,}128$ positives, $760$ have the allergy and $368$ do not. The probability of having the allergy given a positive is $760/1128 \approx 0.674$.
A social network uses an artificial intelligence algorithm to detect hate speech comments. It is known that $5\,\%$ of published comments are actually inappropriate. The…
A social network uses an artificial intelligence algorithm to detect hate speech comments. It is known that $5\,\%$ of published comments are actually inappropriate. The algorithm correctly identifies $98\,\%$ of comments that are truly inappropriate as "inappropriate". However, it wrongly labels $3\,\%$ of respectful comments as "inappropriate". If the system has just blocked a comment for marking it as "inappropriate", what is the probability that the comment was actually respectful?
A tech multinational uses three different suppliers for the microchips in its new gaming laptops. Supplier $A$ supplies $45\%$ of the chips, supplier $B$ supplies…
A tech multinational uses three different suppliers for the microchips in its new gaming laptops. Supplier $A$ supplies $45\%$ of the chips, supplier $B$ supplies $35\%$, and the remainder come from supplier $C$. It is known from previous quality checks that $1\%$ of the chips from $A$ are defective, whereas for $B$ and $C$ these percentages are $2\%$ and $3\%$, respectively. A user buys a laptop and, after a month of use, suffers a critical failure due to the microchip. Calculate the probability that the defective chip was supplied by supplier $B$.
A precision parts factory uses a computer vision machine to inspect production quality. It is known that only $0.5\%$ of the manufactured parts have a defect. The…
A precision parts factory uses a computer vision machine to inspect production quality. It is known that only $0.5\%$ of the manufactured parts have a defect. The machine correctly detects $96\%$ of defective parts, but also erroneously marks $2\%$ of non-defective parts as defective. If the machine has just marked a part as defective, calculate the probability that the part is actually in perfect condition.