1163
Probability theory vs. intuition
I'll start this post by saying that I will build a small holivar. Consider the following problem (which may sound very familiar):
You are participating in a TV show. In the last round before you three doors, behind one is a sheep after another - a goat, and for the third - Ferrari. Do you want a Ferrari and do not want no one from cattle. Lead offers to choose the door and you point to one of the doors. Next presenter decides to open one of the two remaining doors. He selects one of them (say, flip a coin), opens it, and behind it is a sheep. Then the facilitator asks you to change your selection. Question: Based on the information available to you, does it make sense to change the selection. I>
Answer: it does not matter if you change it a choice, Ferrari equiprobably hidden behind one of the two closed doors.
If you agree with this answer, the article you feel is not very interesting. And if you disagree, you may like.
to this problem we shall return. And yes, I know that the answer to the парадокс Monty Hall - 66%.
The reason to write this article was the interesting task that I have encountered. I play Lulu Flappy Bird. And some of my friends like to play Flappy Bird. Sometimes we argue over who gets more points. The problem, however, lies in the fact that the result of a Flappy Bird not very predictable. Therefore, to fix it a bit, we argue on a series of five games. If the first game ubitsya the very first tree, there are four more to rectify the situation.
And once, when I was playing the third game of the five, and has scored 25 points, which by the standards of many of my abilities, I suddenly became an urgent need to move away. "Okay," - I said - "I am now specifically ubyus, and then I'll start from the beginning of the third game, and current points we still add to the result. This does not affect the expected number of points. "- I said. "Certainly impact," - said one - "you can then start the third game from the beginning, but the current points we have not added. This, of course, would increase the expected number of your points ».
Of course, neither I nor my friend no mathematics in the mind is not cranked, we rely on our perception of what is honest, and use the mathematical term "expected number" in intuitively true, but in fact unsubstantiated sense.
Why is the option that offers my friend (do not add points for the current game) intuitively honest - is understandable. If they do not add, I like this game and did not play. I'll play three more, just get five, and it honestly.
Why do I think that my version of honest? Well, because if I was killed, and then start a new game, it is, in principle, the same as if I did not kill, and the game continued.
But, of course, in my version I type exactly 25 points ahead of him. That is, one of them is certainly not fair. Some of us brings intuition.
Once when you first asked Monty Hall, you probably answered 50%, because it was intuitively true. Hopefully, then you make sure this is not the case. When you read the task in the beginning, you are likely to answer 66%, because you know Monty Hall, and this problem looks very similar to it. But in fact it is completely different.
Suppose I do not know the theory of probability, and I want to answer to yourself to understand some task.
One easy way to do it - is to consider what happens if the situation described in the problem occurs at the same time a large number of (eg, three millions) universes.
In the Monty Hall problem from three million universes somewhere in one million once you choose the car, and two million goats you choose. In the first million universes leading opens one of the two remaining doors, no matter what, for them both goat. In the other two millions of universes, one of the doors, behind which a goat, you've chosen, and the second leading chooses. As a result, millions of universes in the first car is still behind that door that you have chosen, and in the remaining two million - for the one you choose, so the chance to get the car without changing selection - 33%, and changing - 66% .
What is the difference in the problem at the beginning of the article? The fact that in it for one of the doors is not a goat, and sheep.
This is sarcasm, of course. The fact that in the problem of Monty Hall leading deliberately chooses a door with a goat. In the problem at the beginning of the article, he chose the door by accident, and for it in fact turned out to be a sheep i>. Consider again the three million universes. We divide them into six groups:
1. I chose the car, leading chose sheep.
2. I chose the car, leading the goat chosen.
3. I chose the goat, sheep presenter chose.
4. I chose the goat, leading the selected machines.
5. I chose a sheep, a goat leading chosen.
6. I chose the lamb leading the selected machines.
All options are equally probable, and therefore each will occur in about 500,000 universes. However, we know that in our scenario, the leading open the door, behind which hides a sheep. So, in fact, we are either in one of the universes of the first group, or in one of the universes of the third group. In all other universes, we see that the leading or opened the door with a goat, or the door of the machine. It turns out that one of the millions of universes in which we are now able to be about half the car outside our door, and in the other half of the one we choose, and the lead is not open, so it does not matter, I have a choice whether or not to change choice.
Usually, this simulation helps, but sometimes it is impossible to verify. Then always helps to write a script that simulates what is happening many times.
Nachem simulation with Monty Hall:
Hidden Text
& lt; code class = & quot; python & quot; & gt; import random x_iters = 1000000 good = 0 bad = 0 for i in range (x_iters): carIsBehind = random.randint (1, 3) doorIChose = random.randint (1, 3) doorsWithGoats = [] for i in range (1, 4): if i! = carIsBehind and i! = doorIChose: doorsWithGoats.append (i) doorHostChose = random.choice (doorsWithGoats ) doorThatIsLeft = 1 + 2 + 3 - doorIChose - doorHostChose if carIsBehind == doorIChose: good + = 1 elif carIsBehind == doorThatIsLeft: bad + = 1 else: assert False, & quot;% d% d% d & quot; % (CarIsBehind, doorIChose, doorThatIsLeft) print good, bad & lt; / code & gt; pre>
Expectedly, the result
& lt; code & gt; 333860 666140 & lt; / code & gt; pre> Now, the problem with the beginning of the article (for simplicity, remove the lamb, and assume that there are two goat):
Hidden Text
& lt; code class = & quot; python & quot; & gt; import random x_iters = 1000000 good = 0 bad = 0 for i in range (x_iters): carIsBehind = random.randint (1, 3) doorIChose = random.randint (1, 3) doorsHostCanChoose = [] for i in range (1, 4): if i! = doorIChose: doorsHostCanChoose.append (i) doorHostChose = random.choice (doorsHostCanChoose) if doorHostChose == carIsBehind: # we know this did not happen continue doorThatIsLeft = 1 + 2 + 3 - doorIChose - doorHostChose if carIsBehind == doorIChose: good + = 1 elif carIsBehind == doorThatIsLeft: bad + = 1 else: assert False, & quot;% d % d% d & quot; % (CarIsBehind, doorIChose, doorThatIsLeft) print good, bad & lt; / code & gt; pre>
Again, as expected
& lt; code & gt; 333537 332792 & lt; / code & gt; pre>
Yes, it turns out that the problem in the beginning of the article is really the answer 50%.
Let us return to the problem that I encountered while playing Flappy Bird. For a start, it is necessary to formalize. Suppose that in one game Flappy Bird - a sequence of attempts to get through the tree. Just assume that the chance to slip through any tree is the same, and is approximately 99/100. The game ends when once again slip through the tree failed. Formalize our argument a little more complicated. Let us try to formalize it so: let if in the third game, the player scored exactly 50 points, then he forcibly killed, and he is given the opportunity to play an extra game. It is necessary to understand whether you need to add these to the score 50 points to the expected number of points, compared to a scenario where the player just plays five games, has not changed. With such a formalization of the paradox described earlier in this article, is preserved:
1. It seems that if you do not count 50 points, then the player will play just five games. Expected kolichetsvo points must not differ from what would have happened if a player played just five games.
2. On the other hand, 50 moves into the player in the corresponding game is not dead, he added this game can be seen as a continuation of the game in which we are forced to have killed him. That is, adding 50 points, too, should not affect the result.
Try to simulate it in the millions of universes in the mind a bit difficult. So go straight to the approach number two - prosimuliruem both versions of Python. Obviously, if the player is not forced to kill, but just give it to play five games, then he gets about 500 points, so we'll see how far the estimates obtained from 500.
Let's start with my version, albeit 50 points are added.
Hidden Text
& lt; code class = & quot; python & quot; & gt; import random x_iters = 100000 ans = 0 def doGame (canKill): score = 0 while True: if random.randint (0, 99) == 0: break; elif score == 50 and canKill: return score, True else: score + = 1 return score, False for i in range (x_iters): addt = 0 res = 0 for i in range (5): # i is game id score , killed = doGame (canKill = (i == 3)) res + = score if killed: score, killed = doGame (canKill = False) assert not killed res + = score ans + = res print ans / x_iters & lt; / code & gt ; pre>
Run, wait a bit, we get the answer:
502
Well, okay, it's close enough. Then let them not be added
Hidden Text
& lt; code class = & quot; python & quot; & gt; import random x_iters = 100000 ans = 0 def doGame (canKill): score = 0 while True: if random.randint (0, 99) == 0: break; elif score == 50 and canKill: return score, True else: score + = 1 return score, False for i in range (x_iters): addt = 0 res = 0 for i in range (5): # i is game id score , killed = doGame (canKill = (i == 3)) if not killed: res + = score else: score, killed = doGame (canKill = False) assert not killed res + = score ans + = res print ans / x_iters & lt ; / code & gt; pre>90% 50% 42% Only registered users can vote in polls. Sign , please. 158 people have voted. 83 people abstained.
Answer:
464
It seems that I was right. Or not?
To fix the result, let's try to change the code a bit. Now we consider how those five games, where in the third game, the player was forcibly killed, and those which were not. What if, in considering leaving only five, where he was forcibly killed?
Now, in the case of adding 50 points in the third game of 550 is obtained, as in the case of not adding - 500. Now the rights of my opponent.
The difference between the two approaches is the same as the difference between the objective and the Monty Hall problem from the beginning of this post. The first approach says
"If a player kills millions of universes in the third game when gaining 50 points in it, and then they play the third game again, they are gaining an average exactly 500 points if they deduct the 50 points, and less 500, if not deduct ».
A second approach says:
"If a player kills millions of universes in the third game when gaining 50 points in it, and then they play the third game again, among those universes where they were forcibly killed, they are gaining an average more 500 points if they deduct the 50 points, and exactly 500, if not deduct ».
Since our initial argument was not formalized, and then right in some way we are both. In the end, I suggested, "Well then, let's so, we do not add the current account to the general, but I'll start again until the third game, as long as it does not type in at least 25 points," and the friend replied: "Yes, it will honestly. " Everyone is happy.
And concludes with another very old problem.
Put that likelihood that Claudia Ivanovna actually sewed diamonds in the chair is not one hundred percent, and 90 (well, anything can happen, it may come up in my old age). Whether rights were Kisa and Osya that every autopsy chair "The chances of them growing," and what was the probability that the last (still unopened) chair has a prize? I>
Correct answer - not one that is the most popular in the vote. The answer to the latter problem, rounded down to the nearest cent
Source: habrahabr.ru/post/224759/