Is there a python datatype that includes numerical error bars?
For example,
: a = 3.00 ± 0.100
: b = 4.00 ± 0.100
: b + a
>> 7.00 ± 0.141
Where √(0.1^2 + 0.1^2) = 0.141
I figured since imaginary numbers already exist in a form something like this a= 3 + j4
, maybe there is a module that handles error analysis for you as well. (I suppose it's complicated by the fact that the + & - uncertainties need not be equal.)
Yes. There is a package called uncertainties.
Install it: sudo pip install uncertainties
Example:
from uncertainties import ufloat_fromstr
x = ufloat_fromstr("0.20+/-0.01")
square = x**2
print square
For more info: https://pythonhosted.org/uncertainties/user_guide.html