Ask Your Question
1

Propagation of uncertainty

asked 2013-10-26 15:06:51 +0100

TobiMarg gravatar image

updated 2013-10-26 16:13:41 +0100

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=RIF(8,12)*RIF(2,4)
R.str(error_digits=2); R.lower(); R.upper(); R.center()

Which outputs:

32.?16
16.0000000000000
48.0000000000000
32.0000000000000

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:

uncertain(10,2)

(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
2

answered 2013-10-26 15:45:15 +0100

tmonteil gravatar image

updated 2013-10-26 16:06:03 +0100

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.center(), 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

Comments

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 16:19:12 +0100 )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

Stats

Asked: 2013-10-26 15:06:51 +0100

Seen: 1,073 times

Last updated: Oct 26 '13