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 $\hat{\text{mean}}(Z)=\hat{\text{mean}}(X)$ and $\hat{\text{var}}(Z)=\hat{\text{var}}(X)$. I have solved it for the simple case of $\hat{\text{mean}}(X)=0$ and $\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.


PS: $x_i\in R$

  • 1
    $\begingroup$ why not just set $z_i = x_i$ and then $\sum_{i=1}^n(z_i-x_i)^2=0$? $\endgroup$ – Glen_b -Reinstate Monica May 26 '13 at 8:37
  • 2
    $\begingroup$ And if that's not a suitable answer ... you might ponder what essential piece of information you omitted. $\endgroup$ – Glen_b -Reinstate Monica May 26 '13 at 8:59
  • $\begingroup$ Thank you for reply. It was a bad mistake. I edited the question. $\endgroup$ – remo May 26 '13 at 11:53

Here is how:

  • Define:


  • solving your minimization problem for the $z^*_i$'s yields:


  • transform your $z_i^*$'s back:


putting it back together


  • $\begingroup$ Thank you for your help. It is the correct answer for the problem. However, I wonder if I change the objective function to Minimize $\sum_{i=1}^n ((z_i-y_i)/y_i)^2$, can I use the same solution? $\endgroup$ – remo May 26 '13 at 12:12
  • $\begingroup$ I'm not sure the formulation you propose is the same as mine. Wouldn't dividing by $y_i$ be problematic when $y_i\approx 0$? $\endgroup$ – user603 May 26 '13 at 12:15
  • $\begingroup$ I add an exception for the case of $y_i=0$. I really need the solution. for the last problem, it took me about two days (!) to solve it (using lagrangian method). I don't want another two days for the similar case if there exist a simpler one. I hope you can help me. $\endgroup$ – remo May 26 '13 at 12:20
  • $\begingroup$ Anyway. If as you wrote in your question, you have already solved it for mean(x)=0 and var(x)=1; just use the third part of my answer to see that you have then solved it for any values of mean(x) and var(x)! $\endgroup$ – user603 May 26 '13 at 12:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.