Gaussian mixture Gibbs updates with independent priors (source code)

= Gaussian mixture Gibbs updates with independent priors
{c}
{title2=$v_i\mid\cdots\sim\operatorname{InvGamma}(\alpha+n_i/2,\beta+\tfrac12\sum_{z_j=i}(x_j-\mu_i)^2)$}

In a finite <normal distribution> mixture with allocation labels $z_j$, independently assign $\mu_i\sim N(m_0,\tau^2)$, $v_i\sim\operatorname{InvGamma}(\alpha,\beta)$ and weights a <Dirichlet distribution>. Let $n_i$ count allocations to component $i$ and $s_i$ sum their observations. The conditional mean precision is $V_i^{-1}=\tau^{-2}+n_i/v_i$, giving $\mu_i\mid\cdots\sim N(V_i(m_0/\tau^2+s_i/v_i),V_i)$. The conditional variance is the displayed <inverse-gamma distribution>; weights have Dirichlet parameters increased by allocation counts. Allocation probabilities are proportional to $\omega_i\varphi(x_j;\mu_i,v_i)$. Independence of the mean prior from $v_i$ is important: its density does not add an extra inverse-gamma shape term.