Skip to main content
Mathematics LibreTexts

3.5: Bayes' Formula

  • Page ID
    179915
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \( \newcommand{\dsum}{\displaystyle\sum\limits} \)

    \( \newcommand{\dint}{\displaystyle\int\limits} \)

    \( \newcommand{\dlim}{\displaystyle\lim\limits} \)

    \( \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{\longvect}{\overrightarrow}\)

    \( \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:

    1. Find probabilities using Bayes’ formula
    2. Use a probability tree to find and represent values needed when using Bayes’ formula.

    In this section, we will develop and use Bayes' Formula to solve an important type of probability problem. Bayes' formula 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' formula 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 you are given two jars. Jar I contains one black and 4 white marbles, and Jar II contains 4 black and 6 white marbles. If a jar is selected at random and a marble is chosen,

    1. What is the probability that the marble chosen is a black marble?
    2. If the chosen marble is black, what is the probability that it came from Jar I?
    3. If the chosen marble is black, what is the probability that it came from Jar II?
    Solution

    Let \(J I\) be the event that Jar I is chosen, \(J II\) be the event that Jar II is chosen, \(B\) be the event that a black marble is chosen and \(W\) the event that a white marble is chosen.

    We illustrate using a tree diagram.

    Example9.2.1.png

    1. The probability that a black marble is chosen is \(P(B)\) = 1/10 + 2/10 = 3/10.
    2. To find \(P(J I | B)\), we use the definition of conditional probability, and we get \[P(J I | B)=\frac{P(J I \cap B)}{P(B)}=\frac{1 / 10}{3 / 10}=\frac{1}{3} \nonumber \]
    3. Similarly, \(\mathrm{P}(\mathrm{J} \mathrm{II} | \mathrm{B})=\frac{\mathrm{P}(\mathrm{J} \mathrm{II} \cap \mathrm{B})}{\mathrm{P}(\mathrm{B})}=\frac{2 / 10}{3 / 10}=\frac{2}{3}\)

    In parts b and c, the reader should note that the denominator is the sum of all probabilities of all branches of the tree that produce a black marble, while the numerator is the branch that is associated with the particular jar in question.

    We will soon discover that this is a statement of Bayes' formula .

    Let us first visualize the problem.

    We are given a sample space \(\mathrm{S}\) and two mutually exclusive events \(J I\) and \(J II\). That is, the two events, \(J I\) and \(J II\), divide the sample space into two parts such that \(\mathrm{JI} \cup \mathrm{JII}=\mathrm{S}\). Furthermore, we are given an event \(B\) that has elements in both \(J I\) and \(J II\), as shown in the Venn diagram below.


    Example9.2.1b.png

    From the Venn diagram, we can see that \(\mathrm{B}=(\mathrm{B} \cap \mathrm{J} \mathrm{I}) \cup(\mathrm{B} \cap \mathrm{J} \mathrm{II})\) Therefore:

    \[ P(B)=P(B \cap J I)+P(B \cap J I I) \label{I} \]

    But the product rule in chapter 7 gives us

    \[ P(B \cap J I)=P(J I) \cdot P(B | J I) \quad \text { and } \quad P(B \cap J I I)=P(J I I) \cdot P(B | J I I) \nonumber \]

    Substituting in \ref{I}, we get

    \[P(B)=P(J I) \cdot P(B | J I)+P(J I I) \cdot P(B | J I I) \nonumber \]

    The conditional probability formula gives us

    \[P(J I | B)=\frac{P(J I \cap B)}{P(B)} \nonumber \]

    Therefore, \(P(J I | B)=\frac{P(J I) \cdot P(B | J I)}{P(B)}\)

    or

    \[P(J I | B)=\frac{P(J I) \cdot P(B | J I)}{P(J I) \cdot P(B | J I)+P(J I I) \cdot P(B | J I I)} \nonumber \]

    The last statement is Bayes' Formula for the case where the sample space is divided into two partitions.

    The following is the generalization of Bayes’ formula for n partitions.

    Bayes' Formula for \(n\) partitions

    Let \(\mathrm{S}\) be a sample space that is divided into \(n\) partitions, \(A_1\), \(A_2\), . . . \(A_n\). If \(E\) is any event in \(\mathrm{S}\), then

    \[\mathbf{P}\left(\mathbf{A}_{\mathbf{i}} | \mathbf{E}\right)=\frac{\mathbf{P}\left(\mathbf{A}_{\mathbf{i}}\right) \mathbf{P}\left(\mathbf{E} | \mathbf{A}_{\mathbf{i}}\right)}{\mathbf{P}\left(\mathbf{A}_{\mathbf{1}}\right) \mathbf{P}\left(\mathbf{E} | \mathbf{A}_{\mathbf{1}}\right)+\mathbf{P}\left(\mathbf{A}_{2}\right) \mathbf{P}\left(\mathbf{E} | \mathbf{A}_{2}\right)+\cdots+\mathbf{P}\left(\mathbf{A}_{\mathbf{n}}\right) \mathbf{P}\left(\mathbf{E} | \mathbf{A}_{\mathbf{n}}\right)} \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 by using Bayes' formula.

    We draw a tree diagram.

    Example9.2.2.png

    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' formula,

    \begin{aligned}
    \mathrm{P}(\mathrm{A} | \mathrm{R}) &=\frac{\mathrm{P}(\mathrm{A}) \mathrm{P}(\mathrm{R} | \mathrm{A})}{\mathrm{P}(\mathrm{A}) \mathrm{P}(\mathrm{R} | \mathrm{A})+\mathrm{P}(\mathrm{B}) \mathrm{P}(\mathrm{R} | \mathrm{B})+\mathrm{P}(\mathrm{C}) \mathrm{P}(\mathrm{R} | \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.

    Example \(\PageIndex{3}\)

    There are five Jacy's department stores in San Jose. The distribution of number of employees by gender is given in the table below.

    Store Number Number of Employees Percent of Women 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 a woman, 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 W be the event that the employee is a woman. 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' formula,

    \[\begin{array}{l}
    \mathrm{P}(3 | \mathrm{W})&=\frac{\mathrm{P}(3) \mathrm{P}(\mathrm{W} | 3)}{\mathrm{P}(1) \mathrm{P}(\mathrm{W} | 1)+\mathrm{P}(2) \mathrm{P}(\mathrm{W} | 2)+\mathrm{P}(3) \mathrm{P}(\mathrm{W} | 3)+\mathrm{P}(4) \mathrm{P}(\mathrm{W} | 4)+\mathrm{P}(5) \mathrm{P}(\mathrm{W} | 5)} \\
    &=\frac{(.20)(.60)}{(.30)(.40)+(.15)(.65)+(.20)(.60)+(.25)(.50)+(.10)(.70)} \\
    &=.2254
    \end{array} \nonumber \]

    Exercises

    SECTION 9.2 PROBLEM SET: BAYES' FORMULA

    1. Jar I contains five red and three white marbles, and Jar II contains four red and two white marbles. A jar is picked at random and a marble is drawn. Draw a tree diagram below, and find the following probabilities.
      1. P(marble is red)
      2. P(It came from Jar II | marble is white)
      3. P(Red | Jar I)
    1. In Mr. Symons' class, if a student does homework most days, the chance of passing the course is 90%. On the other hand, if a student does not do homework most days, the chance of passing the course is only 20%.
      H = event that the student did homework
      C = event that the student passed the course
      Mr. Symons claims that 80% of his students do homework on a regular basis. If a student is chosen at random from Mr. Symons' class, find the following probabilities.
      1. P(C)
      2. P(H|C)
      3. P(C|H)
    1. A city has 60% Democrats, and 40% Republicans. In the last mayoral election, 60% of the Democrats voted for their Democratic candidate while 95% of the Republicans voted for their candidate. Which party's mayor runs city hall?
    1. In a certain population of 48% men and 52% women, 56% of the men and 8% of the women are color-blind.
      1. What percent of the people are color-blind?
      2. If a person is found to be color-blind, what is the probability that the person is a male?
    1. A test for a certain disease gives a positive result 95% of the time if the person actually carries the disease. However, the test also gives a positive result 3% of the time when the individual is not carrying the disease. It is known that 10% of the population carries the disease. If a person tests positive, what is the probability that he or she has the disease?
    1. A person has two coins: a fair coin and a two-headed coin. A coin is selected at random, and tossed. If the coin shows a head, what is the probability that the coin is fair?
    1. A computer company buys its chips from three different manufacturers. Manufacturer I provides 60% of the chips and is known to produce 5% defective; Manufacturer II supplies 30% of the chips and makes 4% defective; while the rest are supplied by Manufacturer III with 3% defective chips. If a chip is chosen at random, find the following probabilities:
      1. P(the chip is defective)
      2. P(chip is from Manufacturer II | defective)
      3. P(defective |chip is from manufacturer III)
    1. Lincoln Union High School District is made up of three high schools: Monterey, Fremont, and Kennedy, with an enrollment of 500, 300, and 200, respectively. On a given day, the percentage of students absent at Monterey High School is 6%, at Fremont 4%, and at Kennedy 5%. If a student is chosen at random, find the probabilities below: Hint: Convert the enrollments into percentages.
      1. P(the student is absent)
      2. P(student is from Kennedy | student is absent)
      3. P(student is absent | student is from Fremont)

    9. At a retail store, 20% of customers use the store’s online app to assist them when shopping in the store ; 80% of store shoppers don’t use the app.

    Of those customers that use the online app while in the store, 50% are very satisfied with their purchases, 40% are moderately satisfied, and 10% are dissatisfied.

    Of those customers that do not use the online app while in the store, 30% are very satisfied with their purchases, 50% are moderately satisfied and 20% are dissatisfied.

    Indicate the events by the following:

    A = shopper uses the app in the store
    N = shopper does not use the app in the store
    V = very satisfied with purchase
    M = moderately satisfied
    D = dissatisfied

    a. Find P(A and D), the probability that a store customer uses the app and is dissatisfied

    b. Find P(A|D), the probability that a store customer uses the app if the customer is dissatisfied.

    10. A medical clinic uses a pregnancy test to confirm pregnancy in patients who suspect they are pregnant. Historically data has shown that overall, 70% of the women at this clinic who are given the pregnancy test are pregnant, but 30% are not.

    The test's manufacturer indicates that if a woman is pregnant, the test will be positive 92% of the time.

    But if a woman is not pregnant, the test will be positive only 2% of the time and will be negative 98% of the time.

    a. Find the probability that a woman at this clinic is pregnant and tests positive.

    b. Find the probability that a woman at this clinic is actually pregnant given that she tests positive.

     


    This page titled 3.5: Bayes' Formula is shared under a CC BY 4.0 license and was authored, remixed, and/or curated by Rupinder Sekhon and Roberta Bloom via source content that was edited to the style and standards of the LibreTexts platform.