tag:blogger.com,1999:blog-6894866515532737257.post1352062729055702719..comments2024-04-22T21:33:32.590-07:00Comments on Probably Overthinking It: All your Bayes are belong to us!Allen Downeyhttp://www.blogger.com/profile/01633071333405221858noreply@blogger.comBlogger62125tag:blogger.com,1999:blog-6894866515532737257.post-67205422141194663592016-09-15T12:08:21.616-07:002016-09-15T12:08:21.616-07:00Thanks for that link. The response from Adriano s...Thanks for that link. The response from Adriano shows another way to answer the question, but it doesn't use Bayes's theorem. I think the method using Bayes's theorem is easier, but maybe not everyone thinks so.Allen Downeyhttps://www.blogger.com/profile/01633071333405221858noreply@blogger.comtag:blogger.com,1999:blog-6894866515532737257.post-27775106159205120922016-09-15T12:04:53.165-07:002016-09-15T12:04:53.165-07:00If Oliver left blood at the scene, he accounts for...If Oliver left blood at the scene, he accounts for the O sample, leaving only one sample to be explained. The chance that one random person has AB blood is 1%.<br /><br />If Oliver did not leave blood at the scene, there are two samples to be explained. If you draw random pairs from the population, you might get [AB, O] or [O, AB] with equal probability, so there are two ways to generate the evidence.<br /><br />If that's not clear, the best way to prove it to yourself is to enumerate all possible pairs.Allen Downeyhttps://www.blogger.com/profile/01633071333405221858noreply@blogger.comtag:blogger.com,1999:blog-6894866515532737257.post-47571357797154577452016-09-13T17:03:04.712-07:002016-09-13T17:03:04.712-07:00Thank you for publishing these problems. I had so...Thank you for publishing these problems. I had some trouble figuring out how P(E) was derived in the M&M problem (#2). I asked for help on math overflow and got a good answer.. May be helpful to others who got similarly stuck -> http://math.stackexchange.com/questions/1924904/urn-type-problem-with-bayes-theorem-and-mms-dont-understand-how-probability<br />Chris Bedfordhttps://www.blogger.com/profile/15601997591378792422noreply@blogger.comtag:blogger.com,1999:blog-6894866515532737257.post-62871977694719436302016-09-13T15:11:33.791-07:002016-09-13T15:11:33.791-07:00I'm having troubles going through the fourth p...I'm having troubles going through the fourth problem.<br /><br />Why would p(E|X) be equal to .01 <br /><br />I think you get that result from multiplying .01 (The probability of finding AB type blood) by 1, given that it makes sense to find O type blood if Oliver was actually involved in the crime.<br /><br />But why didn't you multiply that by a factor of 2? Why wouldn't the permutation factor matter in one case (When testing the hypothesis of Oliver being guilty), but it does in the other? <br /><br />Thank you! :D Anonymoushttps://www.blogger.com/profile/07599875152333798994noreply@blogger.comtag:blogger.com,1999:blog-6894866515532737257.post-73295091982788572782016-01-02T16:03:10.159-08:002016-01-02T16:03:10.159-08:00It would be beneficial for those of us trying to i...It would be beneficial for those of us trying to intuit this if, instead of "Plug in Bayes's theorem" we got a little clearer elaboration. Thanks though.Anonymoushttps://www.blogger.com/profile/14067952676942833778noreply@blogger.comtag:blogger.com,1999:blog-6894866515532737257.post-13777433760043308842015-12-22T04:05:53.930-08:002015-12-22T04:05:53.930-08:00With regard to question 4, although the question d...With regard to question 4, although the question does not ask for posterior probability, I am attempting<br />to solve it using the posterior probability approach to see which proposition has higher odd of <br />finding the criminal.<br /><br />I define 3 propositions which I think are exclusive and exhaustive with regards to this problem,<br />A: Criminal1 is Oliver. Criminal2 is other.<br />B: Criminal1 is other. Criminal2 is Oliver.<br />C: Criminal1 is other. Criminal2 is other.<br /><br />I then attempt to solve it using thinkbayes.Suite approach.<br /><br />def bloodTraceProblem():<br /> '''<br /> Two people have left traces of their own blood at the scene of a crime. <br /> <br /> A suspect, Oliver, is tested and found to have type O blood. <br /> <br /> The blood groups of the two traces are found to be of type O <br /> (a common type in the local population, having frequency 60%) <br /> and of type AB (a rare type, with frequency 1%). <br /> <br /> Do these data (the blood types found at the scene) give evidence <br /> in favour of the proposition that Oliver was one of <br /> the two people whose blood was found at the scene?<br /> <br /> We define 3 propositions,<br /> A: Criminal1 is Oliver. Criminal2 is other.<br /> B: Criminal1 is other. Criminal2 is Oliver.<br /> C: Criminal1 is other. Criminal2 is other.<br /> <br /> Data is the blood trace found at the scene<br /><br /> ''' <br /><br /> class BloodTrace(thinkbayes.Suite):<br /> <br /> def Likelihood(self, data, hypo):<br /> blood_trace = data<br /> <br /> if (hypo == 'A'):<br /> if (blood_trace == "O"):<br /> return 1 <br /> elif (blood_trace == 'AB'):<br /> return 0.01<br /> else:<br /> return (1 - 0.6 - 0.01)<br /> elif (hypo == 'B'):<br /> if (blood_trace == 'O'):<br /> return 1<br /> elif (blood_trace == 'AB'):<br /> return 0.01<br /> else:<br /> return (1 - 0.6 - 0.01)<br /> else: # hypothesis C<br /> if (blood_trace == "O"):<br /> return 0.6<br /> elif (blood_trace == 'AB'):<br /> return 0.01<br /> else:<br /> return (1 - 0.6 - 0.01)<br /> <br /> blood_trace = BloodTrace("ABC")<br /> blood_trace.Update('O')<br /> blood_trace.Update('AB')<br /><br /> blood_trace.Print()<br /> <br />The output is <br />A 0.384615384615<br />B 0.384615384615<br />C 0.230769230769<br /><br />The output is suggesting that we have better odd of solving the crime by assuming that Oliver is one of the criminal and to focus<br />all effort to find the 'AB' guy. This approach narrows the search to 1% of population rather than 60% of the population. The decision may be <br />different if we believe that there is dependency between criminal 1 and criminal 2 i.e. finding either one will increase the <br />odd of finding the other because they probably know each other.<br /><br />I will be glad to hear from you if there is any areas that I may have overlooked in my solution.Anonymoushttps://www.blogger.com/profile/16662487046759383884noreply@blogger.comtag:blogger.com,1999:blog-6894866515532737257.post-50543946909743024222014-12-13T11:05:29.084-08:002014-12-13T11:05:29.084-08:00Jaromir, thanks for your comments -- I'm glad ...Jaromir, thanks for your comments -- I'm glad this problem was worth the effort!<br /><br />I didn't actually apply Bayes's theorem in my solution; I only computed the likelihoods P(E|X) and P(E|Y). The ratio of these likelihoods is the Bayes factor, K, which indicates whether the evidence favors X or Y, and how strong it is.<br /><br />Allen Downeyhttps://www.blogger.com/profile/01633071333405221858noreply@blogger.comtag:blogger.com,1999:blog-6894866515532737257.post-21332512297249923882014-12-13T10:55:23.594-08:002014-12-13T10:55:23.594-08:00Solving this problem was a really cool experience....Solving this problem was a really cool experience. I first did not accept the idea that evidence consistent with a hypothesis can make the hypothesis less likely and agreed with gary that we need to multiply by 2 in P(E/X). Just because it lead to the intuitive conclusion that the evidence increases the probability that Oliver was one of the two people. However, I then imagined what if Oliver was AB and not 0. Multiplying by 2 would then lead to the impossible probability of 1.2. That is 2*1*0.6 instead of 2*1*0.01.<br /><br />Only then it came to me that just one sample of 0 really is a little too few should we take Oliver for granted. It was definitely worth being puzzled for a while.<br /><br />Just a minor technical issue: Since the Bayes's theorem is P(X/E) = P(X)*P(E/X) / P(E)<br />shouldn't the number 0.012 be labelled P(E) rather than P(E/Y)? Not that it makes much difference here, but it leads to some confusion as of where to plug the number in the theorem. Also imagine the same problem for a population of only say 10 people. In such a situation, P(E) would not be equal to P(E/Y) and I think what we really are interested in is P(E).<br /> Anonymoushttps://www.blogger.com/profile/11939209902309250226noreply@blogger.comtag:blogger.com,1999:blog-6894866515532737257.post-45516013698174626722014-08-21T06:43:39.037-07:002014-08-21T06:43:39.037-07:00Ok I see, total probability..., thanks!Ok I see, total probability..., thanks!Henrihttps://www.blogger.com/profile/00434803886040541009noreply@blogger.comtag:blogger.com,1999:blog-6894866515532737257.post-11022125910069703392014-08-19T11:13:41.387-07:002014-08-19T11:13:41.387-07:00I plugged the previous values into Bayes's the...I plugged the previous values into Bayes's theorem:<br /><br />P(A|E) = P(A) P(E|A) / P(E)<br /><br />Where the denominator P(E) is<br /><br />P(A) P(E|A) + P(B) P(E|B)<br /><br />All clear?Allen Downeyhttps://www.blogger.com/profile/01633071333405221858noreply@blogger.comtag:blogger.com,1999:blog-6894866515532737257.post-18779576131694968062014-08-16T23:50:06.950-07:002014-08-16T23:50:06.950-07:00Hi Allen.
In 3), you end up with:
P(A|E) = 8/54 ~...Hi Allen.<br /><br />In 3), you end up with:<br />P(A|E) = 8/54 ~ 0.15.<br /><br />How do you determine that P(E) = 0.54 ?<br />Henrihttps://www.blogger.com/profile/00434803886040541009noreply@blogger.comtag:blogger.com,1999:blog-6894866515532737257.post-46278763085072305232013-10-17T07:38:52.445-07:002013-10-17T07:38:52.445-07:00Thanks for your kind words.
Sadly, I don't ow...Thanks for your kind words.<br /><br />Sadly, I don't own that sign. According to this thread:<br /><br />http://www.quora.com/Shopping/Where-can-I-buy-the-neon-Bayes-Theorem-sign-found-in-Autonomys-Cambridge-offices<br /><br />It lives in the office of Autonomy Corp. The photo is from Wikipedia. I should have given credit and pointed to this page:<br /><br />http://en.wikipedia.org/wiki/File:Bayes%27_Theorem_MMB_01.jpgAllen Downeyhttps://www.blogger.com/profile/01633071333405221858noreply@blogger.comtag:blogger.com,1999:blog-6894866515532737257.post-35399090287430351182013-10-17T07:30:12.182-07:002013-10-17T07:30:12.182-07:00OMG, where do I get one of those neon signs? I hav...OMG, where do I get one of those neon signs? I have never wanted to own a neon sign before. Did you have it made up special?<br /><br />I have been looking over the "Think Bayes" PDF and fondly remembering the estimation and detection course that I took once upon a time at MIT. THANK YOU for writing the missing textbook for that course.Will Warehttps://www.blogger.com/profile/00852978068817644702noreply@blogger.comtag:blogger.com,1999:blog-6894866515532737257.post-48146961389554289402013-10-14T10:57:04.427-07:002013-10-14T10:57:04.427-07:00Odd, isn't it? I suspect that the three number...Odd, isn't it? I suspect that the three numbers in the Wikipedia quote come from different sources, because they are not quite consistent with each other. But since 0.2% is reported with only one significant digit, the result of your division (10.5%) has only one sig fig as well. And at that level of precision, 10.5 and 8 are equal.Allen Downeyhttps://www.blogger.com/profile/01633071333405221858noreply@blogger.comtag:blogger.com,1999:blog-6894866515532737257.post-25835978990355577642013-10-14T09:10:12.088-07:002013-10-14T09:10:12.088-07:00Hi, for the Elvis' twin problem:
If the perce...Hi, for the Elvis' twin problem:<br /><br />If the percentage of twins in the world pop. is:<br /> #T/#Pop = 1.9%, <br />and that the percentage of monozygotic twins over the worl pop. is:<br /> #MZT/#Pop = 0.2%<br /><br />Therefore the percentage of MZT over the number of all twins is:<br /> #MZT/#T= #MZT/#Pop*(#Pop/#MZT) = 0.2/1.9 = 0.105 = 10.5%<br /><br />Am I wrong ? Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6894866515532737257.post-9279695986299625182013-09-30T16:50:10.665-07:002013-09-30T16:50:10.665-07:00Yes. And thanks for your patience!
I think we ar...Yes. And thanks for your patience!<br /><br />I think we are on the same page. And (to hopefully further clarify) the "full solution" in the case that Monty Hall behaves according to p=1 is:<br /><br />P( I win by switching | Monty Hall opens B) * P( Monty Hall opens B) + P( I win by switching | Monty Hall opens C) * P( Monty Hall opens C) = 1/2 * 2/3 + 1 * 1/3 = 2/3<br /><br />... and you've done the general p case of the first term, i.e. you've calculated P( I win by switching | Monty Hall Opens B)<br /> <br /><br />Thanks!!!<br />Kenhttps://www.blogger.com/profile/14301948556610691552noreply@blogger.comtag:blogger.com,1999:blog-6894866515532737257.post-13114652666366703992013-09-30T16:25:50.689-07:002013-09-30T16:25:50.689-07:00Good, we are agreeing now. As you say, the probab...Good, we are agreeing now. As you say, the probability I report is for the case where Monty opens Door B, because that's what the question asks.Allen Downeyhttps://www.blogger.com/profile/01633071333405221858noreply@blogger.comtag:blogger.com,1999:blog-6894866515532737257.post-88250999544230604942013-09-30T16:18:50.605-07:002013-09-30T16:18:50.605-07:00I'm pretty sure that is not correct. Consider...I'm pretty sure that is not correct. Consider the python code I posted in my first post. This simulates draws from the game:<br /><br />1. Car is randomly put behind door 1, 2, or 3.<br />2. I pick door 1<br />3. Monty Hall operates with p=1. i.e. He picks door 2 if he can (it doesn't have a car). Otherwise Monty picks door 3.<br />4. I switch from door 1 to the door that Monty hall didn't open.<br /><br />The result is I win 2/3rds of the time.<br /><br />The probability you calculated (with the p=1 case), is the probability that I win by switching if Monte hall opens Door B (and it's not there) [50%].<br />Kenhttps://www.blogger.com/profile/14301948556610691552noreply@blogger.comtag:blogger.com,1999:blog-6894866515532737257.post-54688787955621725142013-09-30T15:39:17.067-07:002013-09-30T15:39:17.067-07:00Ah, yes. I think you have identified the point of...Ah, yes. I think you have identified the point of confusion. Your analysis is correct before Monty opens a door. But after Monty opens a door you have more information, and the question asks specifically about the case where Monty opens door B. In that case, your chance of winning is 2/3 only if p=1/2. For other values of p, your chance of winning might be as low as 1/2 or as high as 1.Allen Downeyhttps://www.blogger.com/profile/01633071333405221858noreply@blogger.comtag:blogger.com,1999:blog-6894866515532737257.post-37950410766758947042013-09-30T15:30:42.871-07:002013-09-30T15:30:42.871-07:00Thanks!
I was mainly trying to point out what mig...Thanks!<br /><br />I was mainly trying to point out what might be some common confusion. Specifically the strategy of "Choosing Door A and Switching" will win 2/3rds of the time. This is what seems contrary to your statement of the solution. Specifically, it does not matter what Monty Hall does.<br /> <br />i.e. Assuming that the car is randomly behind door A,B, or C:<br /><br />The strategy:<br />1. Pick Door A.<br />2. Whatever Monty Hall shows, change from Door A to the remaining door.<br /><br />The above strategy will win 2/3rds of the time and is _independent_ of p. i.e. Monty Hall could have p=1 and always open Door B if there isn't a car behind. The code (poorly indented as it is) shows why. It underscores that the original choice (Door A) is wrong 2/3rds of the time and, thus, switching is necessarily right 2/3rds of the time and this is independent of Monty Hall's choice of doors (as long has he doesn't open the door with a car ...).<br />Kenhttps://www.blogger.com/profile/14301948556610691552noreply@blogger.comtag:blogger.com,1999:blog-6894866515532737257.post-43688114064730202562013-09-30T12:25:00.163-07:002013-09-30T12:25:00.163-07:00Hi Ken, You are right, I did not answer the full ...Hi Ken, You are right, I did not answer the full problem. There are three steps: (1) what is P(A|E)? (2) what should you do? (3) assuming you do the right thing, what is your chance of winning? I only solved (1) and left the rest to the reader. As you said, the answer to (2) is that it is to your advantage to switch, except when p=1 (in which case it doesn't matter). But the answer to (3) depends on p. For example, when p=0 and Monty opens door B, switching to C wins 100% of the time.Allen Downeyhttps://www.blogger.com/profile/01633071333405221858noreply@blogger.comtag:blogger.com,1999:blog-6894866515532737257.post-16519222685268842992013-09-30T10:34:54.460-07:002013-09-30T10:34:54.460-07:00Apologies about not being able to figure out how t...Apologies about not being able to figure out how to get the whitespace right in the above post. Also apologies that I didn't make it clear that door==1 is A, door==2 is B, etc.<br /><br />In the end there are two comments:<br />1. If the "full problem" is the game where I choose door A and Monty chooses B if possible (i.e. there isn't a goat there) and C otherwise (p=1 case), the answer is that switching still wins 2/3rds of the time. Short answer is that my original choice is right only 1/3rd of the time, and the switching strategy is successful 2/3rds of the time.<br />2. My comment about "wrong interpretation" is that I think your calculation is correct at calculating the probability that the car is behind door A if Monty opens door B (and it's not there). Which is not the "full problem."<br /><br />Am I missing something?Kenhttps://www.blogger.com/profile/14301948556610691552noreply@blogger.comtag:blogger.com,1999:blog-6894866515532737257.post-10525154041304942432013-09-30T10:01:17.969-07:002013-09-30T10:01:17.969-07:00I think what chokurdak khem is pointing out is tha...I think what chokurdak khem is pointing out is that your math isn't wrong, your interpretation of the math is wrong. Either that, or I've misunderstood what the problem is.<br /><br />Consider the following simple python code which gives a monte-carlo solution with p=1. Once you look at that, you'll see that the "full result" is independent of p:<br /><br />import numpy as np<br />trials = 100000<br />(winsbyswitch, winsbynotswitch) = (0, 0)<br />for door in np.random.randint(1,4,trials):<br /> if door==2: # monte opens door 3 and switching wins<br /> winsbyswitch=winsbyswitch+1<br /> if door==1: # monte opens door 2 and not switching wins<br /> winsbynotswitch=winsbynotswitch+1<br /> if door==3: # monte opens door 2 and switching wins<br /> winsbyswitch=winsbyswitch+1<br />print "Wins by switch: ",float(winsbyswitch)/float(trials)<br />print "Wins by notswitch: ",float(winsbynotswitch)/float(trials)<br />Kenhttps://www.blogger.com/profile/14301948556610691552noreply@blogger.comtag:blogger.com,1999:blog-6894866515532737257.post-4752609929444846362013-09-19T07:53:40.524-07:002013-09-19T07:53:40.524-07:00You are correct! I will make that correction in t...You are correct! I will make that correction in the article.Allen Downeyhttps://www.blogger.com/profile/01633071333405221858noreply@blogger.comtag:blogger.com,1999:blog-6894866515532737257.post-60805602627158540212013-09-19T07:47:39.447-07:002013-09-19T07:47:39.447-07:00I added some explanatory text to the article. Ple...I added some explanatory text to the article. Please let me know if it answers your question.Allen Downeyhttps://www.blogger.com/profile/01633071333405221858noreply@blogger.com