# Derivation of the Highest Posterior Probability in Bayesian Model Choice

In Bayesian Essentials, page 40, there's the following formula: I've tried to derive it.

$P(M=k|D=\frac{P(D|M=k)P(M=k)}{\sum_jP(D|M=j)P(M=j)}=\frac{\int P(D|\theta,M=k)P(\theta|M=k)\ d\theta \ \ P(M=k)}{\sum_jP(D|M=j)P(M=j)}=\frac{\int l_k(\theta)\pi_k(\theta)\ d\theta \ \ P(M=k)}{\sum_jP(D|M=j)P(M=j)}$

However, I'm stuck at this last step...

Any help would be appreciated.

$$\mathbb{P}^\pi(\mathfrak{M}=k|\mathscr{D}_n) = \dfrac{\mathbb{P}^\pi(\mathfrak{M}=k) \int \ell(\theta_k|\mathscr{D}_n)\pi_k(\theta_k)\,\text{d}\theta_k}{ \sum_{j=1}^J \mathbb{P}^\pi(\mathfrak{M}=j)\pi_j(\theta_j)\,\text{d}\theta_j}\,.$$ should read as $$\mathbb{P}^\pi(\mathfrak{M}=k|\mathscr{D}_n) = \dfrac{\mathbb{P}^\pi(\mathfrak{M}=k) \int \ell(\theta_k|\mathscr{D}_n)\pi_k(\theta_k)\,\text{d}\theta_k}{ \sum_{j=1}^J \mathbb{P}^\pi(\mathfrak{M}=j)\int \ell(\theta_j|\mathscr{D}_n)\pi_j(\theta_j)\,\text{d}\theta_j}\,.$$ which is also what you propose as the last equation in your question. For some reason the cut-and-paste between numerator and denominator did not work completely and we failed to spot the mistake. Apologies!