Uncertainties: Error Propagation Library

3.2.4 · active · verified Sat Apr 11

The `uncertainties` package is an open-source Python library for doing calculations on numbers that have uncertainties (like 3.14±0.01). It automatically propagates uncertainties and handles correlations using linear error propagation theory. Maintained by the lmfit organization, it is actively developed, with version 3.2.4 released in January 2026, and a major 4.0.0 release is forthcoming.

Warnings

Install

Imports

Quickstart

Create numbers with uncertainties using `ufloat` and perform standard arithmetic or mathematical operations, with uncertainties automatically propagated.

from uncertainties import ufloat
from uncertainties.umath import sin

x = ufloat(2, 0.1)  # x = 2 +/- 0.1
y = ufloat(3, 0.2)  # y = 3 +/- 0.2

result_sum = x + y
result_product = x * y
result_sin = sin(x)

print(f"Sum: {result_sum}")
print(f"Product: {result_product}")
print(f"Sin(x): {result_sin}")

# Accessing nominal value and standard deviation
print(f"Nominal value of sum: {result_sum.nominal_value}")
print(f"Standard deviation of sum: {result_sum.std_dev}")

view raw JSON →