Question 2 a. Show that, for the exponential model with gamma prior, the posterior Π(9121m) under...
Question 2 a. Show that, for the exponential model with gamma prior, the posterior Π(9121m) under n observations can be computed as the posterior given a single observation xn using the prior q(の는 1101r1:n-1). Give the formula for the parameters (an,ßn) of the posterior ll(θ|X1:n, α0,Ao) as a function of (an-1, Bn-1). b. Visualize the gradual change of shape of the posterior II(01:n, ao, Bo) with increasing n: . Generate n 256 exponentially distributed samples with parameter θ-1. . Use the values ao -2, βο 0.2 for the hyperparameters of the prior. . Visualize the updated posterior distribution after n--{4,8, 16, 256), in the range θ e [0,4]. Plot all curves into the same figure and label each curve. Hint: The gamma function Г, which occurs in the definition of the gamma density, is implemented in R as gamma. When you have to compute a product over several data points, you might run into numerical problems with this function. One possible workaround to first compute the log-likelihood and then take its exponential exp(log(p(ziI:n; a, B))). The logarithm of the gamma function is implemented in R as a separate function lgamma. . Comment on the behavior of the posterior distribution as n increases.