Coin Flip Test

Thomas Ellebaek
2015-10-21

Shiny App Presentation

Introduction

As part of the course project for the coursera course Developing Data Products, by Brian Caffo, PhD, Jeff Leek, PhD, Roger D. Peng, PhD, I have created a simple Shiny application Coin Flip Test.

Try it out!

The Coin Flip Test application is published to shinyapps.io on following link CoinFlipTest.

alt text

  1. Choose how many times you want to toss the coin in the left side panel
  2. The app will the show you the result of your experiment and display whether or not the coin, statistically, can be considered fair (a fair coin will show 50% heads and 50% tails - in theory).

Code details

Tossing the coin with R, is done with the method rbinom

rbinom(n=numberOfFlips, size=1, prob = someSecretProbability)

Here is an example with prob=0.7

rbinom(n=10, size=1, prob=0.7)
 [1] 1 1 0 0 1 0 0 1 0 1

The normal approximation confidence interval for a fair coin (prob=0.5) flipped n times is calculated with following formula

ci <- 0.5 + c(1,-1)*qnorm(.025)*sqrt(0.5*(1-0.5)/n)

FAQ

  • Like what you've seen? - Don't worry, the app will be online until the end of the course, so you can enjoy it as much as you like for remainder of the course period.

  • Am I really throwing the same coin each experiment? - Yes, don't worry.

  • How fair is the coin actually? - That is confidential business insight ;)