Get startedGet started for free

Towards grid approximation

Congratulations! You have just been hired as a data analyst at your government's Department of Health. The cabinet is considering the purchase of a brand-new drug against a deadly and contagious virus. There are some doubts, however, regarding how effective the new drug is against the virus. You have been tasked with estimating the drug's efficacy rate, i.e. the percentage of patients cured by the drug.

An experiment was quickly set up in which 10 sick patients have been treated with the drug. Once you know how many of them are cured, you can use the binomial distribution with a cured patient being a "success" and the efficacy rate being the "probability of success". While you are waiting for the experiment's results, you decide to prepare the parameter grid.

numpy and pandas have been imported for you as np and pd, respectively.

This exercise is part of the course

Bayesian Data Analysis in Python

View Course

Exercise instructions

  • Using np.arange(), create an array of all possible numbers of patients cured (from 0 to 10) and assign it to num_patients_cured.
  • Using np.arange(), create an array of all possible values for the efficacy rate (from 0 to 1, by 0.01) and assign it to efficacy_rate.
  • Combine num_patients_cured and efficacy_rate into a DataFrame called df, listing all possible combinations of the two.
  • Assign ["num_patients_cured", "efficacy_rate"] to df's columns and print it.

Hands-on interactive exercise

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

# Create cured patients array from 1 to 10
num_patients_cured = ____

# Create efficacy rate array from 0 to 1 by 0.01
efficacy_rate = ____

# Combine the two arrays in one DataFrame
df = ____([(x, y) for x in ____ for y in ____])

# Name the columns
df.columns = ____

# Print df
print(df)
Edit and Run Code