SAS® and R

Best of Both Worlds

Rolling the dice II

leave a comment »

Continuing from the previous post, for a pair of dice, the sample space becomes a little “bigger.”  That is 36 (6X6) possible outcomes.  Again, for a third-grader, it is much more easier to display the list visually, like this:

sample space for a pair of dice

Now, what’s the probability of dots added up to 7?  By the assumption of fairness, we know that each one of those 36 outcomes is equally likely.  My daughter finally found all the combinations, and figured out the the probability is 1 out of 6 (6/36).

Two dice with seven as outcomeI heard it somewhere that smart men use math formula to solve problems, but ‘lazy’ person (layperson :-)) like me would like to use simulations with R (or other computer languages for the matter), and let the machines do what they are good at – really fast, and intense computation.  People issue commands, machines follow them.  This time, we let the machine toss two dice 1000 times, and count the numbers of getting each possible outcomes.  Notice the shape of the histogram?  That’s very close to the probability distribution of the sum of the two dice.  This pretty much illustrated the Bernoulli Theorem, which states that relative frequency of an event in a sequence of independent trials converges in probability to the probability of the event.

R has a package “TeachingDemos” that’s really useful if you want to demonstrate elementary statistical concepts.  I did all the dice simulation using the dice() function.  You can find out more here.

Advertisements

Written by sasandr

May 4, 2012 at 8:02 pm

Posted in R, Stat

Tagged with , ,

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: