LoslegenKostenlos loslegen

Highest Posterior Density credible intervals

You know that reporting bare point estimates is not enough. It would be great to provide a measure of uncertainty in the drug's efficacy rate estimate, and you have all the means to do so. You decide to add the following to the memo.

The experimental results indicate that with a 90% probability the new drug's efficacy rate is between ___ and ___, and with a 95% probability it is between ___ and ___.

You will need to calculate two credible intervals: one of 90% and another of 95% probability. The drug_efficacy_posterior_draws array is still available in your workspace.

Diese Übung ist Teil des Kurses

Bayesian Data Analysis in Python

Kurs anzeigen

Anleitung zur Übung

  • Import the arviz package as az.
  • Calculate the Highest Posterior Density credible interval of 90% and assign it to ci_90.
  • Calculate the Highest Posterior Density credible interval of 95% and assign it to ci_95.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Import arviz as az
____

# Calculate HPD credible interval of 90%
ci_90 = ____.____(____, ____=____)

# Calculate HPD credible interval of 95%
ci_95 = ____

# Print the memo
print(f"The experimental results indicate that with a 90% probability \nthe new drug's efficacy rate is between {np.round(ci_90[0], 2)} and {np.round(ci_90[1], 2)}, \nand with a 95% probability it is between {np.round(ci_95[0], 2)} and {np.round(ci_95[1], 2)}.")
Code bearbeiten und ausführen