Let $X $ and $Y$ be random variable with $m_{x}$ and $m_{y}$ ,varainces $\sigma^{2}_{X}$ and $\sigma^{2}_{Y}$ ,and correlation coefficient $\rho_{X,Y}$
Find the value of the constant $a$ which minimizes $E[(Y-aX)^2]$
At first,i thought i can express the $E[(Y-aX)^2]$,that is ,
$E[(Y-aX)^2]$=$B$=$E[Y^2+a^2X^2-2YaX]$=$E[Y^2]+a^2E[X^2]-2aE[XY]$,then differentiate a to find the minimum $E[(Y-aX)^2]$.
$\frac{d}{da}B$=$2aE[X^2]-2E[XY]=0$,then when $a=\frac{E[X^2]}{E[XY]}$,we can minimizes $E[(Y-aX)^2]$ ?
in the OP it says
$2aE[X^2] + 2E[XY] = 0\\a = \frac {E[X^2]}{E[XY]}$
This is inverted and should say
$2aE[X^2] + 2E[XY] = 0\\a = \frac {E[XY]}{E[X^2]}$
$\mu_X = E[X]\\ \sigma_X^2 = E[X^2] - E[X]^2\\ E[X^2] = \sigma^2_X + \mu^2_x\\ \text{cov}_{X,Y} = E[XY] - E[X]E[Y]\\ E[XY] = \text {cov}_{X,Y} + \mu_X\mu_y$
$a = \frac {E[XY]}{E[X^2]} = \frac {(\text{cov}_{X,Y} + \mu_X\mu_Y)}{(\sigma^2_X + \mu^2_X)}$