{"id":204,"date":"2012-08-16T21:17:48","date_gmt":"2012-08-17T01:17:48","guid":{"rendered":"http:\/\/learninglover.com\/blog\/?p=204"},"modified":"2014-06-16T09:30:25","modified_gmt":"2014-06-16T13:30:25","slug":"understanding-bayes-theorem","status":"publish","type":"post","link":"https:\/\/learninglover.com\/blog\/index.php\/2012\/08\/16\/understanding-bayes-theorem\/","title":{"rendered":"Understanding Bayes&#8217; Theorem"},"content":{"rendered":"<figure id=\"attachment_209\" aria-describedby=\"caption-attachment-209\" style=\"width: 271px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.learninglover.com\/examples.php?id=26\" title=\"Bayes Theorem\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/learninglover.com\/blog\/wp-content\/uploads\/2012\/08\/bayes-271x300.jpg\" alt=\"An Image of Bayes&#039; Theorem Script\" title=\"bayes\" width=\"271\" height=\"300\" class=\"size-medium wp-image-209\" \/><\/a><figcaption id=\"caption-attachment-209\" class=\"wp-caption-text\">An Image of Bayes&#8217; Theorem Script<\/figcaption><\/figure>\n<p>I&#8217;ve finished <a href=\"http:\/\/www.learninglover.com\/examples.php?id=26\" title=\"Bayes Theorem\">a script that helps understand Bayes&#8217; Theorem<\/a>. <\/p>\n<p>If we have a set of mutually exclusive (aka non-overlapping) sets B<sub>i<\/sub> for i <img decoding=\"async\" src=\"http:\/\/www.learninglover.com\/chars\/in.gif\"\/> {0, 1, 2, &#8230;, n} for some integer n, then the union of these sets forms a sample space. Lets call the sample space S. Suppose that we also have some set (also known as an event) A which is also a subset of S. Bayes&#8217; Theorem considers the probability that one of these mutually exclusive events (one of the B<sub>i<\/sub>&#8216;s) caused the observed event (A). <\/p>\n<p>This probability can be calculated by the formula <\/p>\n<table style=\"width:auto;line-height:normal;\">\n<tr>\n<td>Pr(B<sub>j<\/sub> | A) = <\/td>\n<td><center>Pr(B<sub>j<\/sub>) Pr(A | B<sub>j<\/sub>)<\/center><\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td style=\"border-top:solid 1px black;\"><center><img decoding=\"async\" src=\"http:\/\/www.learninglover.com\/chars\/csigma.gif\"> Pr(B<sub>i<\/sub>) Pr(A | B<sub>i<\/sub>)<\/center><\/td>\n<\/tr>\n<\/table>\n<p>The theorem helps us determine the the probability of the event B<sub>j<\/sub> given A, or in more plain English, the probability that the event B<sub>j<\/sub> is the cause that gives rise to the observed event A. The numerator is given by the product of of the probability of the causal event (Pr(B<sub>j<\/sub>) times the conditional probability of the observed event given the causal event (Pr(A | B<sub>j<\/sub>)). This numerator could be replaced by its equivalent statement of the set A <img decoding=\"async\" src=\"http:\/\/www.learninglover.com\/chars\/cap.gif\" \/> B<sub>j<\/sub>. Likewise, the denominator the sum (over all the causal events) of the probaility of each causal event times the conditional probability of the observed event given that particular causal event. Each term in this denominator could be replaced b its equivalent staetment A <img decoding=\"async\" src=\"http:\/\/www.learninglover.com\/chars\/cap.gif\" \/> B<sub>i<\/sub>, which when summed give the total probability of A because each pair of the B<sub>j<\/sub>&#8216;s is mutually exclusive. So we are able to replace the probability of A with <img decoding=\"async\" src=\"http:\/\/www.learninglover.com\/chars\/csigma.gif\"> Pr(B<sub>i<\/sub>) Pr(A | B<sub>i<\/sub>) because of the fundamental law of probability. <\/p>\n<p>An example that would use Bayes&#8217; Theorem is analyzing the results of an election. The set of mutually exclusive events could be membership in a political party (Democrat, Republican, or Independent). The observed event could be the election of an individual. And the conditional distributions could be the percentage of each party that voted for this individual. If we want to calculate how significant each party was to the individual&#8217;s election, we&#8217;d use Bayes&#8217; Theorem. <\/p>\n<p>The <a href=\"http:\/\/www.learninglover.com\/examples.php?id=26\" title=\"Bayes Theorem\">script I&#8217;ve written to help understand Bayes&#8217; Theorem<\/a> works as follows:<br \/>\n &#8211; A set of mutually exclusive sets is randomly generated (the number of sets also varies). These sets are called B<sub>i<\/sub> for i <img decoding=\"async\" src=\"http:\/\/www.learninglover.com\/chars\/in.gif\"\/> (0, &#8230;, n}.<br \/>\n &#8211; A set A is randomly generated from the union of the B<sub>i<\/sub>&#8216;s.<br \/>\n &#8211; A table is displayed showing:<br \/>\n     Pr(B<sub>i<\/sub>) for each i on line 1.<br \/>\n     Pr(A | B<sub>i<\/sub>) for each i on line 2. <\/p>\n<p> &#8211; The user is given the option to select which of the mutually exclusive sets they would like to use to calculate the probability that this set caused the event A.<br \/>\n &#8211; Once a set is chosen, the user clicks the &#8220;Calculate Conditional&#8221; button and Bayes&#8217; Theorem gives the result.<br \/>\n &#8211; If the &#8220;show work&#8221; checkbox was checked, then the steps used in this calculation are also shown.<br \/>\n &#8211; All work is done using fractions to give an idea of where the numbers come from. <\/p>\n<p>Other Blogs that have covered this topic:<br \/>\n<a href=\"http:\/\/betterexplained.com\/articles\/understanding-bayes-theorem-with-ratios\/\" title=\"Better Explained\">Better Explained<\/a><br \/>\n<a href=\"http:\/\/www.bayestheorem-qed.com\/\" title=\"Bayes' Theorem-qed\">Bayes&#8217; Theorem-qed<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve finished a script that helps understand Bayes&#8217; Theorem. If we have a set of mutually exclusive (aka non-overlapping) sets Bi for i {0, 1, 2, &#8230;, n} for some integer n, then the union of these sets forms a sample space. Lets call the sample space S. Suppose that we also have some set [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-204","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/learninglover.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/204","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/learninglover.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/learninglover.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/learninglover.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/learninglover.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=204"}],"version-history":[{"count":1,"href":"https:\/\/learninglover.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/204\/revisions"}],"predecessor-version":[{"id":887,"href":"https:\/\/learninglover.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/204\/revisions\/887"}],"wp:attachment":[{"href":"https:\/\/learninglover.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=204"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/learninglover.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=204"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/learninglover.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=204"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}