The previous article analyzed the classic Monty Hall problem, and finally concluded that there was a 2/3 chance of winning the replacement option. Monty Hall The problem is over, but that's not the case. In the Monty Hall problem, the moderator knew in advance which door the car was behind, and he would certainly choose the one without the car. If we change the premise a little bit, the moderator does not know in advance which door behind the car, he just casually open a door in 2 doors, and right behind this door is a goat, then what is the situation at this time? If you read the previous article, you may think without thinking that the two are exactly the same, because the host helped us out of a goat anyway! Yes, in a particular choice, the two cases are not different, but in fact the two assumptions imply that the number of samples is different. Now let's assume that the show was recorded 10,000 times before it was aired. In the first case, the host knows in advance which door the goat is in, so if there is no accident, the 10,000 recordings can be completed smoothly, as the director, we just select one time from the. So the number of samples is 10,000. But if the host does not know which door the goat is in advance, then about 3,300 times in 10,000 recordings will fail, because the host has 1/3 of the possibility of selecting the car, which is inconsistent with the requirements of the program. So eventually only about 6,700 recordings are valid. That is, the number of samples in this case has changed and changed to the original 2/3. In the previous article, we had an important conclusion: when a door is chosen, the odds of winning a will no longer change. Note that this conclusion is relative to the probability of the current number. That is to say, we choose the probability of winning a gate 1/3 is relative to 10,000 recordings. When we selected the host to the goat about 6,700 times recording alone to calculate the probability of winning a door, at this time the new chance of winning a door will change to: 1/3÷2/3 = 1/2 can still use the method of the previous article to consider the problem, but the possible situation from 3 to 6 kinds: (1) Contestants choose Goat A, host select Goat b(2) The contestant chooses goat A, the host chooses the car
(3) The contestant chooses Goat B, the host chooses goat a
(4) The contestant chooses Goat B, the host chooses the car
(5) The contestant chooses the car, the host chooses the goat a
(6) The contestants choose the car, the host chooses the Goat B 6 cases the odds are 1/6, but 2 and 42 kinds of circumstances are invalid, so whether or not change the choice, each has half of the odds will win. This is actually the result of another kind of human intervention, and we remove those parts from the results that are not eligible so that the development of things fits our expectations. This is like the human choice of species, the probability of genetic mutation in the artificial selection process is amplified, so that the breeding of offspring more in line with our expectations. On the code:
intTotaltimes = 1000000;intBingo = 0;Boolean[] boxes;intActuallytotaltimes = 0; for(inti = 0; i < totaltimes; i++) {//Loop 1 million timesboxes =New Boolean[] {false,false,false}; Boxes[random (3)] =true; intMyChoice = Random (3); intHostchoice = Random (3, MyChoice); if(Boxes[hostchoice]) {Continue; } actuallytotaltimes++; if(!Boxes[mychoice]) {Bingo++; }}return(Double) Bingo * 100/actuallytotaltimes;
Instead of just choosing a goat, the host is randomly selected in the remaining 2 doors. Actuallytotaltimes is a valid sample count, which increases only when the host is not selected by the car, so a valid sample count is only 2/3 of the total number of samples.
Full code download (including the previous section of the 2 code): Http://pan.baidu.com/s/1i3niOvF
Monty Hall Paradox (Trinity) Ultimate Analysis (supplemental) with full source code