# Integrating a Multinomial distribution over a Dirichlet distribution

I need to compute the probability of sampling a specific vector from any multinomial generated by a Dirichlet parametrization.

Let's call the vector $\mathbf{x} = \{x_i\}, i \in K$

I need to compute $$p(\mathbf{x}|\alpha) = \int Mult_{PMF}(x, y) \, Dirichlet_{PDF}(y|\alpha)\;dy$$

Multinomial PMF is $$Mult_{PMF}(\mathbf{x}, \mathbf{p}) = B(\mathbf{x} +1) \prod_{i=1}^K p_i^{x_i} = \frac{\Gamma(\sum_{i=1}^K x_i +1)}{\prod_{i=1}^K \Gamma(x_i +1)} \prod_{i=1}^K p_i^{x_i}$$

Dirichlet PDF is $$Dirichlet_{PDF}(\mathbf{x}, \mathbf{\alpha}) = B(\mathbf{\alpha}) \prod_{i=1}^K x_i^{\alpha_i - 1} = \frac{\Gamma(\sum_{i=1}^K \alpha_i )}{\prod_{i=1}^K \Gamma(\alpha_i )} \prod_{i=1}^K x_i^{\alpha_i - 1}$$

This is what I derived

\begin{align} p(\mathbf{x}|\alpha) & = \int Mult_{PMF}(x, y) \, Dirichlet_{PDF}(y|\alpha) \; dy \\ & = \int B(\mathbf{x} + 1) \prod_{i=1}^{K}y_i^{x_i} \; B(\alpha) \prod_{i=1}^K y_i^{\alpha_i-1} \; dy \\ & = B(\mathbf{x} + 1) B(\alpha) \int \prod_{i=1}^{K}y_i^{x_i} \; \prod_{i=1}^K y_i^{\alpha_i-1} \; dy \\ & = B(\mathbf{x} + 1) B(\alpha) \int \prod_{i=1}^{K}y_i^{x_i} y_i^{\alpha_i-1} \; dy \\ & = B(\mathbf{x} + 1) B(\alpha) \int \prod_{i=1}^{K}y_i^{x_i + \alpha_i-1} \; dy \\ \end{align}

At thi point I try to bring the part inside the integral in the form of the Dirichlet

\begin{align} p(\mathbf{x}|\alpha) & = \frac{B(\mathbf{x} + 1) B(\alpha)}{B(\mathbf{x} + \alpha)} \int B(\mathbf{x} + \alpha) \prod_{i=1}^{K}y_i^{x_i + \alpha_i-1} \; dy \\ & = \frac{B(\mathbf{x} + 1) B(\alpha)}{B(\mathbf{x} + \alpha)} \int Dirichlet_{PDF}(y, \mathbf{x} + \mathbf{\alpha}) \; dy \\ & = \frac{B(\mathbf{x} + 1) B(\alpha)}{B(\mathbf{x} + \alpha)} \end{align}

I'm not sure I did all the steps correctly, as the result I obtained is pretty different from what I see online (more specifically at How to derive the Dirichlet-multinomial? )

In my result I have an additional $B(x+1)$.

Is my result correct?

Why does it differ from the one showed in the other answer?

\begin{align} \frac{B(\mathbf{x} + 1) B(\alpha)}{B(\mathbf{x} + \alpha)} & = \frac{\Gamma(\sum_i^K x_i + 1)}{\prod_i^K \Gamma(x_i + 1)} \frac{\Gamma(\sum_i^K \alpha_i)}{\prod_i^K \Gamma(\alpha_i)} \frac{\prod_i^K \Gamma(\alpha_i + x_i)}{\Gamma(\sum_i^K \alpha_i + x_i)}\\ &\\ & = \frac{(\sum_i^K x_i)!}{\prod_i^K x_i!} \frac{\Gamma(\sum_i^K \alpha_i)}{\Gamma(\sum_i^K \alpha_i + x_i)} \prod_i^K \frac{\Gamma(\alpha_i + x_i)}{\Gamma(\alpha_i)} \end{align}