# CES Price Index in Melitz (2003)

I am reading Melitz (2003), and I cannot understand why the CES price index can be rewritten as an integral including $$M$$ and $$\mu(\phi)$$. I find the lecture notes by Dave Donaldson (https://dave-donaldson.com/wp-content/uploads/Lecture-3-Firm-heterogeneity-theory-I.pdf, in slide 7), and it says that:

By definition, the CES price index is given by

\begin{align*} P=\left[\int_{\omega\in \Omega} p(\omega)^{1-\sigma}d\omega\right]^{1/(1-\sigma)} \end{align*}

where $$\Omega$$ is the mass of available goods

Since all firms with productivity $$\phi$$ charge the same price $$p(\phi)$$, we can rearrange CES price index as:

$$P=\left[\int_{0}^{+\infty} p(\phi)^{1-\sigma}M\mu(\phi)d\phi\right]^{1/(1-\sigma)}$$ where $$M$$ is the mass of firms in equilibrium and $$\mu(\phi)$$ is the pdf of firm-productivity levels in equilibrium.

I cannot understand the math behind this transformation, like why there are $$M$$ and $$\mu(\phi)$$ in the new integral. Could anyone explain this to me? Thanks!

Consider a joint density $$\Lambda(\omega, \phi)$$ with $$\omega\in\Omega$$ and $$\phi\in[0,\infty)$$; and let $$f(\omega) = \int_0^{\infty} \Lambda(\omega, \phi) d\phi$$ be a marginal density of $$\omega$$. Then we could have \begin{align} \int_{\omega\in\Omega} p(\omega)^{1-\sigma} d\omega &= \int_{\omega\in\Omega} p(\omega)^{1-\sigma} \dfrac{1}{f(\omega)} f(\omega) d\omega \\[7pt] &= \int_{\omega\in\Omega} p(\omega)^{1-\sigma} \dfrac{1}{f(\omega)} \int_0^{\infty} \Lambda(\omega, \phi) d\phi d\omega \\[7pt] &= \int_0^{\infty} \int_{\omega\in\Omega} p(\omega)^{1-\sigma} \dfrac{1}{f(\omega)} \Lambda(\omega, \phi) d\omega d\phi \\[7pt] &= \int_0^{\infty} p(\phi)^{1-\sigma} M \int_{\omega\in\Omega} \Lambda(\omega, \phi) d\omega d\phi \\[7pt] &= \int_0^{\infty} p(\phi)^{1-\sigma} M \mu(\phi) d\phi. \end{align} There is nothing special, just substitutions and the Fubini's. The fourth equality, however, is using $$f(\omega) = 1/M$$ in the (stationary) equilibrium. ($$\because$$ As $$M$$ is the mass of firms, we have $$M$$ measure of goods) And from $$p(\omega)$$ to $$p(\phi)$$ is innocuous.