Skip to main content

errorcalculus

Bouleau's error calculus for Python. errorcalculus propagates the error variance Γ (the quadratic error) and, at second order, the bias A of quantities through a computation, exactly in the sense of the chain rule, at the nominal values. It follows the error calculus of N. Bouleau (Error Calculus for Finance and Physics: The Language of Dirichlet Forms, de Gruyter, 2003), in which Γ and A are two operators with their own calculus: a C² function F of quantities x₁, …, xₙ satisfies

F♯   = Σᵢ ∂ᵢF · xᵢ♯                                    (the "sharp": a linear error)
Γ[F] = Σᵢⱼ ∂ᵢF ∂ⱼF Γ[xᵢ, xⱼ]
A[F] = Σᵢ ∂ᵢF A[xᵢ] + ½ Σᵢⱼ ∂ᵢⱼF Γ[xᵢ, xⱼ]

Status: 0.1.1, alpha. This is the first layer of the library (finite dimension). The API of the 0.x series is not stable: names and signatures may still change, and every change is listed in the changelog.

Install

python -m pip install errorcalculus

Python 3.10 or later; NumPy is the only dependency (SciPy is used when present, for vectorised erf/erfc).

A first computation

The order of the calculus is explicit: order=1 propagates error variances only (Gauss); order=2 propagates error variances and biases.

import errorcalculus as ec

m = ec.Model(order=2)
x = m.input(2.0, std=0.1, bias=0.01, name="x")
y = m.input(3.0, std=0.2, name="y")       # no bias declared: assumed zero, and reported

f = x * ec.exp(y / 10)
print(f)              # 2.6997176151520064 ± 0.1453842429031768 [bias 0.014038531598790434]
print(f.gamma)        # Γ[f], the error variance of f (not the variance of f)
print(dict(f.sharp))  # {'x': 0.13498588075760032, 'y': 0.05399435230304014}
print(ec.contributions(f))          # Γ[f] split by input
print(f.summary(scale=1.0))         # ... (bias assumed zero for: y)

In a first-order model, asking for a bias raises FirstOrderError instead of returning 0 or None: Gauss's calculus excludes biases by construction, and the library says so.

What is in 0.1

  • Model, Quantity, QuantityArray: independent and correlated inputs (Cholesky, or a spectral factorisation for singular covariances), NumPy arrays of quantities, 23 elementary functions with their domain rules, linear algebra (errorcalculus.linalg.solve, inv, det);
  • user functions: wrap (with given or numerical derivatives, checked by step halving) and sensitivities (exact gradient and Hessian);
  • readings: gamma, covariance_matrix, correlation_matrix, contributions (of the error variance, and of the bias by source), summary(scale=s) with s = ε² (Bouleau's gauge);
  • BiasOperator: the bias operator L as an operator on functions, the identity Γ(φ, ψ) = L(φψ) − φL(ψ) − ψL(φ), and its transport by a diffeomorphism;
  • compare_methods: the same model computed by several methods (error calculus, first order, sensitivities, sigma points, Monte Carlo, second-order Taylor moments), side by side.

Every guarantee is tested; the register of the 24 guarantees, each with its test file, is docs/GUARANTEES.md.

Relation to other libraries

The propagation engine is the forward recursion of value, gradient and Laplacian known as the Forward Laplacian (R. Li et al., 2023, arXiv:2307.08214), here applied to error variances and biases; it is cited, not claimed. The first-order part covers what uncertainties and GTC compute, and the second-order moments are those of soerp and of R propagate. The test suite checks parity with uncertainties, GTC, soerp and folx (guarantee G15).

Documentation

https://errorcalculus.readthedocs.io

Contributing, support

See CONTRIBUTING.md. Questions and reports: https://github.com/HubHubHubHubHub/errorcalculus/issues.

License

BSD-3-Clause (LICENSE).

Metadata

Release files for errorcalculus 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for errorcalculus 0.1.1
File Size Uploaded Provenance Actions
errorcalculus-0.1.1.tar.gz 115.3 kB With provenance Details for errorcalculus-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for errorcalculus 0.1.1
File Interpreter ABI Platform Actions
errorcalculus-0.1.1-py3-none-any.whl Python 3 none any Details for errorcalculus-0.1.1-py3-none-any.whl

Total release size: 174.9 kB

Release files / errorcalculus-0.1.1.tar.gz

Download URL errorcalculus-0.1.1.tar.gz
Size 115.3 kB
Tags Source
SHA-256 checksum
How to use checksums
031c985848c9749d5b3bb54f9ab5e494a083c81db71a85e5ea90ed99a86f2a81
BLAKE2b-256 checksum
How to use checksums
c76e209489d475bd7c04e3ea802f746e6f6499c5c657fec14a63675717a7c985
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.

Transparency log

Release files / errorcalculus-0.1.1-py3-none-any.whl

Download URL errorcalculus-0.1.1-py3-none-any.whl
Size 59.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6803ff87e4b8bfd373f3944eaf9211523bbaf4822725a48211c9be2370ef51c7
BLAKE2b-256 checksum
How to use checksums
a9b57194c6be3831f5d9ad91e44f69eb85617a4738ffdea7af79648cb23f6af0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.

Transparency log

Security for errorcalculus 0.1.1

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for errorcalculus-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page