Get startedGet started for free

Updating posterior belief

Well done on estimating the posterior distribution of the efficacy rate in the previous exercise! Unfortunately, due to a small data sample, this distribution is quite wide, indicating much uncertainty regarding the drug's quality. Luckily, testing of the drug continues, and a group of another 12 sick patients have been treated, 10 of whom were cured. We need to update our posterior distribution with these new data!

This is easy to do with the Bayesian approach. We simply need to run the grid approximation similarly as before, but with a different prior. We can use all our knowledge about the efficacy rate (embodied by the posterior distribution from the previous exercise) as a new prior! Then, we recompute the likelihood for the new data, and get the new posterior!

The DataFrame you created in the previous exercise, df, is available in the workspace and binom has been imported for you from scipy.stats.

This exercise is part of the course

Bayesian Data Analysis in Python

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Assign old posterior to new prior and calculate likelihood
df["new_prior"] = ____
df["new_likelihood"] = ____(df["num_patients_cured"], ____, df["efficacy_rate"])
Edit and Run Code