Monday, February 25, 2013

AWK, Gauss and Coin Toss

Hi all,

It has been ages. We have moved out of college, and are living in different places. So, no more regular night long discussion about random stuffs. Things were getting awkward and I am trying to get them back to normal. Now, I don't remember whether I read it somewhere, or my friend told me about it, or my friend told me about reading it somewhere. However, I do remember that hidden within nature is Normal or Gaussian Distribution.

A normal distribution curve looks something like what you see in the image here ->

If you want to know a lot more about Gaussian distribution, go here. If you want to know more about the church, go here.

Imagine that you toss an unbiased coin 10 times and increase counter by 1 when head. Record the net value of the counter. Repeat the game 100 times. Plot the frequency of each of the records. You get a bell-curve.

Few days back, I was reading about awk. I needed some problem to try, neither easy, nor hard. The above simulation seemed to be the perfect fit (awk isn't meant to be used for such problems usually).

Following is the output and code: