last updated: January 23, 2025

Bayesian Statistics

\CustomizeMathJax

2.5 Exercises on Chapter 2

You can find formulae for named distributions in Appendix A.

  • 2.1 This exercise provides template code for drawing several sketches of distributions, which you will find helpful in many later exercises.

    Use a computer package of your choice to complete the following questions. You will need the file 2_dist_sketching.ipynb if you use Python, or 2_dist_sketching.Rmd if you use R.

    • (a) You will find code that produces a sketch of the probability density functions of the Exp(3) and Exp(5) distributions. Modify this code to produce a sketch of the probability density functions of the Gamma(4,5) and Gamma(6,7) distributions.

    • (b) You will find code that produces a sketch of the Geometric(12) distribution. Modify this code to produce a sketch of the Bin(10,23) distribution.

    • (c) In this question we look at distributions in the form of equation (2.4).

      You will find code that produces a sketch of the discrete distribution with p.m.f. 

      P[X=x]=01P[Bin(10,p)=x]fBeta(2,3)(p)dp

      for x{0,1,,10}. Note that this distribution is the sampling distribution associated to a discrete Bayesian model with model family Bin(10,p) and prior PBeta(2,3).

      Modify this code to produce a sketch of the discrete distribution with p.m.f. 

      P[X=x]=01P[Geometric(p)=x]fBeta(12,12)(p)dp

      for x{0,1,,}.

  • 2.2 Let (X,P) be a discrete Bayesian model with model family MpGeometric(p) where p[0,1].

    We regard Mp as a model for the number of times an experiment fails before the experiment is successful. The probability of success on each try is p[0,1], which is an unknown parameter. We assume that the experiments are independent of each other.

    • (a) Write down the probability mass function P[Mp=n], and the range of this model.

    • (b) Take a prior PUniform([0,1]). Given the single data point x=5, show that the posterior distribution is given by P|{X=x}Beta(2,6).

    • (c) Use a computer package of your choice to sketch the p.d.f. of this distribution, alongside the prior distribution.

    • (d) A second Bayesian update is made using a new data point, x=9. Find the new posterior distribution and add it to your sketch from (c).

    • (e) Write down the p.m.f. of the predictive distribution, after the second update. Use a computer package of your choice to sketch it.

  • 2.3 Let (X,Λ) be a discrete Bayesian model with model family MλPoisson(λ), where λ(0,). Take the prior to be ΛExp(5). Find the distribution of the posterior Λ|{x=7} and write down the p.m.f. of the predictive distribution.

  • 2.4 Let (X,Y) be a random variable with distribution

    P[X=n,YA]=1ZAeyyn(1y)21n!dy

    for n{0,1,2,} and A(0,1), and zero otherwise.

    • (a) Find the marginal p.d.f. of Y and hence find the value of Z.

    • (b) Find the distribution of X|{Y=y}.