# Integration problem in Bayes factor calculation for multinomial model

This is one integration problem I encountered during the calculation of Bayes factor between two models given data $D$

One of the model, $M_0$ assumes the data accords to multinomial distribution, with the parameter $(\theta_1, \theta_2, \dots, \theta_k)$ and $\sum_{i=1}^k\theta_i= 1$.

Also we assume Dirichlet distribution for the prior, $\mathrm{Dir}(\alpha_1, \alpha_2, \dots,\alpha_k)$.

Now we want to calculate the marginal posterior $\mathrm{P}(D|M_0)$, which is proportional to

$\int_0^1(\prod_{i=1}^k \theta_i^{n_i + \alpha_i - 1}) \mathrm{d}(\theta_1\theta_2\dots \theta_k)$

I am stuck here, how to calculate this integral, which is subject to $\sum_{i=1}^k\theta_i= 1$?

Since the Dirichlet prior is conjugate to the multinomial likelihood, the posterior distribution is also a Dirichlet. Thus, a simple way to find a solution to your integral is to match it up against the definition of the Dirichlet distribution, $$p(\boldsymbol{x}|\boldsymbol{\alpha}) = \frac{1}{\mathrm{B}(\boldsymbol{\alpha})}\prod_{i=1}^Kx_i^{\alpha_i-1},$$ where $\mathrm{B}(\cdot)$ is the multinomial beta function. Because the Dirichlet integrates to one (on the simplex), you can see that the solution to your integral is $\mathrm{B}(\boldsymbol{\alpha}+\boldsymbol{n})$.