5.2 Latent discrete parameterization
One way to parameterize a mixture model is with a latent categorical variable indicating which mixture component was responsible for the outcome. For example, consider K normal distributions with locations μk∈R and scales σk∈(0,∞). Now consider mixing them in proportion λ, where λk≥0 and ∑Kk=1λk=1 (i.e., λ lies in the unit K-simplex). For each outcome yn there is a latent variable zn in {1,…,K} with a categorical distribution parameterized by λ, zn∼categorical(λ).
The variable yn is distributed according to the parameters of the mixture component zn, yn∼normal(μz[n],σz[n]).
This model is not directly supported by Stan because it involves discrete parameters zn, but Stan can sample μ and σ by summing out the z parameter as described in the next section.