JuliaPhysics / Measurements.jl

Error propagation calculator and library for physical measurements. It supports real and complex numbers with uncertainty, arbitrary precision calculations, operations with arrays, and numerical integration.
https://juliaphysics.github.io/Measurements.jl/stable/
MIT License
488 stars 37 forks source link

deal with floating point uncertainty in measurement("123.4(2.1)") #44

Closed alusiani closed 5 years ago

alusiani commented 5 years ago

Measurements.jl provides an useful converssion from a string with a value and uncertainty, in the form "val(unc)" to a measurement. Currently, the uncertainty must be an integer.

Some papers report measurements with fixed point uncertainties, for instance one of the most precise Physics measurements, the muon g-2 anomaly, is reported as 11659208.0(6.3)e-10.

Could such a functionality be implemented? I could try to work on it when in some undetermined future I could find the time.

giordano commented 5 years ago

My understanding is that the meaning of this writing is "whatever is within parentheses is the uncertainties", rather than "the uncertainty on the last digits", is this correct? So "11659208.0(6.3)e-10" is actually equal to (and one character longer than) "11659208.0(63)e-10", right?

alusiani commented 5 years ago

My understanding is that the meaning of this writing is "whatever is within parentheses is the uncertainties", rather than "the uncertainty on the last digits", is this correct? So "11659208.0(6.3)e-10" is actually equal to (and one character longer than) "11659208.0(63)e-10", right?

11659208.0(6.3)e-10 means 11659208.0e-10 +- 00000006.3e-10

so the "6.3" replaces the corresponding "8.0" in the value, and all previous digits of the value are zeroed, to determine the uncertainty.

Indeed I see that measurement("11659208.0(63)e-10") returns the value above, i.e. the correct value and uncertainty that I would like to see for measurement("11659208.0(6.3)e-10"), which currently returns error because the string is not in the expected format.

giordano commented 5 years ago

@alusiani Could you please have a look at #45?