Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for groups of errors (e.g. statistical and systematic) #70

Open
natfarleydev opened this issue Aug 15, 2017 · 1 comment
Open

Comments

@natfarleydev
Copy link

I propose something like the following:

import uncertainties as uc
x = uc.ufloat(1, 0.5, "x_error_name", error_group="stats")
y = uc.ufloat(-1, 0.7, "y_error_name2", error_group="syst")
z = x + y

print("z: {:L}".format(z))
print("z.std_dev: {}".format(z.std_dev)) # Acts as the independent sum in quadrature of all error groups

would print something like

z: 0 \pm 0.5 \pm 0.7
z.std_dev: 0.86023252670426

This would provide a few advantages over manually calculating separate errors including having proper error propagation for both groups independently.

Changes/improvements to syntax/methods names/etc. are welcome.

@lebigot
Copy link
Collaborator

lebigot commented Aug 15, 2017

Thanks, that's an interesting use case.

The interaction of a form like 0±0.5±0.7 with formatting is not fully trivial I guess (because the nominal value and the uncertainty use the same format, so here we would have to find a meaningful common format for three or more numbers), but it is worth investigating.

Now, what you propose should definitely be complemented by a way of specifying the order in which each group prints their uncertainty (or we don't know which error comes from where, which makes the feature less useful).

I would suggest to proceed as follows:

  1. Maybe a first attempt at providing this kind of feature would be to not go through a new format, but to provide some convenient access to each group error and let the user print them. That should be quite easy to implement.

  2. A next step could be to offer some formatting facility so that the nominal value and errors are printed in some particularly legible way (maybe like 1.234 ± 0.021 ± 0.001?).

  3. Then later a formatting option could be considered.

I am not promising anything in terms of timeline (I want to implement some speed up idea that I worked on more recently (see issue #53), and I feel that providing some deeper support for arrays is more urgent). However, adding the concept of error groups and providing some interface to them should be quite doable for external contributors: pull requests are welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants