{"id":1175,"date":"2024-05-03T18:32:05","date_gmt":"2024-05-03T22:32:05","guid":{"rendered":"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/?post_type=chapter&#038;p=1175"},"modified":"2024-06-12T14:38:48","modified_gmt":"2024-06-12T18:38:48","slug":"calculating-probabilities-using-contingency-tables","status":"publish","type":"chapter","link":"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/chapter\/calculating-probabilities-using-contingency-tables\/","title":{"raw":"Calculating Probabilities Using Contingency Tables","rendered":"Calculating Probabilities Using Contingency Tables"},"content":{"raw":"<div class=\"textbox textbox--learning-objectives\"><header class=\"textbox__header\">\r\n<p class=\"textbox__title\">Learning Objectives<\/p>\r\n\r\n<\/header>\r\n<div class=\"textbox__content\">\r\n\r\nUse contingency tables to calculate probabilities.\r\n\r\n<\/div>\r\n<\/div>\r\n<h2>Possible Calculations Using Contingency Tables:<\/h2>\r\nContingency tables give us the following values:\r\n<ul>\r\n \t<li>'Singular' probabilities: P(A), P(B), P(\u0100), P(B\u0305), ...<\/li>\r\n \t<li>'Joint' probabilities: P(A and B), P(A and B\u0305), P(\u0100 and B), P(\u0100 and B\u0305), ...<\/li>\r\n<\/ul>\r\nWe can use these probabilities and our probability rule to calculate many probabilities. Ex:\r\n<ul>\r\n \t<li>P(At least one event occurring):[latex]P(A \\text{ or } B) = P(A) + P(B) - P(A \\text{ and } B) [\/latex]<\/li>\r\n \t<li>P(Neither event occurring):[latex]P(\\text{neither }A \\text{ nor } B) = P(\\overline{A} \\text{ and } \\overline{B}) [\/latex]<\/li>\r\n \t<li>P(One event occurring given another event occurred):[latex]P(A|B) = \\frac{P(A \\text{ and } B)}{P(B)} [\/latex]<\/li>\r\n<\/ul>\r\n<h1>Calculting Either\/Or, Neither\/Nor (Exercise)<\/h1>\r\nLet us explore understanding multiple ways to use the table to calculate:\r\n<ul>\r\n \t<li>P(A or B) = P(at least one of event A or B occurs)<\/li>\r\n \t<li>P(neither A nor B) = P(neither event A nor event B occurs)<\/li>\r\n<\/ul>\r\n<h2>Example 18.1.1<\/h2>\r\n<strong><span style=\"color: #003366\">Problem Setup<\/span><\/strong>: Let us continue with the two marketing campaigns example (Example 18.1):\r\n<ul>\r\n \t<li>P(A) = the click-through rate for ad campaign 'A'<\/li>\r\n \t<li>P(B) = the click-through rate for ad campaign 'B'<\/li>\r\n \t<li>P(\u0100) = probability of people not clicking through after viewing ad 'A'<\/li>\r\n \t<li>P(B\u0305) = probability of people not clicking through after viewing ad 'B'<\/li>\r\n \t<li>The 2x2 (contingency) table for this example is below:<\/li>\r\n<\/ul>\r\n<table class=\"grid aligncenter\" style=\"width: 676px\">\r\n<tbody>\r\n<tr>\r\n<td style=\"width: 130.521px;text-align: center\"><\/td>\r\n<td style=\"width: 179.354px;text-align: center\"><strong>A<\/strong><\/td>\r\n<td style=\"width: 261.083px;text-align: center\"><strong>not A<\/strong><\/td>\r\n<td style=\"width: 150.708px;text-align: center\"><strong>Totals<\/strong><\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 130.521px;text-align: center\"><strong>B<\/strong><\/td>\r\n<td style=\"width: 179.354px;text-align: center\">0.003<\/td>\r\n<td style=\"width: 261.083px;text-align: center\">0.047<\/td>\r\n<td style=\"width: 150.708px;text-align: center\">0.05<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 130.521px;text-align: center\"><strong>not B<\/strong><\/td>\r\n<td style=\"width: 179.354px;text-align: center\">0.017<\/td>\r\n<td style=\"width: 261.083px;text-align: center\">0.933<\/td>\r\n<td style=\"width: 150.708px;text-align: center\">0.95<\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 130.521px;text-align: center\"><strong>Totals<\/strong><\/td>\r\n<td style=\"width: 179.354px;text-align: center\">0.02<\/td>\r\n<td style=\"width: 261.083px;text-align: center\">0.98<\/td>\r\n<td style=\"width: 150.708px;text-align: center\">1<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<span style=\"color: #003366\"><strong>Questions<\/strong><\/span>: Use the above table to answer the following:\r\n<ol>\r\n \t<li>What percent of people click through on at least one of the ads?<\/li>\r\n \t<li>What percent of people click through on neither 'A' nor 'B'?<\/li>\r\n<\/ol>\r\n<span style=\"color: #003366\"><strong>Solution<\/strong><\/span>: Click below to reveal the answers (after trying it yourself):\r\n\r\n[h5p id=\"44\"]\r\n<h1>Calculating COnditional Probabilities (Exercise)<\/h1>\r\nTo get the conditional\/given probabilities:\r\n<ul>\r\n \t<li>Take any of the <em>AND<\/em>'s in our table and divide by an overall probabilities.<\/li>\r\n \t<li>Ex: [latex]P(A|B) = \\frac{P(A \\text{ and } B)}{P(B)} [\/latex]<\/li>\r\n<\/ul>\r\n<h2>Example 18.1.2<\/h2>\r\n<strong><span style=\"color: #003366\">Problem Setup<\/span><\/strong>: Let us continue using the table given in Example 18.1.1.\r\n\r\n<span style=\"color: #003366\"><strong>Questions<\/strong><\/span>: Calculate the conditional probabilities listed below:\r\n<ol>\r\n \t<li>What percent of people who clicked through on ad 'A' then click through on 'B'?<\/li>\r\n \t<li>Given someone doesn't click through 'A', what is the probability they click through 'B'?<\/li>\r\n \t<li>Out of those who do not click through on 'B', what percent click through on 'A'?<\/li>\r\n \t<li>Who should the company running these ads target for ad 'B'? Those who clicked through on 'A' or those who did not?<\/li>\r\n<\/ol>\r\n<span style=\"color: #003366\"><strong>Instructions: <\/strong><\/span>Try the questions yourself. Once done, click below to reveal the answers for each part.\r\n<div>\r\n<h1>Solution # 18.1.2-1 (Click To ReveAL)<\/h1>\r\nThink of what comes 'first' in this conditional probability. <span style=\"font-size: 20.5333px\">This event goes behind the line<\/span>\r\n<ul>\r\n \t<li>In this case, clicking through on 'A' comes first.<\/li>\r\n \t<li>So, we are looking for P(B|A)<\/li>\r\n \t<li>Ie: [latex]P(B|A) = \\frac{P(A \\text{ and } B)}{P(A)}=\\frac{0.003}{0.02}= 0.15=15\\%[\/latex]<\/li>\r\n \t<li>This was actually the probability we were given at the start of this example in the last section!<\/li>\r\n<\/ul>\r\n<\/div>\r\n<div>\r\n<h1>Solution #18.1.2-2 (Click to reveal)<\/h1>\r\nNot clicking through after viewing ad 'A' comes first for this conditional probability.\r\n<ul>\r\n \t<li>Ie: We are looking for P(B| not A) = P(B| \u0100)<\/li>\r\n \t<li>[latex]P(B|\\overline{A}) = \\frac{P(\\overline{A} \\text{ and } B)}{P(\\overline{A})}=\\frac{0.047}{0.98}= 0.0480=4.8\\%[\/latex]<\/li>\r\n<\/ul>\r\n<\/div>\r\n<div>\r\n<h1>Solution #18.1.2-3 (Click To reveal)<\/h1>\r\nNot clicking through after viewing ad 'B' comes first for this conditional probability. Ie:\r\n<ul>\r\n \t<li>We are looking for P(A| not B) = P(A | B\u0305)<\/li>\r\n \t<li>[latex]P(A|\\overline{B}) = \\frac{P(A \\text{ and } \\overline{B})}{P(\\overline{B})}=\\frac{0.017}{0.95}= 0.0179=1.79\\%[\/latex]<\/li>\r\n<\/ul>\r\n<\/div>\r\n<div>\r\n<h1>Solution #18.1.2-4 (Click To reveal)<\/h1>\r\nIn questions 1 and 2, we examined the following:\r\n<ul>\r\n \t<li>Percent who clicked on 'B' after they clicked on 'A'= P(B|A) =15%<\/li>\r\n \t<li>Percent who clicked on 'B' after not clicking on 'A'= P(B|\u0100) =4.8%<\/li>\r\n \t<li>We can tell that those who clicked on 'A' first are quite a bit more likely to click on 'B'<\/li>\r\n \t<li>So, the company should target those who already clicked on A.<\/li>\r\n \t<li>We will revisit this idea later in the course with 'Chi-squared' testing<\/li>\r\n<\/ul>\r\n<\/div>\r\n<h1>Key Takeaways (EXERCISE)<\/h1>\r\n<div class=\"textbox textbox--key-takeaways\"><header class=\"textbox__header\">\r\n<p class=\"textbox__title\">Key Takeaways: Calculating Probabilities Using Contingency Tables<\/p>\r\n&nbsp;\r\n\r\n<\/header>\r\n<div class=\"textbox__content\">\r\n\r\n[h5p id=\"46\"]\r\n\r\n[h5p id=\"45\"]\r\n\r\n<\/div>\r\n<\/div>\r\n<h1>Your Own Notes (EXERCISE)<\/h1>\r\n<ul>\r\n \t<li>Are there any notes you want to take from this section? Is there anything you'd like to copy and paste below?<\/li>\r\n \t<li>These notes are for you only (they will not be stored anywhere)<\/li>\r\n \t<li>Make sure to download them at the end to use as a reference<\/li>\r\n<\/ul>\r\n[h5p id=\"16\"]","rendered":"<div class=\"textbox textbox--learning-objectives\">\n<header class=\"textbox__header\">\n<p class=\"textbox__title\">Learning Objectives<\/p>\n<\/header>\n<div class=\"textbox__content\">\n<p>Use contingency tables to calculate probabilities.<\/p>\n<\/div>\n<\/div>\n<h2>Possible Calculations Using Contingency Tables:<\/h2>\n<p>Contingency tables give us the following values:<\/p>\n<ul>\n<li>&#8216;Singular&#8217; probabilities: P(A), P(B), P(\u0100), P(B\u0305), &#8230;<\/li>\n<li>&#8216;Joint&#8217; probabilities: P(A and B), P(A and B\u0305), P(\u0100 and B), P(\u0100 and B\u0305), &#8230;<\/li>\n<\/ul>\n<p>We can use these probabilities and our probability rule to calculate many probabilities. Ex:<\/p>\n<ul>\n<li>P(At least one event occurring):[latex]P(A \\text{ or } B) = P(A) + P(B) - P(A \\text{ and } B)[\/latex]<\/li>\n<li>P(Neither event occurring):[latex]P(\\text{neither }A \\text{ nor } B) = P(\\overline{A} \\text{ and } \\overline{B})[\/latex]<\/li>\n<li>P(One event occurring given another event occurred):[latex]P(A|B) = \\frac{P(A \\text{ and } B)}{P(B)}[\/latex]<\/li>\n<\/ul>\n<h1>Calculting Either\/Or, Neither\/Nor (Exercise)<\/h1>\n<p>Let us explore understanding multiple ways to use the table to calculate:<\/p>\n<ul>\n<li>P(A or B) = P(at least one of event A or B occurs)<\/li>\n<li>P(neither A nor B) = P(neither event A nor event B occurs)<\/li>\n<\/ul>\n<h2>Example 18.1.1<\/h2>\n<p><strong><span style=\"color: #003366\">Problem Setup<\/span><\/strong>: Let us continue with the two marketing campaigns example (Example 18.1):<\/p>\n<ul>\n<li>P(A) = the click-through rate for ad campaign &#8216;A&#8217;<\/li>\n<li>P(B) = the click-through rate for ad campaign &#8216;B&#8217;<\/li>\n<li>P(\u0100) = probability of people not clicking through after viewing ad &#8216;A&#8217;<\/li>\n<li>P(B\u0305) = probability of people not clicking through after viewing ad &#8216;B&#8217;<\/li>\n<li>The 2&#215;2 (contingency) table for this example is below:<\/li>\n<\/ul>\n<table class=\"grid aligncenter\" style=\"width: 676px\">\n<tbody>\n<tr>\n<td style=\"width: 130.521px;text-align: center\"><\/td>\n<td style=\"width: 179.354px;text-align: center\"><strong>A<\/strong><\/td>\n<td style=\"width: 261.083px;text-align: center\"><strong>not A<\/strong><\/td>\n<td style=\"width: 150.708px;text-align: center\"><strong>Totals<\/strong><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 130.521px;text-align: center\"><strong>B<\/strong><\/td>\n<td style=\"width: 179.354px;text-align: center\">0.003<\/td>\n<td style=\"width: 261.083px;text-align: center\">0.047<\/td>\n<td style=\"width: 150.708px;text-align: center\">0.05<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 130.521px;text-align: center\"><strong>not B<\/strong><\/td>\n<td style=\"width: 179.354px;text-align: center\">0.017<\/td>\n<td style=\"width: 261.083px;text-align: center\">0.933<\/td>\n<td style=\"width: 150.708px;text-align: center\">0.95<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 130.521px;text-align: center\"><strong>Totals<\/strong><\/td>\n<td style=\"width: 179.354px;text-align: center\">0.02<\/td>\n<td style=\"width: 261.083px;text-align: center\">0.98<\/td>\n<td style=\"width: 150.708px;text-align: center\">1<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"color: #003366\"><strong>Questions<\/strong><\/span>: Use the above table to answer the following:<\/p>\n<ol>\n<li>What percent of people click through on at least one of the ads?<\/li>\n<li>What percent of people click through on neither &#8216;A&#8217; nor &#8216;B&#8217;?<\/li>\n<\/ol>\n<p><span style=\"color: #003366\"><strong>Solution<\/strong><\/span>: Click below to reveal the answers (after trying it yourself):<\/p>\n<div id=\"h5p-44\">\n<div class=\"h5p-iframe-wrapper\"><iframe id=\"h5p-iframe-44\" class=\"h5p-iframe\" data-content-id=\"44\" style=\"height:1px\" src=\"about:blank\" frameBorder=\"0\" scrolling=\"no\" title=\"Click here to reveal the solutions to Example 24.1.1\"><\/iframe><\/div>\n<\/div>\n<h1>Calculating COnditional Probabilities (Exercise)<\/h1>\n<p>To get the conditional\/given probabilities:<\/p>\n<ul>\n<li>Take any of the <em>AND<\/em>&#8216;s in our table and divide by an overall probabilities.<\/li>\n<li>Ex: [latex]P(A|B) = \\frac{P(A \\text{ and } B)}{P(B)}[\/latex]<\/li>\n<\/ul>\n<h2>Example 18.1.2<\/h2>\n<p><strong><span style=\"color: #003366\">Problem Setup<\/span><\/strong>: Let us continue using the table given in Example 18.1.1.<\/p>\n<p><span style=\"color: #003366\"><strong>Questions<\/strong><\/span>: Calculate the conditional probabilities listed below:<\/p>\n<ol>\n<li>What percent of people who clicked through on ad &#8216;A&#8217; then click through on &#8216;B&#8217;?<\/li>\n<li>Given someone doesn&#8217;t click through &#8216;A&#8217;, what is the probability they click through &#8216;B&#8217;?<\/li>\n<li>Out of those who do not click through on &#8216;B&#8217;, what percent click through on &#8216;A&#8217;?<\/li>\n<li>Who should the company running these ads target for ad &#8216;B&#8217;? Those who clicked through on &#8216;A&#8217; or those who did not?<\/li>\n<\/ol>\n<p><span style=\"color: #003366\"><strong>Instructions: <\/strong><\/span>Try the questions yourself. Once done, click below to reveal the answers for each part.<\/p>\n<div>\n<h1>Solution # 18.1.2-1 (Click To ReveAL)<\/h1>\n<p>Think of what comes &#8216;first&#8217; in this conditional probability. <span style=\"font-size: 20.5333px\">This event goes behind the line<\/span><\/p>\n<ul>\n<li>In this case, clicking through on &#8216;A&#8217; comes first.<\/li>\n<li>So, we are looking for P(B|A)<\/li>\n<li>Ie: [latex]P(B|A) = \\frac{P(A \\text{ and } B)}{P(A)}=\\frac{0.003}{0.02}= 0.15=15\\%[\/latex]<\/li>\n<li>This was actually the probability we were given at the start of this example in the last section!<\/li>\n<\/ul>\n<\/div>\n<div>\n<h1>Solution #18.1.2-2 (Click to reveal)<\/h1>\n<p>Not clicking through after viewing ad &#8216;A&#8217; comes first for this conditional probability.<\/p>\n<ul>\n<li>Ie: We are looking for P(B| not A) = P(B| \u0100)<\/li>\n<li>[latex]P(B|\\overline{A}) = \\frac{P(\\overline{A} \\text{ and } B)}{P(\\overline{A})}=\\frac{0.047}{0.98}= 0.0480=4.8\\%[\/latex]<\/li>\n<\/ul>\n<\/div>\n<div>\n<h1>Solution #18.1.2-3 (Click To reveal)<\/h1>\n<p>Not clicking through after viewing ad &#8216;B&#8217; comes first for this conditional probability. Ie:<\/p>\n<ul>\n<li>We are looking for P(A| not B) = P(A | B\u0305)<\/li>\n<li>[latex]P(A|\\overline{B}) = \\frac{P(A \\text{ and } \\overline{B})}{P(\\overline{B})}=\\frac{0.017}{0.95}= 0.0179=1.79\\%[\/latex]<\/li>\n<\/ul>\n<\/div>\n<div>\n<h1>Solution #18.1.2-4 (Click To reveal)<\/h1>\n<p>In questions 1 and 2, we examined the following:<\/p>\n<ul>\n<li>Percent who clicked on &#8216;B&#8217; after they clicked on &#8216;A&#8217;= P(B|A) =15%<\/li>\n<li>Percent who clicked on &#8216;B&#8217; after not clicking on &#8216;A&#8217;= P(B|\u0100) =4.8%<\/li>\n<li>We can tell that those who clicked on &#8216;A&#8217; first are quite a bit more likely to click on &#8216;B&#8217;<\/li>\n<li>So, the company should target those who already clicked on A.<\/li>\n<li>We will revisit this idea later in the course with &#8216;Chi-squared&#8217; testing<\/li>\n<\/ul>\n<\/div>\n<h1>Key Takeaways (EXERCISE)<\/h1>\n<div class=\"textbox textbox--key-takeaways\">\n<header class=\"textbox__header\">\n<p class=\"textbox__title\">Key Takeaways: Calculating Probabilities Using Contingency Tables<\/p>\n<p>&nbsp;<\/p>\n<\/header>\n<div class=\"textbox__content\">\n<div id=\"h5p-46\">\n<div class=\"h5p-iframe-wrapper\"><iframe id=\"h5p-iframe-46\" class=\"h5p-iframe\" data-content-id=\"46\" style=\"height:1px\" src=\"about:blank\" frameBorder=\"0\" scrolling=\"no\" title=\"Key Takeaways for Using Contingency Tables to Calculate Probabilities 1\"><\/iframe><\/div>\n<\/div>\n<div id=\"h5p-45\">\n<div class=\"h5p-iframe-wrapper\"><iframe id=\"h5p-iframe-45\" class=\"h5p-iframe\" data-content-id=\"45\" style=\"height:1px\" src=\"about:blank\" frameBorder=\"0\" scrolling=\"no\" title=\"Key Takeaways for Using Contingency Tables to Calculate Probabilities Solutions\"><\/iframe><\/div>\n<\/div>\n<\/div>\n<\/div>\n<h1>Your Own Notes (EXERCISE)<\/h1>\n<ul>\n<li>Are there any notes you want to take from this section? Is there anything you&#8217;d like to copy and paste below?<\/li>\n<li>These notes are for you only (they will not be stored anywhere)<\/li>\n<li>Make sure to download them at the end to use as a reference<\/li>\n<\/ul>\n<div id=\"h5p-16\">\n<div class=\"h5p-iframe-wrapper\"><iframe id=\"h5p-iframe-16\" class=\"h5p-iframe\" data-content-id=\"16\" style=\"height:1px\" src=\"about:blank\" frameBorder=\"0\" scrolling=\"no\" title=\"Key takeaways, notes and comments from this section document tool.\"><\/iframe><\/div>\n<\/div>\n","protected":false},"author":865,"menu_order":5,"template":"","meta":{"pb_show_title":"on","pb_short_title":"","pb_subtitle":"","pb_authors":[],"pb_section_license":""},"chapter-type":[],"contributor":[],"license":[],"class_list":["post-1175","chapter","type-chapter","status-publish","hentry"],"part":208,"_links":{"self":[{"href":"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-json\/pressbooks\/v2\/chapters\/1175","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-json\/pressbooks\/v2\/chapters"}],"about":[{"href":"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-json\/wp\/v2\/types\/chapter"}],"author":[{"embeddable":true,"href":"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-json\/wp\/v2\/users\/865"}],"version-history":[{"count":25,"href":"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-json\/pressbooks\/v2\/chapters\/1175\/revisions"}],"predecessor-version":[{"id":1949,"href":"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-json\/pressbooks\/v2\/chapters\/1175\/revisions\/1949"}],"part":[{"href":"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-json\/pressbooks\/v2\/parts\/208"}],"metadata":[{"href":"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-json\/pressbooks\/v2\/chapters\/1175\/metadata\/"}],"wp:attachment":[{"href":"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-json\/wp\/v2\/media?parent=1175"}],"wp:term":[{"taxonomy":"chapter-type","embeddable":true,"href":"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-json\/pressbooks\/v2\/chapter-type?post=1175"},{"taxonomy":"contributor","embeddable":true,"href":"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-json\/wp\/v2\/contributor?post=1175"},{"taxonomy":"license","embeddable":true,"href":"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-json\/wp\/v2\/license?post=1175"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}