1. Learn
  2. /
  3. Courses
  4. /
  5. Fundamentals of Bayesian Data Analysis in R

Exercise

Sampling from the zombie posterior

Again pars contains the data frame representing the posterior zombie IQ distribution you calculated earlier. The code to the right draws sample_indices: a sample of row numbers (a.k.a. indices) from the posterior. Now, let's sample from pars to calculate some new measures!

Instructions 1/4

undefined XP
    1
    2
    3
    4
  • Use sample_indices to create a new data frame pars_sample from pars with the columns mu and sigma drawn from the rows indicated by sample_indices.

Tip: If df is a data frame with many rows and columns here is how you would extract rows 1, 3 and 1 (again), and the columns named "height" and "weight":

df[c(1,3,1), c("height","weight")]