Cheater Die? Bayes' Theorem

This post demostrates an application of Bayes’ theorem into an R and Shiny application.

Background:

I came across an interesting probability question that required me to dust off my knowledge of Bayes’ theorem in order to solve. For me, there is no better way to understand theory than incorporating it into an application. I decided to work the probability question and model into an R/Shiny application (embedded on this page below).

The question to solve:

A casino die is loaded to roll a six 50% of the time. This is, of course, as opposed to a fair dice that would roll a six 16.7% of the time (1/6). The cheat die is included in a box of 100 dice. A gambler choses a random die from the box and procedes to roll 3 sixes in a row. What is the probabiliity that the die is the cheat?

R/Shiny App:

The Shiny app below is served from an R server. You can change the inputs on the left to update the graphical and text output.

The shiny application is embedded in an iFrame below. On some devices it may require scrolling within the iFrame. It might look better to view the app in its own browser tab by clicking here.

Source Code

Source code on GitHub

Inspiration Resources:

I came across the blog “The Chemical Statitician” by Eric Cai. He had a related post where he discussed implementing the same problem in R. This post and related code inspired the Shiny app above:

Book image

The Chemical Statistician

Eric Cai

Read Detecting Unfair Dice in Casinos with Bayes’ Theorem

Eric Cai’s post ‘Detecting Unfair Dice in Casinos with Bayes’ Theorem’ provided inspiration for this Shiny app

 

 

Last modified:15 July 2019