Solution (source code)

= Solution

Let $n=\sum_{\nu=1}^gn_\nu$, $\bar x_\nu=n_\nu^{-1}\sum_jx_j^{(\nu)}$ and $\bar x=n^{-1}\sum_\nu n_\nu\bar x_\nu$. Define the within-group and between-group scatter <matrices> by
$$
\boxed{W=\sum_{\nu=1}^g\sum_{j=1}^{n_\nu}(x_j^{(\nu)}-\bar x_\nu)(x_j^{(\nu)}-\bar x_\nu)^T,\qquad B=\sum_{\nu=1}^gn_\nu(\bar x_\nu-\bar x)(\bar x_\nu-\bar x)^T.}
$$
The <within-group and between-group scatter decomposition> gives total scatter $T=W+B$: in each group the residuals about $\bar x_\nu$ sum to zero, so all cross terms vanish. Under unrestricted group <means>, the <maximum-likelihood estimators> are $\widehat\mu_\nu=\bar x_\nu$ and $\widehat V=W/n$. Under the common-mean <null hypothesis>, they are $\widehat\mu=\bar x$ and $\widehat V_0=(W+B)/n$.

For either fitted scatter <matrix> $A$, substitution into the <log-likelihood> gives
$$
\ell_{\max}(A)=-\frac{np}{2}\log(2\pi)-\frac n2\log|A/n|-\frac{np}{2},
$$
since $\operatorname{tr}[(A/n)^{-1}A]=np$. Thus the maximized <likelihood ratio> is
$$
\Lambda_{\mathrm{LR}}=\frac{\sup_{H_0}L}{\sup_{H_1}L}=\left(\frac{|W|}{|W+B|}\right)^{n/2}.
$$
A <generalized likelihood-ratio test> rejects for small $\Lambda_{\mathrm{LR}}$, equivalently
$$
\boxed{\log\frac{|W+B|}{|W|}>c.}
$$
The cutoff $c$ is chosen for the desired significance level. The determinant ratio $|W|/|W+B|$ itself is the <Wilks lambda statistic>. The derivation assumes $W$ is <positive-definite>, which for continuous normal samples requires enough within-group degrees of freedom, $n-g\geq p$; singular $W$ does not support this ordinary determinant-based test without a modified model.