uncertainties
The uncertainties package allows calculations with values that have uncertaintes, such as (2 +/- 0.1)*2 = 4 +/- 0.2. uncertainties takes the pain and complexity out of error propagation and calculations of values with uncertainties. For more information, see https://uncertainties.readthedocs.io/
Basic examples
>>> from uncertainties import ufloat
>>> x = ufloat(2, 0.25)
>>> x
2.0+/-0.25
>>> square = x**2
>>> square
4.0+/-1.0
>>> square.nominal_value
4.0
>>> square.std_dev # Standard deviation
1.0
>>> square - x*x
0.0 # Exactly 0: correlations taken into account
>>> from uncertainties.umath import sin, cos # and many more.
>>> sin(1+x**2)
-0.95892427466313845+/-0.2836621854632263
>>> print (2*x+1000).derivatives[x] # Automatic calculation of derivatives
2.0
>>> from uncertainties import unumpy # Array manipulation
>>> varr = unumpy.uarray([1, 2], [0.1, 0.2])
>>> print(varr)
[1.0+/-0.1 2.0+/-0.2]
>>> print(varr.mean())
1.50+/-0.11
>>> print(unumpy.cos(varr))
[0.540302305868+/-0.0841470984808 -0.416146836547+/-0.181859485365]
Main features
Transparent calculations with uncertainties: Little or no modification of existing code is needed to convert calculations of floats to calculations of values with uncertainties.
Correlations between expressions are correctly taken into account. Thus, x-x is exactly zero.
Most mathematical operations are supported, including most functions from the standard math module (sin,…). Comparison operators (>, ==, etc.) are supported too.
Many fast operations on arrays and matrices of numbers with uncertainties are supported.
Extensive support for printing numbers with uncertainties (including LaTeX support and pretty-printing).
Most uncertainty calculations are performed analytically.
This module also gives access to the derivatives of any mathematical expression (they are used by error propagation theory, and are thus automatically calculated by this module).
Installation or upgrade
To install uncertainties, use:
pip install uncertainties
To upgrade from an older version, use:
pip install --upgrade uncertainties
Further details are in the on-line documentation.
Git branches
The GitHub master branch is the latest development version, and is intended to be a stable pre-release version. It will be experimental, but should pass all tests.. Tagged releases will be available on GitHub, and correspond to the releases to PyPI. The GitHub gh-pages branch will contain a stable test version of the documentation that can be viewed at https://lmfit.github.io/uncertainties/. Other Github branches should be treated as unstable and in-progress development branches.
License
This package and its documentation are released under the Revised BSD License.
History
This package was created back around 2009 by Eric O. LEBIGOT.
Ownership of the package was taken over by the lmfit GitHub organization in 2024.
Metadata
Release files for uncertainties 3.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| uncertainties-3.2.3.tar.gz | 160.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| uncertainties-3.2.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 220.6 kB
Release files / uncertainties-3.2.3.tar.gz
| Download URL | uncertainties-3.2.3.tar.gz |
|---|---|
| Size | 160.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
76a5653e686f617a42922d546a239e9efce72e6b35411b7750a1d12dcba03031
|
|
BLAKE2b-256 checksum How to use checksums |
fe0ccb09f33b26955399c675ab378e4063ed7e48422d3d49f96219ab0be5eba9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Release files / uncertainties-3.2.3-py3-none-any.whl
| Download URL | uncertainties-3.2.3-py3-none-any.whl |
|---|---|
| Size | 60.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
313353900d8f88b283c9bad81e7d2b2d3d4bcc330cbace35403faaed7e78890a
|
|
BLAKE2b-256 checksum How to use checksums |
8f5ef1e1dd319e35e962a4e00b33150a8868b6329cc1d19fd533436ba5488f09
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Security for uncertainties 3.2.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.