Probability and Statistics - Three Doors game and Bayes' theorem

This article first appeared in public numbers: TechFlow
 
There is a classic problem in probability theory textbooks, it has been bothering me for a long time. There were many times I thought I would like to see, over a period of time but will be confused. The problem studied probability theory, students must know, it is the famous three doors problem .
Said to be preceded by a well-known variety show in the United States, this program, there are three closed doors. There are goats behind the two, there is one stood a luxury car. Moderator will let guests make a choice, to make a choice after the guests, the host of which will open the wrong door, asking guests: Dude, you have a chance to change the selection, you have to use it?
 
How can we talk about the effect of the program, but the underlying mathematical problem is very interesting. We choose to change or do not change, how were much chance of winning it?
 
 
We analyze from intuition, we do not replace the answer should not be affected. After all, three doors there is a correct answer, the host exclusion is wrong answers, that is to say the correct answer lies in the two remaining door. Whether we choose for no change, the door is the probability of winning should be half fishes. But the book is the answer if you do not replace it, the probability of winning is one third of the replacement, then the probability of winning up to two-thirds.
 
The answer is clearly contrary to our intuition, so we are going to talk about the hidden deep mathematical principle is very necessary. In fact, this is the understanding among the conditional probability probability theory and Bayesian formula is a very important example.
 
 
 
Conditional Probability
 
Conditional probability everyone is familiar with, we will go to school in math at an early age too.
 
Simple to review, assuming that there is A, B two events in which the sample space. If A, B no association between the two events, then they are considered independent events . For example, if I drink milk this morning as the event A, I forwarded this article as the amount of more than 10 events B. Obviously these two events do not have any relevance, I do not drink milk drink will not affect the amount forwarded the article. So these two events are called independent events:
 
 
Of course, there will still be two events were related to each other circumstances, for example, I drink milk in the morning and I did not have to work late most likely related events. Because it takes time to drink milk in the morning, it is likely to affect whether or not late. At this time P (AB) and the two events are related, not simply the product.
 
 
As shown above, when two events are not independent events AB time. P (AB) AB refers to the intersection of two events, the event may be considered as the premise A B events, or events premise A, B event.
 
Probability theory on the premise probability of something happening Another thing that happens is called conditional probability, writing P (B | A).
 
We concluded earlier written formula:
 
 
This formula is derived very naturally, but use is great. Because many times the conditional probability is not intuitive, we need the help of this formula.
 
We see the classic example of a book, to consolidate it.
 
AB assume two cities, A city probability of rain is 20% probability B is the city of rain 18% probability of rain both have 12%, Will B rain, rain probability of A is also much .
 
This question is very simple, we can directly apply the formula, apparently
 
 
Then:
 
 
 
 
Full probability formula
 
 
We introduce the conditional probability when things are said with the A and B two events. But the event actually lives associated with each other and more than two, if multiple events are related to the event A, then this time the formula of what should become what it?
 
We put all the events related to the events into a group A, group called B, where n contains events. So based on previous conditional probability, we can use events to indicate A B event.
 
 
This formula is called total probability formula , the formula established on the premise that event group B and A are all events related set of events, also known as complete event group.
 
 
 
Bayes Theorem
 
 
This is the highlight of this article, Bayes' theorem is only a simple formula in the textbook:
I think we can get them above formula is derived in accordance with the conditional probability. If only so understanding is certainly true, but this can only be understood in which a very shallow layer of meaning. If only to understand this layer behind the prior, posterior probability, maximum likelihood is difficult to understand.
 
We then look at a layer of understanding, and this time, we deform the whole probability formula:
So, the event A occurs Bi conditional probability event also occurs as follows:
这个公式看起来其貌不扬,但其实说明了结果和原因之间的联系。举个很简单的例子,假设A事件是汽车报警。那么导致A事件发生的原因有很多,比如行人不小心碰撞,偷车贼来盗窃,或者是警报故障。这些导致A发生的原因的集合,就是B事件组。
 
如果有一天晚上我们听到了警报声,我们要做的其实就是要根据事件A来猜测发生事件A的原因,也即是推算P(Bi | A)。
 
因为是在晚上,所以行人碰撞的概率很低,所以大概率是因为偷车贼。这个时候,我们就需要起床查看。如果是在白天,则相反,行人碰撞的概率很高,偷车贼作案的可能性很小,我们就可以置之不理。
 
也就是说事件A是我们可以直接观测的事件,而事件B则是事件发生背后存在的原因。贝叶斯公式就是一个寻果溯因的工具,这才是贝叶斯定理真正伟大的地方。
 
在统计学当中,通常将可以直接观测的事件发生概率称为先验概率,言下之意就是我们可以直接通过实验测量的概率。而发生这个概率背后的原因称为后验概率,也就是说是我们需要通过先验概率来计算的概率。最大似然估计,就是根据后验概率的函数来计算使得发生概率最大时的参数。
 
最后,我们回到一开始的那个例子,尝试着用贝叶斯定理算出结果。
 
我们用1,2,3分别代表三扇门,显然豪车可能出现在它们当中任一扇后面。为了简化表达,我们假设嘉宾一定选择第一扇门打开,主持人打开了第二扇门。
 
我们定义ABCD四个事件,ABC三个事件分别代表三扇门后面是豪车,D事件表示主持人打开第二扇门的概率。
 
 
 
 
直觉上我们觉得
 
不过我们并不确定。没关系,我们可以来推算一下。
 
首先:
 
 
 
这点也很容易看出来。因为如果奖品出现在第二扇门后面,主持人一定不会打开第二扇门,所以 P(D|B)=0 。同理,如果奖品在第三扇门后面,主持人一定打开第二扇。所以P(D|C)=1 。
 
代入,可以算出来:
 
接下来,我们要算的是 P(A|D) 和 P(C|D) 。
 
根据贝叶斯定理:
 
 
 
通过种种计算,我们终于得到了正确的结果。但是即使我们理解了贝叶斯原理,理解了这些计算过程,还是解答不了我们心中的疑惑,为什么这和我们的直观感受不一样呢?为什么答案不是1 /2?
 
这个问题其实很简单,因为我们的思维被限制了。我们只关注剩下没有打开的两扇门上了,完全忽略了开启的门带来的影响。
 
假设我们换个游戏,还是三扇门,还是一个奖品,还是随机摆放。假设某个人一次可以选择一扇或者两扇门。那么这这两个选项获奖的概率是多少?显而易见,选择两扇门的概率当然是2/ 3。这个时候,我们打开两扇门中一定是错误的那一扇,结果会发生变化吗?当然也不会。
 
同样的,当主持人询问是否要更换选择的时候,其实就是问我们是要选择一扇门还是两扇门。如果我们不变更选择,就是选择了一扇门。而如果我们变更选择,其实是相当于一开始的时候选择了两扇门。两扇门当中一定有一个错误答案,将它排除并不会影响最终的结果。
 
在主持人打开那扇门之前,三者的概率是均等的。当门开了之后,我们都知道那扇门的概率发生了塌缩,塌缩成了0。它身上缩小的概率,其实并不是均等地分摊在剩下的两扇门上。理解了这一点,这个问题也就迎刃而解了。
 
程序员的数学2
概率论与数理统计(浙江大学第四版)
 
如果觉得有所收获,那就扫码关注下吧:
 

Guess you like

Origin www.cnblogs.com/techflow/p/12143076.html