Bayesian statistics : conjugate prior

Reminder

image.png

1. Gamma distribution

image.png

image.png

Solution

image.png

1.1. Exercices

We have, in the following a function that generates a gaussian dataset with a gamma prior distribution on the precision. We assume that :

Our aim is to find out the right precision of the distribution based on the generated dataset X

Exercice 1.

As mentioned in the course, in this case the prior and the posterior distributions follow a Gamma distribution. Let's choose $\alpha_{prior} = 1$ and $\beta_{prior} = 1$ as a starting point for our prior. Plot the pdf of this distribution. In the same graph, plot the true distribution.

Exercice 2. compute numerically $\alpha_{posterior}$ and $\beta_{posterior}$ based on $\alpha_{prior}$, $\beta_{prior}$ and one value of X (the first one for example). plot the estimated distribution along with the true distribution of the precision.

Exercice 3. compute numerically $\alpha_{posterior}$ and $\beta_{posterior}$ based on $\alpha_{prior}$, $\beta_{prior}$ and all values of X. Plot the estimated distribution along with the true distribution of the precision.

1.2. Plot's summary

2. Beta distribution

image.png

image.png

Solution

image.png

3. Gaussian distribution

image.png

TODO BEFORE THE END OF THE CLASS : +0.5 point in your final exam if it is correct

4. Advantages

5. More conjugate distributions

When the likelihood probability distribution has one of the more common distributions then its conjugate prior can be found in the table of conjugate priors on Wikipedia