Mixture model (source code)

= Mixture model
{title2=$f(x)=\sum_{j=1}^K\pi_jf_j(x)$}
{wiki}

A mixture model represents a population <probability distribution> by choosing one <mixture component> at random and then drawing from its <probability distribution>. For a <finite mixture model> whose <mixture components> have <probability density functions> $f_j$, the resulting <mixture distribution> has <probability density function>
$$
f(x)=\sum_{j=1}^K\pi_jf_j(x),\qquad \pi_j\geq0,\qquad \sum_{j=1}^K\pi_j=1.
$$
The <mixture weights> ensure $f\geq0$ and $\int f(x)\,dx=\sum_j\pi_j=1$. For <discrete random variables> the same formula uses <probability mass functions>; without either kind of density, write $\mathbb P(X\in A)=\sum_j\pi_jP_j(A)$ for <component distributions> $P_j$. A zero <mixture weight> makes that <mixture component> inactive.<Stan User's Guide by Stan Development Team/Finite Mixtures>[Finite Mixtures, sections Latent discrete parameterization and Summing out the responsibility parameter: nonnegative normalized weights, categorical labels, and the sum of weighted normal densities]{ref}

The <mixture components> need not occupy disjoint bins of $x$. Two <normal distributions> both have positive <probability density functions> everywhere, so the same value can plausibly come from either <mixture component>. The <Two-Gaussian mixture example> makes this overlap visible, and its <mixture responsibilities> quantify the remaining uncertainty about the <latent variable>. This is useful when a single <normal distribution> cannot represent the population's shape, but a fitted <mixture model> alone does not establish that its <mixture components> are real biological or social groups.