I have some numbers $X={x_1,x_2,...,x_n}$. I add some small numbers to them and get $Y={y_1,y_2,...,y_n}$ where $y_i=x_i+\epsilon_i$. How can I find $Z={z_1,z_2,...,z_n}$ to minimize $\sum_{i=1}^n(z_i-y_i)^2$ such that $\text{mean}(Z)=\text{mean}(X)$$\hat{\text{mean}}(Z)=\hat{\text{mean}}(X)$ and $\text{var}(Z)=\text{var}(X)$$\hat{\text{var}}(Z)=\hat{\text{var}}(X)$. I have solved it for the simple case of $\text{mean}(X)=0$$\hat{\text{mean}}(X)=0$ and $\text{var}(X)=1$$\hat{\text{var}}(X)=1$. However, the computation is too long for the general case. I wonder if there exist more statistical (hopefully shorter) version of the solution.
Regards
PS: $x_i\in R$