Closing 3 numbers I have 3 numbers that physically must add up to zero.  Unfortunately, each is obtained from a noisy measurement and they don't add up exactly.  Assuming the noise is Gaussian and given 3 corresponding standard deviations (one for each number), what is the correct way to change the numbers so that they add up correctly?  It seems like the number with the smallest stdev should be moved least, etc...
It feels like a least squares problem, and I think I can do this with an optimizer like Nelder Mead or something, but a closed form solution would be very welcome.
 A: X$_1$=a$_1$+e$_1$,X$_2$=a$_2$+e$_2$, and X$_3$=a$_3$+e$_3$ where a$_1$+a$_2$+a$_3$=0.
e$_1$ has mean 0 and variance σ$_1$$^2$
e$_2$ has mean 0 and variance σ$_2$$^2$
e$_3$ has mean 0 and variance σ$_3$$^2$
X$_1$+X$_2$+X$_3$=a$_1$+a$_2$+a$_3$+e$_1$+e$_2$+e$_3$=0+e$_1$+e$_2$+e$_3$ is Gaussian
E(X$_1$+X$_2$+X$_3$)=0 Var(X$_1$+X$_2$+X$_3$)=σ$_1$$^2$+σ$_2$$^2$+σ$_3$$^2$
If you are given that X$_1$+X$_2$+X$_3$ =a ≠ 0, Set Z=X$_1$+X$_2$+X$_3$-a.  Then Z=0.
E(a)=0 and Var(a)=σ$_1$$^2$+σ$_2$$^2$+σ$_3$$^2$ and a is Gaussian. So the question is how to split a into three parts s$_1$, s$_2$, s$_3$ such that s$_1$+s$_2$+s$_3$=a where s$_i$ is the amount X$_i$ is adjusted. Assume you want to 
minimize E[(X$_1$-s$_1$)$^2$+(X$_2$-s$_2$)$^2$+(X$_3$-s$_3$)$^2$] where s$_1$+s$_2$+s$_3$=a.  The question is how to choose s$_1$, s$_2$ and s$_3$ given a.
E[(X$_1$-s$_1$)$^2$+(X$_2$-s$_2$)$^2$+(X$_3$-s$_3$)$^2$] = 
EX$_1$$^2$+E[s$_1$$^2$] + EX$_2$$^2$+E[s$_2$$^2$]+EX$_3$$^2$+E[s$_3$$^2$]=
E[s$_1$$^2$] +E[s$_2$$^2$]+E[s$_3$$^2$]=s$_1$$^2$+s$_1$$^2$+s$_3$$^2$.
Since s$_1$=a-s$_2$-s$_3$,  s$_1$$^2$+s$_1$$^2$+s$_3$$^2$=(a-s$_2$-s$_3$)$^2$+s$_2$$^2$+s$_3$$^2$
A: The correct way to change the numbers, from the maximum likelihood perspective, is to use
$$
b_1^\prime = \frac
{ a_1 b_1 ( a_2 + a_3 ) - a_2 a_3 ( b_2 + b_3 ) }
{ a_1 a_2 + a_2 a_3 + a_3 a_1 }
$$
and similarly for $b_2$ and $b_3$ where $b_i$ is the $i$th data point and $a_i$ is $1 / \sigma_i^2$ where $\sigma_i$ is $i$th standard deviation.  Wolfram alpha was used to get this closed form solution of the constrained least squares problem.
