Exercise

Coin flips with prop_model

The function prop_model has been loaded into your workspace. It implements a Bayesian model that assumes that:

  • The data is a vector of successes and failures represented by 1s and 0s.
  • There is an unknown underlying proportion of success.
  • Prior to being updated with data any underlying proportion of success is equally likely.

Assume you just flipped a coin four times and the result was heads, tails, tails, heads. If you code heads as a success and tails as a failure then the following R codes runs prop_model with this data

data <- c(1, 0, 0, 1)
prop_model(data)

Instructions 1/2

undefined XP
    1
    2

The output of prop_model is a plot showing what the model learns about the underlying proportion of success from each data point in the order you entered them. At n=0 there is no data, and all the model knows is that it's equally probable that the proportion of success is anything from 0% to 100%. At n=4 all data has been added, and the model knows a little bit more.

  • Take prop_model for a spin by entering the R-code above into the script window to the right.