DMelt:Units/3 Error Propagation
Error propagation
Propagation of uncertainty (or propagation of error) is the effect of variables' uncertainties (or errors, more specifically random errors) on the uncertainty of a function based on them. Error (or uncertainty) propagation for arbitrary (analytic and non-analytic) functions are supported using several methods:
- Using a Taylor expansion
- Using a Monte Carlo simulation
Error propagation using P1D
A typical measurement contains an uncertainty. A convenient way to keep data with
errors is to use the jhplot.P1D data container.
from jhplot import * p=P1D("data with errors") p.add(1, 2, 0.5) # error on Y=2 is 0.5 p.add(2, 5, 0.9) # error on Y=5 is 0.9
When you are using the method
"oper()" of this class, the errors are automatically propagated. This applies for subtraction, division, multiplication and addition.
Error propagation
DataMelt links the Python package uncertainties, therefore, you can program with Python as usual. Run this example in the DataMelt IDE and you can see this:
from uncertainties import ufloat from uncertainties.umath import * # sin(), etc. x = ufloat(1, 0.1) # x = 1+/-0.1
This approach calculates errors using a Taylor expansion. It also can differentiate a function.
Error propagation for complex functions
In this section we describe error propagation for an arbitrary transformation using the Java classes.
![]() | No access to this part. DataMelt members can view this part after login to member area. |
Uncertainty propagation using a Monte Carlo method
Complex functions are difficult to deal with using the above approach. DataMelt includes Java classes for a Monte Carlo approach which:
- avoids any errors associated with the linearization of the model
- produces a distribution for the uncertain output as well as the mean and standard deviation.
Propagation of errors formula requires the computation of derivatives, which can be quite complicated for larger models.
The Monte Carlo approach can handle correlated parameters as well as independent parameters.
![]() | No access to this part. DataMelt members can view this part after login to member area. |
Error propagation using VisAd
The Java package VisAd contains powerful classes
visad.Real and
visad.Data to perform calculations with units and errors.
In VisAD the values of a Scalar may be either Real which is used for numeric quantities. The form of constructor for Real:
Real(double value, double error)
allows us to provide an error estimate for the value. This estimate can then be propagated through mathematical operations to provide an error estimate. Here is Java example:
import visad.Real; Real a,b,c; a = new Real(10.,1.); b = new Real(255.,10.); c = (Real) a.add(b); System.out.println("sum = "+c);
When you run this example, you still get: sum = 265.0
The VisAD default for most math operations, however, is to not propagate errors, so to make use of this, we must explicitly indicate how we want error estimate to propagate. This is done by using an alternate signature of the add method (and all other math operators):
import visad.Real; Real a,b,c; a = new Real(10.,1.); b = new Real(255.,10.); c = (Real) a.add(b, Data.NEAREST_NEIGHBOR, Data.INDEPENDENT); System.out.println("sum = "+c); System.out.println("error of sum is="+c.getError().getErrorValue());
When you run this example, you get: "sum = 265.0" and "error of sum is=10.04987562112089"
The constants supplied to the add method are the type of interpolation and the type of error propagation. In this simple case, the type of interpolation is not really relevant, but as you will see later, VisAD Data types may contain finite approximations to continuous functions and when these are combined mathematically, may need to be resampled in order to match domains.
This example shows how to define values with errors and how to perform mathematical transformation while propagating errors (independently) using Jython/Python:
![]() | No access to this part. DataMelt members can view this part after login to member area. |