## Tuesday, February 24, 2015

### Simulations Are More Fun

One of my favorite computer science teachers, Judy Hromcik from Texas, posted a link to a video called “The last banana: A thought experiment in probability.” The video outlines a particular statistical problem.

“Imagine a game played with two players and two dice: if the biggest number rolled is one, two, three, or four, player 1 wins. If the biggest number rolled is five or six, player 2 wins. Who has the best probability of winning the game?”

The video outlines several ways to determine who has the best chance of winning. There are several ways including logic diagrams which are interesting and perhaps even fun. For me, programming geek that I am, creating a Monte Carlo simulations seems like the most fun way. Judy is thinking about using this with her students and I’m thinking about using it with mine as well.

I’m looking forward to discussions with students about the results. The first couple of times I ran the simulation I did so with small iterations (36 simulated rolls) and the results were not always what I expected. Player One won more than Player Two in several cases. This is well within the realm of possibility of course. Probability is not certainty. Larger numbers of iterations came a lot closer to the theoretical ratio of winners. This is also expected. I think the next improvement to the program is to show the percentages for each player as well as the raw numbers BTW. Theoretically Player Two should win 56% of the time.

I think simulations are fun but I also wonder if they might help students picture the results better than looking at a strictly mathematical look at the probabilities.

Back in college I took a number of courses in statistics (I was originally a sociology major) and I got tired of doing the arithmetic. The math was fun but doing the calculations was tedious. So I did the only logical thing – I wrote programs to do the arithmetic. Do this really helped me focus on the math, the algorithms, and save time doing the arithmetic. So some people the math is enough. Some of us like to see things in a different way.

Anyone out there teach statistics? Do you have students run (or better yet program) simulations as part of the course? Does it work for your students?

Garth said...

I teach stats and programming but never the twain shall meet. I tried it many years ago and the time required to teach the stats kids enough programming to be useful was too much. I have done simulations with the programming kids but there are just too many more interesting projects out there that will teach programming. I do have the programmers do a series assignment (compute cos, pi, and others) because it does such a good job of teaching iteration. That still pushes the limit of programming boredom.

An interesting computer simulation I used to do is the Buffon’s needle approximation of pi. Of course now that I remember doing it, I cannot remember how I did it. New project! (Sort of.)

Anonymous said...

Looks like a great project for the freshmen. Loops, local v. global variables, plus a little stats to boot!

Managed NOC said...

I have done simulations with the programming kids but there are just too many more interesting projects out there that will teach programming.

Mike Zamansky said...

That's why I love NetLogo as one of the tools I use in my intro course. By it's nature it's a modelling / simulation tool so we can do all sorts of great CS while exploring topics in other subject areas.