    vector[K] lps = log_theta;
    for (k in 1:K)
      lps[k] += normal_lpdf(y[n] | mu[k], sigma[k]);
    target += log_sum_exp(lps);
  }
}</code></pre>
<p>The model involves <code>K</code> mixture components and <code>N</code> data
points. The mixing proportion parameter <code>theta</code> is declared to be
a unit <span class="math inline">\(K\)</span>-simplex, whereas the component location parameter <code>mu</code>
and scale parameter <code>sigma</code> are both defined to be
<code>K</code>-vectors.</p>