Earlier I develop a handy-dandy little algorithm for combining two uncertain values in the form x_{1} ± u_{1} and x_{2} ± u_{2}. The code presumes that the four values are ready to be popped off the stack:

float u2 = boundedInverseTransform(pop());

float x2 = boundedInverseTransform(pop());

float u1 = boundedInverseTransform(pop());

float x1 = boundedInverseTransform(pop());

push(boundedTransform((float)Math.sqrt(u1*u1 + u2*u2))); // uncertainty value

push(boundedTransform((x1+(u1*x2)/u2)/(1 + (u1/u2)))); // new mean value

This is not giving me good results: after some testing, I realized that it’s off. So let’s re-derive it right now:

In this diagram, x_{1} is the mean of one value, with uncertainty u_{1}, and x_{2} and u_{2} play the same roles for the second distribution. Our goal is to find x_{3}, the point that is equidistant from the two mean values, as measured in standard deviations (the u values). From this diagram, it really is easy to see the answer. The topmost horizontal line, whose length is x_{2} - x_{1}. To do this, we just have to stretch the sum of u_{1} and u_{2} to equal the size of x_{2} - x_{1}. Thus, we have:

x_{3} - x_{1} = u_{1 }* [(x_{2} - x_{1}) / (u_{1} + u_{2})]

with a final result:

x_{3} = u_{1}_{ }* [(x_{2} - x_{1}) / (u_{1} + u_{2})] + x_{1}

which produces this line of code:

push(boundedTransform((x1+(u1*((x2-x1)/(u1+u2))));

But this didn’t work, either. After much screwing around, I realized that the problem lay not in this code but instead in one of the parameters fed into it: one of the uncertainty values was negative. That’s a serious no-no, and completely screwed up the calculation.

One other thing: the original form of the code was also correct; it merely represents a different expression of the same formula.