Looks great! How about overloading the ± operator? using Measurements
±(μ, σ) = Measurement(μ, σ) # => ± (generic function with 1 method) a = 4.5 ± 0.1 # 4.5 ± 0.1 I don't know if it's defined in other packages, but I've never seen it. On Tuesday, May 17, 2016 at 6:23:30 AM UTC-3, Mosè Giordano wrote: > > Dear all, > > I'd like to share with you my new simple package Measurements.jl > <https://github.com/giordano/Measurements.jl>, a library for propagation > of uncertainty. The package provides a new type, Measurement, that is > composed by the value and its associated error, assumed to be a standard > deviation. Then, some basic mathematical operations are redefined to > handle Measurement type and return a Measurement object with error computed > according to rules of uncertainty propagation of standard deviations. > > I started this new function because I didn't find anything like this in > http://pkg.julialang.org/ Please tell me if I missed a registered > package. Before further developing my package, I'd like to have some > comments about it and how to improve its design. The fields of Measurement > type are arbitrary in order to make the library compatible with as many > library as possible (I was thinking about compatibility with SIUnits, for > example), but operations like zero, hypot, and inv must make sense for the > field types (SIUnits misses hypot), in addition to the other mathematical > operations. > > The package, released under terms of MIT "Expat" License, isn't registered > yet, but you can check it out with > > Pkg.clone("https://github.com/giordano/Measurements.jl") > > Here are some examples taken from the README: > > using Measurements > a = Measurement(4.5, 0.1) > # => 4.5 ± 0.1 > b = Measurement(3.8, 0.4) > # => 3.8 ± 0.4 > 2a + b > # => 12.8 ± 0.4472135954999579 > a - 1.2b > # => -0.05999999999999961 ± 0.49030602688525043 > l = Measurement(0.936, 1e-3); > T = Measurement(1.942, 4e-3); > P = 4pi^2*l/T^2 > # => 9.797993213510699 ± 0.041697817535336676 > c = Constant(4) > # => 4 ± 0 > a*c > # => 18.0 ± 0.4 > sind(Measurement(94, 1.2)) > # => 0.9975640502598242 ± 0.0014609761696991563 > > Cheers, > Mosè >
