Solution (source code)

= Solution

Let
$$
S_{xx}=\sum_{i=1}^n(x_i-\bar x)^2,
\qquad
S_{xy}=\sum_{i=1}^n(x_i-\bar x)(Y_i-\bar Y).
$$
Differentiating the Gaussian log-likelihood, equivalently minimizing the residual sum of squares, gives the <ordinary least squares estimators>
$$
\boxed{\hat\beta=\frac{S_{xy}}{S_{xx}},
\qquad
\hat\alpha=\bar Y-\hat\beta\bar x},
$$
assuming $S_{xx}>0$.