SAS® and R

Best of Both Worlds

Rolling the dice

leave a comment »

Over the weekend, I tried to teach my 9-year-old daughter some basic concept of probability.  And what better to start her with than examples of rolling the dice since for most of human history, probability, the formal study of the laws of chance, was used for only one thing: gambling.

First I tried to introduce the basic definition of “sample space”.  With one die, my daughter was able to determine the sample space is six, and figure out the probability of getting each is 1 out of 6.  In the beginning we actually rolled the dice together, and recorded the outcomes on a piece of paper.  But soon she got bored, and I don’t blame her.  It gets tedious and time-consuming to manually sample a process.  Also entirely possible that the dice I got are not fair, thus introducing bias into the experiment.

Thankfully with computer, it is now possible to do simulations – rolling dice thousands of times in matter of seconds.  Here are four examples of rolling the dice 1000 times, we can see at the end of the long sequence, the proportion of getting face of one is near 1/6, but it is still not exactly 1/6, which reminds us even this long sampling process is finite, and there is no guarantee that the relative frequency of an event will match the true underlying probability of it happening.

The idea of these graphs came from Dr. John K. Kruschke’s book – Doing Bayesian Data Analysis: A Tutorial with R and BUGS.


Doing Bayesian Data Analysis


Written by sasandr

May 3, 2012 at 9:41 pm

Posted in R, Stat

Tagged with , ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: