Exercise

Simulating posterior draws

You have just decided to use a Beta(5, 2) prior for the efficacy rate. You are also using the binomial distribution to model the data (curing a sick patient is a "success", remember?). Since the beta distribution is a conjugate prior for the binomial likelihood, you can simply simulate the posterior!

You know that if the prior is \(Beta(a, b)\), then the posterior is \(Beta(x, y)\), with:

\(x = NumberOfSuccesses + a\),

\(y = NumberOfObservations - NumberOfSuccesses + b\).

Can you simulate the posterior distribution? Recall that altogether you have data on 22 patients, 19 of whom have been cured. numpy and seaborn have been imported for you as np and sns, respectively.

Instructions

100 XP
  • Assign the numbers of patients treated and cured to num_patients_treated and num_patients_cured, respectively.
  • Use the appropriate numpy function to sample from the posterior distribution and assign the result to posterior_draws.
  • Plot the posterior distribution using the appropriate seaborn function.