#set document(title: "4.6 Conditional Probability", author: "Rachel Webb") #set page(width: 8.5in, height: auto, margin: 1in) #import "@preview/cetz:0.5.2" #set text(font: ("STIX Two Text", "Libertinus Serif", "New Computer Modern"), size: 10.5pt, lang: "en") #show math.equation: set text(font: ("STIX Two Math", "New Computer Modern Math")) #set par(justify: true, leading: 0.62em, spacing: 0.9em) #set enum(spacing: 1.1em) // room between list items so tall inline fractions don't collide #set list(spacing: 1.1em) #set table(stroke: 0.5pt + rgb("#c7ccd3")) #let BLUE = rgb("#183B6F") // brand navy — section bars + example/solution labels (white on navy 11.09:1) #let ORANGE = rgb("#A94509") // brand primary-700 — AA-safe deep orange for TEXT (5.93:1 on white; raw brand #F37021 is 2.94:1 and must never carry text) #let RED = rgb("#DC2626") // brand error-600 #let GREEN = rgb("#059669") // brand success-600 (decoration only; small green text uses green-text #007942) #show heading.where(level: 1): it => block(width: 100%, above: 0pt, below: 16pt, fill: gradient.linear(BLUE, rgb("#2C5AA0")), inset: (x: 14pt, y: 12pt), radius: 3pt, text(fill: white, weight: "bold", size: 19pt, it.body)) #show heading.where(level: 2): it => block(width: 100%, above: 18pt, below: 10pt, fill: BLUE, inset: (x: 10pt, y: 6pt), radius: 2pt, text(fill: white, weight: "bold", size: 12pt, it.body)) #show heading.where(level: 3): it => text(fill: ORANGE, weight: "bold", size: 12.5pt, it.body) #show heading.where(level: 4): it => text(fill: BLUE, weight: "bold", size: 10.5pt, it.body) #let examplebox(label, title, body) = block(width: 100%, breakable: true, fill: rgb("#EFF1F5"), stroke: 0.5pt + rgb("#CFDDF0"), radius: 4pt, inset: 10pt, above: 12pt, below: 12pt)[ #block(below: 6pt)[#box(fill: BLUE, inset: (x: 6pt, y: 2pt), radius: 2pt, text(fill: white, weight: "bold", size: 8.5pt, label)) #h(0.4em) #strong[#title]] #body] // rail = decorative left rule (raw brand token); labelcolor = AA-safe label text shade #let notebox(label, rail, labelcolor, tint, body) = block(width: 100%, breakable: true, fill: tint, stroke: (left: 3pt + rail), inset: (left: 10pt, rest: 8pt), radius: (right: 4pt), above: 11pt, below: 11pt)[ #text(fill: labelcolor, weight: "bold", size: 7.5pt, tracking: 0.5pt)[#upper(label)] #linebreak() #body] #let solutionbox(body) = block(above: 4pt, below: 8pt)[ #text(fill: BLUE, weight: "bold", size: 8.5pt)[Solution] #linebreak() #body] #let figph(msg) = block(width: 100%, height: 60pt, fill: rgb("#f6f7f9"), stroke: (paint: rgb("#c7ccd3"), dash: "dashed"), radius: 4pt, inset: 10pt)[ #align(center + horizon, text(fill: rgb("#889"), style: "italic", size: 9pt, msg))] // Standardize inlined figure sizes: measure the natural CeTZ canvas, then scale to a // consistent envelope (aspect-aware; see build_typst.py FIG_* constants). Unlike the // print preamble, dimensions are FLOORED: in an editor a user can trim a figure to a // degenerate 1-D shape (a bare line), and w/h or tw/w would then divide by zero. #let _STD_W = 3.5 #let _WIDE_W = 5.6 #let _MAX_H = 3.4 #let _ASPECT_WIDE = 2.2 #let _UPSCALE_MAX = 1.15 #let stdfig(body) = context { let m = measure(body) let w = calc.max(m.width / 1in, 0.01) let h = calc.max(m.height / 1in, 0.01) let tw = if w / h > _ASPECT_WIDE { _WIDE_W } else { _STD_W } let s = calc.min(tw / w, _MAX_H / h, _UPSCALE_MAX) align(center, box(scale(x: s * 100%, y: s * 100%, reflow: true, body))) } #show figure: set block(breakable: false) #set figure(gap: 8pt) #show figure.caption: set text(size: 8.5pt, fill: rgb("#555")) == 4.6#h(0.6em)Conditional Probability The probability of event B happening, given that event A already happened, is called the #strong[conditional probability]. The conditional probability of B, given A is written as P(B | A), and is read as “the probability of B given A happened first.” We can use the General Multiplication Rule when two events are dependent. #notebox("Note", rgb("#8a94a6"), rgb("#556666"), rgb("#f7f8fa"))[ #emph[General Multiplication Rule] #math.equation(block: true, alt: "P open parenthesis A ∩ B close parenthesis equals P open parenthesis A close parenthesis times P open parenthesis B vertical bar A close parenthesis P open parenthesis A ∩ B close parenthesis; equals P open parenthesis A close parenthesis times P open parenthesis B vertical bar A close parenthesis")[$P ( A ∩ B ) = P ( A ) · P ( B | A ) P ( A ∩ B ) \ = P ( A ) · P ( B | A )$] ] #examplebox("Example 1")[][ A bag contains 10 colored marbles: 7 red and 3 blue. A random experiment consists of drawing a marble from the bag, then drawing another marble without replacement (without putting the first marble back in the bag). Find the probability of drawing a red marble on the first draw (event #emph[R]#sub[1]), #emph[and] drawing another red marble on the second draw (event #emph[R]#sub[2]). #solutionbox[ Drawing a red marble on the first draw and drawing a red marble on the second draw are dependent events because we do not place the marble back in the bag. The probability of drawing a red marble on the first draw is P(#emph[R]#sub[1]) = #math.equation(block: false, alt: "the fraction 7 over 10")[$frac(7, 10)$], but on the second draw, the probability of drawing a red marble given that a red marble was drawn on the first draw is P(#emph[R]#sub[2]|#emph[R]#sub[1]) = #math.equation(block: false, alt: "the fraction 6 over 9")[$frac(6, 9)$]. \# Check the tree-diagram answer by simulating the two dependent draws bag \<- rep(c("R", "B"), c(7, 3)) \# 7 red, 3 blue set.seed(2) both\_red \<- replicate(10000, { draw \<- sample(bag, 2) \# sample() draws WITHOUT replacement draw\[1\] == "R" && draw\[2\] == "R" }) mean(both\_red) \# simulation estimate of P(R1 and R2) (7/10) \* (6/9) \# general multiplication rule -\> 0.4667 \# Change the bag to rep(c("R","B"), c(5, 5)) and re-run both lines Thus, by the general multiplication rule, P(#emph[R]#sub[1] and #emph[R]#sub[2]) = P(#emph[R]#sub[1])·P(#emph[R]#sub[2]|#emph[R]#sub[1]) = ( #math.equation(block: false, alt: "the fraction 7 over 10")[$frac(7, 10)$] ) ( #math.equation(block: false, alt: "the fraction 6 over 9")[$frac(6, 9)$] ) = 0.4667. ] ] #examplebox("Example 2")[][ A bag contains 10 colored marbles: 7 red and 3 blue. A random experiment consists of drawing a marble from the bag, then drawing another marble without replacement. Create the tree diagram for this experiment and compute the probabilities of each outcome. #solutionbox[ #figure(figph[Tree diagram for drawing two marbles without replacement: P(R1) = 7/10 and P(B1) = 3/10 branch to P(R2|R1) = 6/9, P(B2|R1) = 3/9, P(R2|B1) = 7/9, and P(B2|B1) = 2/9, giving outcome probabilities (7/10)(6/9) = 0.4667, 0.2333, 0.2333, and (3/10)(2/9) = 0.0667.], alt: "Tree diagram for drawing two marbles without replacement: P(R1) = 7/10 and P(B1) = 3/10 branch to P(R2|R1) = 6/9, P(B2|R1) = 3/9, P(R2|B1) = 7/9, and P(B2|B1) = 2/9, giving outcome probabilities (7/10)(6/9) = 0.4667, 0.2333, 0.2333, and (3/10)(2/9) = 0.0667.", caption: none) Figure 4-15 If we were to multiply the probabilities as we move from left to right up each set of tree branches as shown in Figure 4-15, we get the intersections. For example, by the general multiplication rule, P(#emph[R]#sub[1] and #emph[R]#sub[2]) = P(#emph[R]#sub[1])·P(#emph[R]#sub[2]|#emph[R]#sub[1]) = ( #math.equation(block: false, alt: "the fraction 7 over 10")[$frac(7, 10)$] ) ( #math.equation(block: false, alt: "the fraction 6 over 9")[$frac(6, 9)$] ) = 0.4667. Put the four intersection values into a contingency table and total the rows and columns. The table will help solve probability questions of other events. #figure(table( columns: 4, align: left, inset: 6pt, table.header([], [#emph[R] #sub[2]], [#emph[B] #sub[2]], [Total]), [#emph[R] #sub[1]], [0.4667], [0.2333], [0.7], [#emph[B] #sub[1]], [0.2333], [0.0667], [0.3], [Total], [0.7], [0.3], [1], )) The grand total should add up to 1 since we have 100% of the sample space. ] ] #notebox("Note", rgb("#8a94a6"), rgb("#556666"), rgb("#f7f8fa"))[ #strong[Conditional Probability Rule:] #emph[P] (#emph[A]|#emph[B]) = #math.equation(block: false, alt: "the fraction P open parenthesis A intersection B close parenthesis over P open parenthesis B close parenthesis")[$frac(P ( A ∩ B ), P ( B ))$] or #emph[P] (#emph[B]|#emph[A]) = #math.equation(block: false, alt: "the fraction P open parenthesis A intersection B close parenthesis over P open parenthesis A close parenthesis")[$frac(P ( A ∩ B ), P ( A ))$] ] #examplebox("Example 3")[][ The following table shows the utility contract granted for a specific year. One contractor is randomly chosen. Corporation Government Individual Total United States 0.45 0.007 0.08 0.537 Foreign 0.41 0.003 0.05 0.463 Total 0.86 0.01 0.13 1 + Compute the probability the contractor is from the United States and is a corporation. + Compute the probability the contractor is from the United States given that they are a corporation. + If the contractor is from a foreign country, what is the probability that it is from a government? + Are the events a “contractor is an individual” independent of a “contractor from the United States?” #solutionbox[ a) For the intersection in the contingency tables use where the row and column meet. P(U.S. ∩ Corp) = 0.45. b) #emph[P] (U.S.|Corp) = #math.equation(block: false, alt: "the fraction P open parenthesis U.S. ∩ Corp close parenthesis over P open parenthesis Corp close parenthesis")[$frac(P ( " U.S. ∩ Corp" ), P ( "Corp" ))$] = #math.equation(block: false, alt: "the fraction 0.45 over 0.86")[$frac(0.45, 0.86)$] = 0.5233. c) #emph[P] (Gov|Foreign) = #math.equation(block: false, alt: "the fraction P open parenthesis Gov ∩ Foreign close parenthesis over P open parenthesis Foreign close parenthesis")[$frac(P ( " Gov ∩ Foreign" ), P ( "Foreign" ))$] = #math.equation(block: false, alt: "the fraction 0.003 over 0.463")[$frac(0.003, 0.463)$] = 0.0065. d) Do not assume independence between two variables in a contingency table since the data may show relationships that you didn’t know were there. Use the definition of independent events. If the two events are independent then we would have P(Individual ∩ U.S.) = P(Individual)·P(U.S.). First find the intersection using where the row and column meet to get P(Individual ∩ U.S.) = 0.08. Then use the row and column totals to find P(Individual)·P(U.S.) = 0.13·0.537 = 0.0698. Since P(Individual ∩ U.S.) ≠ P(Individual)·P(U.S.) these two events are dependent. ] ] #examplebox("Example 4")[][ A random sample of 500 people was taken from the 2010 United States Census. Their marital status and race were recorded in the following contingency table. A person is randomly chosen, find the following. Race Marital Status American Indian Black Asian White Two Major Races Total Divorced 0 6 1 30 1 38 Married 1 25 23 156 4 209 Single 2 33 21 155 11 222 Widowed 0 7 2 22 0 31 Total 3 71 47 363 16 500 a) P(Single and Asian) b) P(Single | Asian) c) Given that a person is single what is the probability their race is Asian? #solutionbox[ a) The intersection for a contingency table is found by simply finding where the row or intersection meets. There are 21 single Asians, therefore the P(Single ∩ Asian) = P(Single and Asian) = 21/500 = 0.042. Do not multiply the row total times the column total since there is no indication that these are independent events. b) In words we are trying to find the probability that the person is single given that we already know that their race is Asian. Using the conditional probability formula, we get P(Single | Asian) = #math.equation(block: false, alt: "the fraction P open parenthesis Single ∩ Asian close parenthesis over P open parenthesis Asian close parenthesis")[$frac(P ( " Single ∩ Asian" ), P ( "Asian" ))$] = #math.equation(block: false, alt: "the fraction 21 over 47")[$frac(21, 47)$] = 0.4468. c) This seems similar to the last question, however the part we know is that the person is single, but we do not know their race. In symbols we want to find the P(Asian | Single) = #math.equation(block: false, alt: "the fraction P open parenthesis Asian ∩ Single close parenthesis over P open parenthesis Single close parenthesis")[$frac(P ( " Asian ∩ Single" ), P ( "Single" ))$]= #math.equation(block: false, alt: "the fraction 21 over 222")[$frac(21, 222)$] = 0.0946. ] ] #notebox("Note", rgb("#8a94a6"), rgb("#556666"), rgb("#f7f8fa"))[ Keep in mind that P(A | B) ≠ P(B | A) since we would divide by a different total in the equation. ] #examplebox("Example 5")[][ A blood test correctly detects a certain disease 95% of the time (positive result), and correctly detects no disease present 90% of the time (negative result). It is estimated that 25% of the population have the disease. A person takes the blood test and they get a positive result. What is the probability that they have the disease? #solutionbox[ Let #emph[D] = Having the Disease, #emph[D#super[C]] = Not having the disease, + is a positive result, and – is a negative result. We are given in the problem the following: P(+ | #emph[D]) = 0.95, P(– | #emph[D#super[C]]) = 0.90, P(#emph[D]) = 0.25. We want to find #emph[P] (#emph[D]|+) = #math.equation(block: false, alt: "the fraction P open parenthesis D intersection plus close parenthesis over P open parenthesis plus close parenthesis")[$frac(P ( D ∩ + ), P ( + ))$]. #figure(figph[Tree diagram for a disease test: P(D) = 0.25 and P(D^C) = 0.75 branch to P(+|D) = 0.95, P(−|D) = 0.05, P(+|D^C) = 0.1, and P(−|D^C) = 0.9, giving joint probabilities 0.2375, 0.0125, 0.075, and 0.675.], alt: "Tree diagram for a disease test: P(D) = 0.25 and P(D^C) = 0.75 branch to P(+|D) = 0.95, P(−|D) = 0.05, P(+|D^C) = 0.1, and P(−|D^C) = 0.9, giving joint probabilities 0.2375, 0.0125, 0.075, and 0.675.", caption: none) Figure 4-16 When you multiply up each pair of tree branches from left to right as shown in Figure 4-16, you are finding the intersection of the events. Place the multiplied values into a table. Note that the 0.2375 is not our answer. This is the people who have the disease and tested positive, but does not take into consideration the false positives. Since we know that the result was positive, we only divide by the proportion of positive results. #figure(table( columns: 4, align: left, inset: 6pt, table.header([], [#emph[D#super[C]]], [#emph[D]], [Total]), [+], [0.075], [0.2375], [0.3125], [–], [0.675], [0.0125], [0.6875], [Total], [0.75], [0.25], [1], )) #math.equation(block: true, alt: "P open parenthesis D vertical bar plus close parenthesis equals the fraction P open parenthesis D intersection plus close parenthesis over P open parenthesis plus close parenthesis equals the fraction 0.2375 over 0.3125 equals 0.76")[$P ( D | + ) = frac(P ( D ∩ + ), P ( + )) = frac(0.2375, 0.3125) = 0.76$] There is a 76% chance that they have the disease given that they tested positive. Many of the more difficult probability problems can be set up in a table, which makes the probabilities easier to find. ] ]