express_uncertainty
- typhon.physics.metrology.express_uncertainty(expr, aliases={}, on_failure='raise', collect_failures=None, return_sensitivities=False, return_components=False, correlated_terms=())[source]
For a sympy expression, calculate uncertainty.
Uncertainty is given in the Guides to Uncertainties and Measurements (GUM), see http://www.bipm.org/en/publications/guides/gum.html equations 10 and 13.
This takes all free symbols. If you have IndexedBase symbols, you may want to pass them into aliases {free_symbol: indexed_base_symbol[index]} is this is not identified automatically.
- Parameters:
expr (Expr) – Expression for which to calculate uncertainty
aliases (Mapping) – Mapping of replacements to apply prior.
on_failure (str) – Signals what to do when some variables cannot be differentiated against. This appears to be the case for indexed quantities (see https://github.com/sympy/sympy/issues/12191). Default is ‘raise’, but can set to ‘warn’ instead.
collect_failures (set) – Pass in a set object where failures will be collected, assuming on_failure is ‘warn’.
return_sensitivities (boolean) – If True, return dictionary with sensitivity coefficients (as expressions). Defaults to False.
return_components (boolean) – If True, return dictionary with component of evaluated uncertainty per argument/effect. Only considers uncorrelated part (which is the only thing implemented so far anyway).
correlated_terms (Sequence[Symbol]) – Sequence of symbols for which covariances will be included in the expression. Passing a sequence with less than two elements means no covariances are considered.
- Returns:
Expression indicating uncertainty