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.4, 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.4

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.4
File Size Uploaded Provenance Actions
errorcalculus-0.1.4.tar.gz 148.1 kB With provenance Details for errorcalculus-0.1.4.tar.gz

Built distribution (wheel)

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

Total release size: 219.6 kB

Release files / errorcalculus-0.1.4.tar.gz

Download URL errorcalculus-0.1.4.tar.gz
Size 148.1 kB
Tags Source
SHA-256 checksum
How to use checksums
e4d6eec84f6109275c5425fffa5ce5eb9da6f9c18e8c39eaf9a524f3a7597859
BLAKE2b-256 checksum
How to use checksums
b2b0c24664ef65e5665524ceee48158e0b9060d7cb3e664458566f45dd46a27e
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 4, 2026.

Transparency log

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

Download URL errorcalculus-0.1.4-py3-none-any.whl
Size 71.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0941cdde60fda25f5ded2b656ffc4fd08efe2bf573f7957c0564b4b98653a09f
BLAKE2b-256 checksum
How to use checksums
5412e87ddba10632b342b11292f94fb8879b5da642b3dc98501164efaab91602
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 4, 2026.

Transparency log

Security for errorcalculus 0.1.4

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.4.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 4, 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