The Three-Goats-Problem: The Solution
There is an easy way to check the forecasts: write a simulation. In APL, it is very easy and should take only minutes to write the code – here it is:
r←Make strategy;doors;hit;first;rest;opened;toBeOpened doors←1 2 3 hit←?3 ⍝ here is the car first←?3 ⍝ candidates first choice rest←doors≠hit toBeOpened←(rest/doors)~hit,first ⍝ one of them needs to be opened opened←toBeOpened[?⍴toBeOpened] ⍝ really opened by the showmaster :Select strategy :CaseList 1 'pigheaded' ⍝---candidate don't change r←hit=first :CaseList 2 'at random' ⍝---candidate choose at random r←hit=(doors~opened)[?2] :CaseList 3 'fall down' ⍝---candidate choose the other one r←hit=doors~first,opened :EndSelect
Via the right argument you can choose one of the three strategies. But to get a useful result, we need to run this program at least 10.000 times. For this we will use a defined operator:
x←type(f Loop)noof;i x←i←0 :Repeat x←x+f type :Until noof=i←i+1 x←⌊0.5+100×x÷noof
Now we can check the result of the first strategy:
1 Make Loop 10000 34
If you did expect 50%: At the moment when you as the candidate choose a door, it was a 1:3 or 33% chance. This is because the car was moved behind one of three doors.
If you later open one door, or two doors or all doors, here, in the TV studio or in China, immediately after you made your choice, one day later or one year later, all this does not change anything: at the time given it was a 1:3 chance = 33%. It is important that you agree with this, because we come back to this result later on. So think twice before contradicting
Let’s check the second strategy now: throwing a dice.
2 Make Loop 10000 51
Of course! At that moment, two doors remain, so it is a 1:2 or 50% chance.
Let’s check the last one:
3 Make Loop 10000 67
That’s where most people run into trouble, and which is predicted (=without writing a simulation) by only a very small number of people.
However, the explanation is quite simple. Remember: persisting on you original choice was a 1:3 or 33% chance. This means that the other doors together had a 2:1 chance, and since one of these doors was opened without having a car behind it, the chance of the last door must be twice of 33%.
Note that the function “Make” is optimized for readability, not for speed. However, on a modern PC even 100.000 iterations should not cause a problem.
GrahamSteer found a different way to solve the problem.
Thanks to DanBaronet, KenChakawhata, GraemeRobertson and especially PhilLast, who found the easy-to-understand final explanation after having spent hours discussing this problem.
<< The Task