8.5: Bayes' Theorem
- Page ID
- 147316
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
\( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)
( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)
\( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)
\( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)
\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)
\( \newcommand{\Span}{\mathrm{span}}\)
\( \newcommand{\id}{\mathrm{id}}\)
\( \newcommand{\Span}{\mathrm{span}}\)
\( \newcommand{\kernel}{\mathrm{null}\,}\)
\( \newcommand{\range}{\mathrm{range}\,}\)
\( \newcommand{\RealPart}{\mathrm{Re}}\)
\( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)
\( \newcommand{\Argument}{\mathrm{Arg}}\)
\( \newcommand{\norm}[1]{\| #1 \|}\)
\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)
\( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)
\( \newcommand{\vectorA}[1]{\vec{#1}} % arrow\)
\( \newcommand{\vectorAt}[1]{\vec{\text{#1}}} % arrow\)
\( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vectorC}[1]{\textbf{#1}} \)
\( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)
\( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)
\( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
\(\newcommand{\avec}{\mathbf a}\) \(\newcommand{\bvec}{\mathbf b}\) \(\newcommand{\cvec}{\mathbf c}\) \(\newcommand{\dvec}{\mathbf d}\) \(\newcommand{\dtil}{\widetilde{\mathbf d}}\) \(\newcommand{\evec}{\mathbf e}\) \(\newcommand{\fvec}{\mathbf f}\) \(\newcommand{\nvec}{\mathbf n}\) \(\newcommand{\pvec}{\mathbf p}\) \(\newcommand{\qvec}{\mathbf q}\) \(\newcommand{\svec}{\mathbf s}\) \(\newcommand{\tvec}{\mathbf t}\) \(\newcommand{\uvec}{\mathbf u}\) \(\newcommand{\vvec}{\mathbf v}\) \(\newcommand{\wvec}{\mathbf w}\) \(\newcommand{\xvec}{\mathbf x}\) \(\newcommand{\yvec}{\mathbf y}\) \(\newcommand{\zvec}{\mathbf z}\) \(\newcommand{\rvec}{\mathbf r}\) \(\newcommand{\mvec}{\mathbf m}\) \(\newcommand{\zerovec}{\mathbf 0}\) \(\newcommand{\onevec}{\mathbf 1}\) \(\newcommand{\real}{\mathbb R}\) \(\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}\) \(\newcommand{\laspan}[1]{\text{Span}\{#1\}}\) \(\newcommand{\bcal}{\cal B}\) \(\newcommand{\ccal}{\cal C}\) \(\newcommand{\scal}{\cal S}\) \(\newcommand{\wcal}{\cal W}\) \(\newcommand{\ecal}{\cal E}\) \(\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}\) \(\newcommand{\gray}[1]{\color{gray}{#1}}\) \(\newcommand{\lgray}[1]{\color{lightgray}{#1}}\) \(\newcommand{\rank}{\operatorname{rank}}\) \(\newcommand{\row}{\text{Row}}\) \(\newcommand{\col}{\text{Col}}\) \(\renewcommand{\row}{\text{Row}}\) \(\newcommand{\nul}{\text{Nul}}\) \(\newcommand{\var}{\text{Var}}\) \(\newcommand{\corr}{\text{corr}}\) \(\newcommand{\len}[1]{\left|#1\right|}\) \(\newcommand{\bbar}{\overline{\bvec}}\) \(\newcommand{\bhat}{\widehat{\bvec}}\) \(\newcommand{\bperp}{\bvec^\perp}\) \(\newcommand{\xhat}{\widehat{\xvec}}\) \(\newcommand{\vhat}{\widehat{\vvec}}\) \(\newcommand{\uhat}{\widehat{\uvec}}\) \(\newcommand{\what}{\widehat{\wvec}}\) \(\newcommand{\Sighat}{\widehat{\Sigma}}\) \(\newcommand{\lt}{<}\) \(\newcommand{\gt}{>}\) \(\newcommand{\amp}{&}\) \(\definecolor{fillinmathshade}{gray}{0.9}\)Learning Objectives
In this section, you will learn to:
- Find probabilities using Bayes’ theorem.
- Use a probability tree to find and represent values needed when using Bayes’ theorem.
Prerequisite Skills
Before you get started, take this prerequisite quiz.
1. If \(P(F) = .4\), \(P(E | F) = .3\), find \(P\)(\(E \cap F\)).
- Click here to check your answer
-
\(.12\)
If you missed this problem, review Section 8.4. (Note that this will open in a new window.)
2. \(P(E) = .3\), \(P(F) = .3\); \(E \cap F\) are mutually exclusive. Find \(P(E | F)\).
- Click here to check your answer
-
\(0\)
If you missed this problem, review Section 8.4. (Note that this will open in a new window.)
3. If \(P(E) = .6\), \(P\)(\(E \cap F\)) = .24, find \(P(F | E)\).
- Click here to check your answer
-
\(.4\)
If you missed this problem, review Section 8.4. (Note that this will open in a new window.)
4. If \(P(E \cap F\)) = \(.04\) , \(P(E | F) = .1\), find \(P(F)\).
- Click here to check your answer
-
\(.4\)
If you missed this problem, review Section 8.4. (Note that this will open in a new window.)
In this section, we will develop and use Bayes' theorem to solve an important type of probability problem. Bayes' theorem is a method of calculating the conditional probability \(P(F | E)\) from \(P(E | F)\). The ideas involved here are not new, and most of these problems can be solved using a tree diagram. However, Bayes' theorem does provide us with a tool with which we can solve these problems without a tree diagram.
We begin with an example.
Example \(\PageIndex{1}\)
Suppose a certain disease afflicts 1% of the population. A test has been devised to detect this disease. The test does not produce false negatives (that is, anyone who has the disease will test positive for it), but the false positive rate is 5% (that is, even among those without the disease, 5% who take the test will test positive).
Suppose a randomly selected person takes the test and tests positive. What is the probability that this person actually has the disease?
Solution
Let's begin by interpreting the information we have.
Let
- Disease = the event that the person has the disease
- Healthy= the event that the person is healthy (does not have the disease)
- Pos = the event that the test is positive
- Neg = the event that the test is negative
Then
- P(Disease) = 0.01
- P(Healthy) = 0.99
- P(Pos | Healthy) = 0.05 (5% of healthy people will test positive.)
- P(Neg | Healthy) = 0.95 (The other 95% of healthy people will test negative.)
- P(Pos | Disease) = 1 (All who have the disease will test positive.)
- P(Neg | Disease) = 0 (None who have the disease will test negative.)
To find the probability that a person who tests positive actually has the disease, we are trying to find P(Disease | Pos). Note that this is the opposite order of the information we are given.
We can construct a tree diagram and use our knowledge about conditional probability to find this.
To find P(Disease | Pos), we will need to know P(Pos). The probability of a positive test is the probability of a healthy person testing positive plus the probability of a diseased person testing positive.
From the tree diagram, we can see:
- P(Disease \(\cap\) Pos) = (0.01)(1) = 0.01
- P(Healthy \(\cap\) Pos) = (0.99)(0.05) = 0.0495
Therefore, P(Pos) = 0.01 + 0.0495 = 0.0595. For the purpose of understanding Bayes' theorem, it might be helpful to rewrite this in its unsimplified form, of P(Pos) = (0.01)(1) + (0.99)(0.05).
Using the formula for conditional probability,
\[\begin{array}{l}
P( \text{Disease} | \text{Pos})&=\frac{P( \text{Disease} \cap \text{Pos})}{P(\text{Pos})} \\
&= \frac{(0.01)(1)}{(0.01)(1) + (0.99)(0.05)} \\
&= 0.168
\end{array} \nonumber\]
This means that only 16.8% of those who test positive actually have the disease!
In the above example, we found that the \(P( \text{Disease} | \text{Pos})=\frac{P( \text{Disease} \cdot P( \text{Pos|Disease})}{P(\text{Pos})}\). Note that the denominator included the sum of all the branches that ended in a positive test.
This leads us to Bayes' theorem.
Bayes' Theorem
For any events E and F,
\[P(E|F)=\frac{P(E)P(F|E)}{P(F)} \nonumber\]
We begin with the following example.
Example \(\PageIndex{2}\)
A department store buys 50% of its appliances from Manufacturer A, 30% from Manufacturer B, and 20% from Manufacturer C. It is estimated that 6% of Manufacturer A's appliances, 5% of Manufacturer B's appliances, and 4% of Manufacturer C's appliances need repair before the warranty expires. An appliance is chosen at random. If the appliance chosen needed repair before the warranty expired, what is the probability that the appliance was manufactured by Manufacturer A? Manufacturer B? Manufacturer C?
Solution
Let A, B and C be the events that the appliance is manufactured by Manufacturer A, Manufacturer B, and Manufacturer C, respectively. Further, suppose that the event R denotes that the appliance needs repair before the warranty expires.
We need to find P(A | R), P(B | R) and P(C | R).
We will do this problem both by using a tree diagram and also by using Bayes' theorem.
We draw a tree diagram.
The probability P(A | R), for example, is a fraction whose denominator is the sum of all probabilities of all branches of the tree that result in an appliance that needs repair before the warranty expires, and the numerator is the branch that is associated with Manufacturer A. P(B | R) and P(C | R) are found in the same way.
\[\begin{array}{l}
P(A | R)=\frac{.030}{(.030)+(.015)+(.008)}=\frac{.030}{.053}=.566 \\
P(B | R)=\frac{.015}{.053}=.283 \text { and } P(C | R)=\frac{.008}{.053}=.151
\end{array} \nonumber\]
Alternatively, using Bayes' theorem,
\begin{aligned}
\mathrm{P}(\mathrm{A} | \mathrm{R}) &=\frac{\mathrm{P}(\mathrm{R} | \mathrm{A})\mathrm{P}(\mathrm{A}) }{\mathrm{P}(\mathrm{R} | \mathrm{A})\mathrm{P}(\mathrm{A}) + \mathrm{P}(\mathrm{R} | \mathrm{B})\mathrm{P}(\mathrm{B}) + \mathrm{P}(\mathrm{R} | \mathrm{C})\mathrm{P}(\mathrm{C}) } \\
&=\frac{.030}{(.030)+(.015)+(.008)}=\frac{.030}{.053}=.566
\end{aligned}
P(B | R) and P(C | R) can be determined in the same manner.
P(B | R) = \(\frac{.015}{.053}=.283\) and P(C | R) = \(\frac{.008}{.053}=.151\).
Example \(\PageIndex{3}\)
There are five American Furniture Warehouse stores in the Denver area. The percent of employees over the age of 50 is given in the table below.
Store Number |
Number of Employees |
Percent of 50+ Employees |
1 |
300 |
.40 |
2 |
150 |
.65 |
3 |
200 |
.60 |
4 |
250 |
.50 |
5 |
100 |
.70 |
Total = 1000 |
If an employee chosen at random is over 50 years old, what is the probability that the employee works at store III?
Solution
Let \(k\) = 1, 2, . . . , 5 be the event that the employee worked at store \(k\), and A be the event that the employee is over 50 years old. Since there are a total of 1000 employees at the five stores,
\[P(1)=.30 \quad P(2)=.15 \quad P(3)=.20 \quad P(4)=.25 \quad P(5)=.10 \nonumber\]
Using Bayes' theorem,
\[\begin{array}{l}
\mathrm{P}(3 | \mathrm{A})&=\frac{\mathrm{P}(\mathrm{A} | 3)\mathrm{P}(3) }{\mathrm{P}(\mathrm{A} | 1)\mathrm{P}(1) + \mathrm{P}(\mathrm{A} | 2)\mathrm{P}(2) + \mathrm{P}(\mathrm{A} | 3)\mathrm{P}(3) + \mathrm{P}(\mathrm{A} | 4)\mathrm{P}(4) + \mathrm{P}(\mathrm{A} | 5)\mathrm{P}(5) } \\
&=\frac{(.60)(.20)}{(.40)(.30)+(.65)(.15)+(.60)(.20)+(.50)(.25)+(.70)(.10)} \\
&=.2254
\end{array} \nonumber\]