Here we solve the curve fitting problem presented in Sec.~\ref{sec:curve_fitting} using of Bayesian statistical inference. Given some data $d$ and a model $\mathcal{M}$, Bayesian parameter estimation involves computing the posterior distribution of the parameters $\theta$ describing the model. Using Bayes theorem, we can write
where $p(\theta | \mathcal{M})$ is the prior distribution of the parameters $\theta$, $p(d | \theta , \mathcal{M})$ is the likelihood of data given the parameters $\theta$ and the model $\mathcal{M}$, while
is the evidence of the model $\mathcal{M}$. Bayesian model selection involves comparing the evidence of different models, say $\mathcal{M}_1$ and $\mathcal{M}_2$, by means of the likelihood ratio (Bayes factor) between the two models.
\item Compute the posterior distribution $p(H_0 | d, \mathcal{M}_1)$ of the Hubble constant $H_0$ using the Supernova Cosmology project data $z \leq0.1$. Assume the Hubble's law [Eq.\eqref{eq:Hubble_law}] as the model $\mathcal{M}_1$. Assume uniform prior for $H_0$ in the interval $(10, 100)$ km/s/Mpc.
\item Repeat the analysis using the full data set. What are the differences that you see in the posterior?
\item Compute the posterior distribution $p(H_0, \Omega_M | d, \mathcal{M}_2)$ of the Hubble constant $H_0$ and matter density $\Omega_M$ using the $\Lambda$CDM model $\mathcal{M}_2$ [Eq.\eqref{eq:lcdm}]. You can compute the posterior on a 2-dimensional grid. Assume uniform priors for $H_0$ in the interval $(10, 100)$ km/s/Mpc and for $\Omega_M$ in the interval (0, 1).
\item Compute the likelihood ratio (Bayes factor) between the Hubble's law and $\Lambda$CDM model by computing the evidences [Eq.\ref{eq:evidence}] of the two models using a numerical integration method that we learned in Sec.~\ref{sec:integr}.