Scaled inverse chi-squared distribution (source code)

= Scaled inverse chi-squared distribution
{title2=$\operatorname{Inv}\text{-}\chi^2(\nu,b^2)$}
{wiki}

For parameters $\nu>0$ and $b^2>0$, the <Scaled inverse chi-squared distribution> is the law of
$$
X=\frac{\nu b^2}{Q},\qquad Q\sim\chi_\nu^2.
$$
The inverse <change of variables> $q=\nu b^2/x$ gives its normalized <probability density function>[density]
$$
f_X(x)=\frac{(\nu b^2/2)^{\nu/2}}{\Gamma(\nu/2)}x^{-(\nu/2+1)}
\exp\left(-\frac{\nu b^2}{2x}\right),\qquad x>0.
$$
It is an <Inverse-gamma distribution> with shape $\nu/2$ and scale $\nu b^2/2$. The label $b^2$ is a scale parameter, not the <variance> of $X$.

Its <mean> is $\nu b^2/(\nu-2)$ for $\nu>2$, and its <variance> is $2\nu^2b^4/[(\nu-2)^2(\nu-4)]$ for $\nu>4$. Below those respective thresholds the positive <moments> diverge. For example, $\nu=6,b^2=2$ gives <mean> three and <variance> nine.

This is a <conjugate prior> for the unknown <variance> of a <Normal distribution> with known <mean> $\mu$. With prior parameters $\nu_0,b_0^2$ and $n$ <independent> observations, the posterior has $\nu_n=\nu_0+n$ and $b_n^2=[\nu_0b_0^2+\sum_i(x_i-\mu)^2]/\nu_n$. Multiplying prior and <likelihood function>[likelihood] adds their powers and inverse-variance exponents, which proves the update. An unknown estimated <mean> requires a separate model and changes the update.