Monthly Archives: November 2011

Monty Hall Problem – Simulation using Python

Had too much time between my flights at Frankfurt, and the old “Find and Win the Elephant/Car Behind 3 Doors” (Monty Hall problem) puzzle is easily the simplest psychology/probability/Math puzzle that bothers people. The puzzle, commonly stated is as follows:

You are a contestant on a game show, where the prize is a Mercedes Benz. You are shown 3 unmarked doors, one of which is the door to the Benz and the other 2 doors lead to nothing (or goats). You can pick a door, and if you pick the right door, you can drive away with a new Benz. Most of us can quickly agree that the probability of winning the Benz is 1/3. (The interesting variation comes next.)

The setup is the same – you are still a contestant, trying to win the Benz, and there are still 3 unmarked doors. However, in this case, the game show host, who knows the door that has the car, is trying to help you. When you pick a door, the game show host flings open one of the two doors that you did not select, and that door (as you can observe after he flings it open) does NOT lead to the car. Then, he gives you a chance to reevaluate your choice – you can keep the door that you originally selected, or to switch to the other unopened door.

The question is: Should you switch?

The subtext here is that door that you selected, has the probability of being the right door of 1/3, and of not being the right door of 2/3. If you did not select the right door initially, when you switch, you will have the right door. If you selected the right door initially, when you switch, you will have a wrong door. So, if you do switch, the probability of you getting to the right door becomes 2/3, and there is a probability of 1/3 that you leave your good door and go to a wrong door. You can choose to look at it very many different ways, and come up with many good arguments, and you can convince yourself one way or the other.

There are many answers to this problem, and one of which, which happens to be the CORRECT one is, that Yes, you should ALWAYS switch. The probability of you winning the Benz if you switch, is indeed 2/3. The probability of you winning the Benz, if you do not switch remains a rather uninteresting 1/3.

If you have had enough of the arguments, you can look at this simple Monte Carlo simulation, and observe the results yourself. Of course, no reason to trust the results without looking at the code, so please feel free to download the source code here. The simulation models two contestants – contestant 1 who always switches, and contestant 2 who never switches and sticks with the original choice.

>>> =================== RESTART ======================
Total number of times run: 100000
Win count when switching the choice: 66613
Win count when not switching the choice: 33267
>>> =================== RESTART ======================
Total number of times run: 1000000
Win count when switching the choice: 666085
Win count when not switching the choice: 333498
>>> =================== RESTART ======================
Total number of times run: 10000000
Win count when switching the choice: 6665600
Win count when not switching the choice: 3329991

It is a Monte Carlo simulation, so you can run it, and you can observe different results each time due to randomization. I do not have Python experience, so I used Python in this example so I could learn it a bit as well. If you have a different programming language that you think I should keep in mind for some other simulation, let me know.

Grading on a curve, “Yahan ka system, hi hai kharab” and Sir Ken Robinson

A generation ago, I was a student at IIT Delhi. But, I wasn’t a brilliant student. Had a fundamental disconnect with the grading process there – 12.5% of students (roughly, rounding etc) had to be given A, A-, B, B-, C, C-, D and F grades. (All grades other than F are considered passing grades). While there were some professors who deviated from that significantly (and certainly didn’t hand out F grades), that still was the suggested grading policy. That bothered me significantly. Should I hope for my friends to mess up royally, so that I can get a better grade? Should I help someone else study, and in the process, screw my own grade? Should I lend you the book so you can push me to a different color of the pie chart? Even more innocuously, should I really study hard, and in the process push you down one bit? (Really, what kind of friend am I?)

Call it the Buridan’s ass, the obstinacy of the teenage years, or give it a fancier name, but when the system bothers you, you write and sing songs like purani jeans aur guitar and repeat “yahan ka system, hi hai kharab”. Ali Haider - Purani Jeans Aur Guitar

And now, how the times have changed. Some of my students at GWU ask me, “Would you be grading on a curve?” There is optimism in their voice. The answer they are looking for is “YES!”. “Most definitely!!” “¡Cómo no!” I kind of understand that. The students who are hoping that I grade on a curve, are suggesting that their score may be lower than my “flat passing line”, so if I grade on a curve, they stand to benefit. But alas, I deny them that very easy pleasure. I remind my students that I am going to grade everyone individually, and that I am not bound to give 20% As, 40% Bs and 20% Cs etc. All of them may finish with an A. Or, all of them may finish with a B. One student’s grade is independent of how well the entire class does. The simple reason I do this is to promote goodwill among the students, and to encourage collaboration (wherever appropriate).

In the collaborative aspect, I am in extremely distinguished company. In this awesome video, Sir Ken Robinson, international adviser on education in the arts talks about how the current education system stifles creativity, rather than encouraging it.