I'm fine with the least squares derivation:
$e = Hx-z$
$e^2 = ||Hx-z||^2$
$\hat{x} = \text{argmin}(e^2)$
...
$\hat{x} = (H^TH)^{-1}H^Tz$
However, for the weighted least squares derivation, my notes introduce it like so:
$e^2 = ||R^{-1}(Hx-z)||^2$,
where R is the covariance matrix of of uncertainty of each measurement. Expanding like so:
$e^2 = (Hx-z)^TR^{-2}(Hx-z)$,
and minimising, I get:
$\hat{x} = (H^TR^{-2}H)^{-1}H^TR^{-2}z$,
where all the $R^{-2}$ should be $R^{-1}$ as shown here.
Where am I going wrong?
There is a typo in the linked version. If $e \sim N(0, R )$., then it should be $$ R^{-1/2}(Hx - z), $$ because $$ Var(R^{-1/2}(Hx - z))=R^{-1/2}Var(z)R^{-1/2}= R^{-1/2}R^{1/2}R^{1/2}R^{-1/2} =I. $$