Not to be confused with Monte Carlo Simulation, this is about the so-called "Monty Hall Paradox."

In the Monty Hall game, there are three doors, one of which hides a prize. The contestant chooses one of the doors, at which time Monty opens another door with no prize behind it. Now the contestant is given an option to switch doors. The question is, "Should the contestant switch or not, or does it matter?"

Rather than agonizing over the theoretical possibilities, let's use a probability management approach and simulate it with Excel and SDXL. Let's play the game a thousand times and count the number of times a sticking strategy wins and the number of times a switching strategy wins. Then we'll know.

Here's a picture of the spreadsheet model we use to do the simulation. Column B has the calculations and column C shows the formulas used in Column B.

The calculated results in Column B are sample distributions - arrays of a thousand trials each, packed into a CSV string by the function *toCSV()*. The other SDXL functions unpack the CSV and do whatever they do using array math. Column B gives you a peek at the first few trial values.

In row two, the *rint()* function produces a thousand randomly generated integers between 1 and 3, each representing the door where the prize was put. In row 3, it's another thousand integers between 1 and 3 each representing a contestant's choice.

Monty opens a door that's not hiding a prize, reducing the game to two doors, one of which has a prize behind it.

The functions *sdEq()* and *sdNeq()* check for equality, or not, respectively. Each of Row 5's thousand trials is a 1 if the door numbers are equal, a 0 if not. This marks the wins where the contestant chooses to stick. Row 6 does the same for a choice to switch. Rows 7 and 8 use *sdSum()* to add up all the ones in each of the arrays.

The sums in B7 and B8 resolve the paradox.

Interesting.

ReplyDeleteI did a simulation for the problem as well using the random number generator and basic logical functions in excel and I got pretty much the same results. I think your simulation is more efficient though.