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.
1 Gamma(πΌ, π½)
π½πΌ
Ξ(πΌ)
π₯πΌβ1πβπ½π₯
Poisson(π)
. πππβπ
π!
π
π₯
βΌ Gamma(πΌ, π½)
βΌ Poisson(π)
2
πΌ = 1 π½ = 2 π π₯ 300
π₯ = [3, 10, 2, 5, 6, 7] 300 π
π₯
π₯
π₯
π₯
= [3, 10]
= [3, 10, 2, 5]
= [3, 10, 2, 5, 6, 7].
1
2

