Solution (source code)

= Solution

Assume $S_{xx}=\sum_i x_i^2>0$, so the slope in this <linear regression through the origin> is identifiable. Expanding the residual sum of squares gives
$$
\sum_i(Y_i-bx_i)^2=\sum_iY_i^2-2b\sum_i x_iY_i+b^2S_{xx}.
$$
Differentiation gives the unique <least-squares estimator> and its <normal distribution>:
$$
\boxed{\widehat\beta=\frac{\sum_i x_iY_i}{S_{xx}},\qquad
\widehat\beta\sim N\left(\beta,\frac{\sigma^2}{S_{xx}}\right).}
$$
For $n\ge2$, estimate the unknown variance by
$$
s^2=\frac1{n-1}\sum_i(Y_i-\widehat\beta x_i)^2.
$$
The fitted component and orthogonal residual of the <Gaussian vector> are independent, and $(n-1)s^2/\sigma^2$ has the <chi-squared distribution> with $n-1$ degrees of freedom. Under the null hypothesis,
$$
T=\frac{(\widehat\beta-\beta_0)\sqrt{S_{xx}}}{s}\sim t_{n-1}.
$$
The <Student t test for regression through the origin> rejects at significance level $\alpha$ when \b[$|T|>t_{n-1,1-\alpha/2}$], where the subscript denotes the corresponding quantile of <Student's t-distribution>. If all $x_i=0$, the data contain no information about $\beta$; if $n=1$, no residual degree of freedom is available for this unknown-variance test.