uncertainties 3.2.3


pip install uncertainties

  Latest version

Released: Apr 21, 2025


Meta
Author: Eric O. LEBIGOT (EOL)
Requires Python: >=3.8

Classifiers

Development Status
  • 5 - Production/Stable

Intended Audience
  • Developers
  • Education
  • Other Audience
  • Science/Research

License
  • OSI Approved :: BSD License

Operating System
  • OS Independent

Programming Language
  • Python
  • Python :: 3
  • Python :: 3.8
  • Python :: 3.9
  • Python :: 3.10
  • Python :: 3.11
  • Python :: 3.12
  • Python :: Implementation :: Jython
  • Python :: Implementation :: PyPy

Topic
  • Education
  • Scientific/Engineering
  • Scientific/Engineering :: Mathematics
  • Scientific/Engineering :: Physics
  • Software Development
  • Software Development :: Libraries
  • Software Development :: Libraries :: Python Modules
  • Utilities
https://readthedocs.org/projects/uncertainties/badge/?version=latest https://img.shields.io/pypi/v/uncertainties.svg https://pepy.tech/badge/uncertainties/week https://codecov.io/gh/lmfit/uncertainties/branch/master/graph/badge.svg https://img.shields.io/github/actions/workflow/status/lmfit/uncertainties/python-package.yml?logo=github%20actions

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.

3.2.3 Apr 21, 2025
3.2.2 Jul 07, 2024
3.2.1 Jun 08, 2024
3.2.0 Jun 03, 2024
3.1.7 Jun 19, 2022
3.1.6 Jul 11, 2021
3.1.5 Nov 18, 2020
3.1.4 Jun 06, 2020
3.1.2 Aug 05, 2019
3.1.1 May 30, 2019
3.1 May 19, 2019
3.0.3 Oct 28, 2018
3.0.2 Jan 14, 2018
3.0.1 Aug 15, 2016
2.4.8.1 Mar 28, 2016
2.4.8 Feb 24, 2016
2.4.7.1 Jan 16, 2016
2.4.6.1 Aug 14, 2014
2.4.6 Aug 14, 2014
2.4.5 Apr 09, 2014
2.4.4 Jan 11, 2014
2.4.3 Dec 07, 2013
2.4.2 Nov 19, 2013
2.4.1 Jul 26, 2013
2.4 Jul 18, 2013
2.3.6 Apr 28, 2013
2.3.5 Apr 26, 2013
2.3 Apr 23, 2013
2.2 Apr 18, 2013
2.1 Apr 17, 2013
2.0.1 Apr 14, 2013
2.0 Apr 13, 2013
1.9.1 Mar 01, 2013
1.9 Nov 23, 2012
1.8 Oct 29, 2011
1.7.4 Jul 09, 2011
1.7.3 Jun 19, 2011
1.7.2 Apr 26, 2011
1.7.1 Mar 18, 2011
1.7 Aug 25, 2010
1.6 Aug 15, 2010
1.5.5 Jul 11, 2010
1.5.4.9 Jun 30, 2010
1.5.4.8 Jun 28, 2010
1.5.4.7 Jun 28, 2010
1.5.4.6 Jun 28, 2010
1.5.4.5 Jun 28, 2010
1.5.4.4 Jun 25, 2010
1.5.4.3 Jun 21, 2010
1.5.4.2 Jun 20, 2010
1.5.4.1 Jun 08, 2010
1.5.4 Jun 08, 2010
1.5.3 Jun 08, 2010
1.4.5 Jun 08, 2010
1.4.3 Jun 08, 2010
1.4.1 Jun 08, 2010
1.4 Jun 08, 2010
1.3 Jun 08, 2010
1.2.5 Jun 08, 2010
1.2.4 Jun 08, 2010
1.2.3 Jun 08, 2010
1.2.2 Jun 08, 2010
1.2.1 Jun 08, 2010
1.2 Jun 08, 2010
1.1 Jun 08, 2010
1.0.17 Jun 08, 2010
1.0.15 Jun 08, 2010
1.0.14 Jun 08, 2010
1.0.12 Jun 08, 2010
1.0.11 Jun 08, 2010
1.0.10 Jun 08, 2010
1.0.9 Jun 08, 2010
1.0.8 Jun 08, 2010
1.0.7 Jun 08, 2010
1.0.6 Jun 08, 2010
1.0.5 Jun 08, 2010
1.0.4 Jun 08, 2010
1.0.2 Jun 08, 2010
1.0.1 Jun 08, 2010
1.0 Jun 08, 2010

Wheel compatibility matrix

Platform Python 3
any

Files in release

Extras:
Dependencies: