Description
Exercise 1
Use the following lemma to generate samples from a distribution in pyro. Plot the resulting distribution
using sns.distplot function.
Lemma Let be independent random variables, then is a random variable with
distribution.
500 𝐵𝑖𝑛𝑜𝑚𝑖𝑎𝑙(30, 0.5)
𝑋1, … , 𝑋𝑛 𝐵𝑒𝑟𝑛𝑜𝑢𝑙𝑙𝑖(𝑝) 𝑋 = 𝑋1 + … + 𝑋𝑛
𝐵𝑖𝑛𝑜𝑚𝑖𝑎𝑙(𝑛, 𝑝)
Exercise 2
1. (theory) Consider the Gamma distribution with p.d.f.
and the Poisson distribution with p.m.f.
Given the generative model
prove that the Gamma distribution is a conjugate prior for the Poisson likelihood.
2. (code) Set the parameters of the Gamma distribution to and . Write the pyro code to sample and , extract
samples from the distributions of both random variables and plot their histograms.
3. (code) Suppose you observe some data . Plot samples from the posterior distribution of as the
number of observed data points from increases:
Section “Probability distributions” in notebook 01.
Section “Conjugate priors” in notebook 02.