Boundary likelihood-ratio test for two Gaussian means (source code)

= Boundary likelihood-ratio test for two Gaussian means
{title2=$T=n[\bar Y^2+(A-\bar X)_+^2]$}

For independent unit-variance Gaussian samples with means $\mu_X,\mu_Y$, testing $\mu_X\geq A,\mu_Y=0$ against unrestricted means gives $T=-2\log\Lambda=n[\bar Y^2+(A-\bar X)_+^2]$. The unrestricted <maximum-likelihood estimators> are the two <sample means>, while the null estimators are $\max(A,\bar X)$ and zero. Under the null, write $W=\sqrt n(\bar X-A)=W_0+\delta$, $\delta=\sqrt n(\mu_X-A)\geq0$, and $Z=\sqrt n\bar Y$, with $W_0,Z$ independent standard Gaussian variables. Then $T=Z^2+(-W_0-\delta)_+^2$ decreases pointwise with $\delta$, so the largest rejection probability occurs at the boundary $\mu_X=A$. There its law is the <chi-bar-squared distribution> $\tfrac12\chi_1^2+\tfrac12\chi_2^2$. The exact size-$\alpha$ threshold $c_\alpha$ is therefore determined by $1-\Phi(\sqrt{c_\alpha})+\tfrac12e^{-c_\alpha/2}=\alpha$.