Session Ready
Exercise

The more you toss, the more you learn

Imagine you are a frequentist (just for a day), and you've been tasked with estimating the probability of tossing heads with a (possibly biased) coin, but without observing any tosses. What would you say? It's impossible, there is no data! Then, you are allowed to flip the coin once. You get tails. What do you say now? Well, if that's all your data, you'd say the heads probability is 0%.

You can probably feel deep inside that these answers are not the best ones. But what would be better? What would a Bayesian say? Let's find out! numpy and seaborn have been imported for you as np and sns, respectively.

Instructions 1/3
undefined XP
  • 1
    • Estimate the heads probability using get_heads_prob() based on an empty list, assign the result to heads_prob_nodata and visualize it on a density plot.
    • 2
      • Do the same, this time based on a single tails (a list with a single 0) and assigning the result to heads_prob_onetails.
    • 3
      • Generate a list of 1000 tosses with a biased coin which comes up heads only 5% of all times and assign the result to biased_tosses.
      • Estimate the heads probability based on biased_tosses, assign the result to heads_prob_biased and visualize it on a density plot.