Ask Your Question

Propagation of uncertainty

asked 2013-10-26 08:06:51 -0600

TobiMarg gravatar image

updated 2013-10-26 09:13:41 -0600

Is there any simple method in sage to do a calculation with uncertainties? Something like this: $(10\pm2) * (3\pm1) = (30\pm18)$. Or with a more "sophisticated" formula: $(30\pm11.67)$ because of $(10 \times 3 \times \sqrt{(2/10)^2 + (1/3)^2} = 11.67)$. Both ways are taken from here, but the second way is also described on wikipedia.

To do such calculations I have already seen a method using RIF's like the following:

R.str(error_digits=2); R.lower(); R.upper();

Which outputs:


But with as one can see the center result is $32$ ($\frac{16+48}{2}$) instead of $30$ ($10*3$). Also I think it is a bit complex, because one has to calculate the upper an lower limits before, instead of a simple thing like:


(And as last point, I think result with the question mark is not very nice)

If one of my calculations is wrong please let me know, because I am new to error calculations.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2013-10-26 08:45:15 -0600

tmonteil gravatar image

updated 2013-10-26 09:06:03 -0600

Your approach with RIF is the right one.

You should understand that the product of the middles is usually not equal to the middle of the products, not every map is flat! Actually, the result $32\pm 16$ given by RIF is more accurate than your $30\pm 18$, since the interval $[16,48]$ is strictly contained in the interval $[12, 48]$, and both are valid results.

The result using the "sophisticated" formula is wrong: the smallest product between $10\pm 2$ and $3\pm 1$ is $8\times 2 = 16$, and is smaller than $30-11.67 = 18.33$. It uses a truncated Taylor estimation, so it can only be used to have a quick rough estimate of the error, not a guaranteed upper bound, see the Caveats and warnings section.

If you want to use custom functions instead of RIF defaults, you can define:

sage: uncertain = lambda value, error : RIF(value-error, value+error)
sage: value_error = lambda r : (, r.absolute_diameter()/2)

Then you can do:

sage: R = uncertain(10,2) * uncertain(3,1)
sage: value_error(R)
(32.0000000000000, 16.0000000000000)
edit flag offensive delete link more


Thank you for your answer. To the second point (wrong method/calculation): I haven't read the whole Wikipedia article, because I got it first from the other site. Thanks for pointing that out. Also your "custom functions" are really nice.

TobiMarg gravatar imageTobiMarg ( 2013-10-26 09:19:12 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2013-10-26 08:06:51 -0600

Seen: 210 times

Last updated: Oct 26 '13