Simulating dice throws in R

[This article was first published on biologyforfun » R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

I am currently following a course on probability theory in coursera (https://www.coursera.org/course/probas) and I’ve seen some graphs concerning the outcome of some dice throws. Being an R-nerd I wrote a little function to do this in R. This is nothing fancy just I find it interesting the process of thoughts going from a real-world problem (100 throws of two dice) to some code and graphs (histogramms of the empirical and theoretical results of the sum of the two dice).

Here is the problem: We throw two six-faced fair dice a certain number of times and we compute the sum of their values, we want to compare the theoretical expectations with empirical ones as we are varying the number of times dice are thrown.

The code can be found here: http://rpubs.com/Lionel/11497

And just as a teaser here is one of the figure we can get from it

dice


Filed under: R and Stat Tagged: Probability, R

To leave a comment for the author, please follow the link and comment on their blog: biologyforfun » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)