# Confusion in integration

I was referring to this video lecture related to Bayesian estimation and I came across this equation

$$P(X)=\int_{\theta}P(X|\theta)*P(\theta)$$

where $P(\theta)$ is the prior, and $P(X|\theta)$ is the likelihood.

The prior follows a Dirichlet distribution. Basically the likelihood is given by the binomial distribution $$P(X=x_i)= \frac{1}{Z}\int_{\theta}{\theta_i*\prod_{j}\theta_j^{\alpha_j-1}d\theta}$$

$$=\frac{\alpha_i}{\sum_{j}{\alpha_j}}$$

I didn't get how the last expression was derived. Further I didn't get how the partition function Z is moved out of the integral. I mean it is the normalizer for the Dirichlet distribution. Why is it moved out of the integral in the first place?

-