Posts tagged Probability

If you saw my post about the Monty Hall Problem, you know that calculating the probabilities in this puzzle, while not terrifically complicated, are nonetheless a bit frustrating to our feelings of common sense. Therefore, I decided to whip up a quick script that would simulate the Monty Hall problem in code.

It turns out that this has been done many times before, and if you head on over to rosettacode.org, you can find scripts for nearly every language you could imagine…except ColdFusion.

If you’re too lazy to click a link, however, here is the script in its entirety:

<cfscript>
function runmontyhall(num_tests) {
// number of wins when player switches after original selection
switch_wins = 0;
// number of wins when players "sticks" with original selection
stick_wins = 0;
// run all the tests
for(i=1;i<=num_tests;i++) {
// unconditioned potential for selection of each door
doors = [0,0,0];
// winning door is randomly assigned...
winner = randrange(1,3);
// ...and actualized in the array of real doors
doors[winner] = 1;
// player chooses one of three doors
choice = randrange(1,3);
do {
// More >

Consider you’re on the game show Let’s Make a Deal!. The game is simple: there are 3 doors presented to you. One of the them has a fabulous prize behind it, while the other two hide nothing but shattered dreams.

When you initially select a door, the host (Monty Hall) will reveal one of the doors which hides your shattered dreams. Because Monty knows which doors conceal what, he will always reveal one door that is empty, while always leaving 1 empty and 1 prize door.

* If you initially select the winning door, Monty will reveal an empty door.
* If you initially select an empty door, Monty will reveal the other empty door.

Left with two doors (one with the prize, the other with nothing), you have the opportunity to either stick with your initial selection, or vacillate entirely and change your mind, selecting the other remaining door.

So the question is simple: Should you stick or change?

The answer, quite counter-intuitively, is that you should most definitely change.

WHAT?? How does this make any sense? If there are two doors left, surely the probability of winning or losing is equivalent, right?

Puzzle #1: I have two children. One of my children is a boy. What is the probability that I have two boys?

Puzzle #2: I have two children. One of my children is a boy who was born on Tuesday. What is the probability that I have two boys?

Let’s tackle the first one. By sheer intuition, the average person would probably answer that the probability of the second child being a boy is 50% (I know I did the first time). After all, the population is (seemingly) roughly divided equally between males and females, so it just feels right that the answer is somewhere around 50%.

However, there is a bit of a trick in the question. The question, after all, is not actually asking about the chances that any particular, individual child is male or female. Rather, it’s asking what the probability that both children are boys is, based on the knowledge that one is a boy.

So how do we work this out? First, we need to represent all the possible arrangements of children in this scenario. Since one is already known to be a boy, the possible arrangements are:

I recently puzzled through some interesting probability riddles with some co-workers, and thought I would share. It comes in two parts (somewhat related). To allow you to work these out on your own without *accidentally* seeing the answer, I’ll simply state the riddles on this note, and provide the answers on the second

Here goes:

Puzzle #1: I have two children. One of my children is a boy. What is the probability that I have two boys?

Puzzle #2: I have two children. One of my children is a boy who was born on Tuesday. What is the probability that I have two boys?