Linear and stochastic sensitivity analysis and uncertainty propagation
Project description
sensitivities
(L. Riegger, 2025)
Methods for linear and stochastic sensitivities analysis and uncertainty propagation, following the BIPM GUM (JCGM 102:2011).
Install
You can install the sensitivities module using pip:
pip install sensitivities
Usage
sensitivities.stochastic
The sensitivities.stochastic module provides functionality for stochastic sensitivity analysis. It allows you to stochastically sample input parameters from various, potentially correlated distributions and evaluate the sensitivities of a function to those inputs. Available distributions are
- Gaussian (given mean and standard deviation)
- Uniform (between lower and upper bound)
- Discrete (multiple discrete options)
Example for stochastic sampling:
from sensitivities.stochastic import sample, Gaussian, Uniform, Discrete
import matplotlib.pyplot as plt
def my_function(a, b, c=0, d=0):
return a + b + c + d
samples = sample(
my_function,
[
Gaussian(10, 0.05),
Discrete([1, 2]),
],
{"c": Uniform(-0.4, 0.4), "d": -100},
corr=[("a", "c", 0.5)],
n=100000,
)
plt.hist(np.array(samples), 100)
plt.show()
sensitivities.linear
This module contains the propagate_uncertainties function for propagation of uncertainties for a given function based on the principle of linear differentials. It makes use of the scipy function approx_fprime to calculate the partial derivatives of the given function.
Here is a simple usage example:
from sensitivities.linear import propagate_uncertainties
def my_function(x, y):
return [x ** 2, x, y]
print(propagate_uncertainties(my_function, uncertainties=[0.1, 0.2], x0=[1, 1]))
This will output the propagated standard uncertainties and correlation matrix between the function outputs:
(
np.array([0.2, 0.1, 0.2]),
np.array([[1.0, 1.0, 0.0], [1.0, 1.0, 0.0], [0.0, 0.0, 1.0]])
)
Development
Setup development environment
uv sync --extra dev
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sensitivities-1.1.0.tar.gz.
File metadata
- Download URL: sensitivities-1.1.0.tar.gz
- Upload date:
- Size: 573.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2391c98ec355567e1ee4eea1a0ee7619442fe2d554e73f379eae658711276acc
|
|
| MD5 |
9333e2882326656a46d3147513789b75
|
|
| BLAKE2b-256 |
67345c11e08a83f526e5f9b8c36356921b82308dff49acb2ba4c26a68662edf7
|
Provenance
The following attestation bundles were made for sensitivities-1.1.0.tar.gz:
Publisher:
release.yml on himbeles/sensitivities
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sensitivities-1.1.0.tar.gz -
Subject digest:
2391c98ec355567e1ee4eea1a0ee7619442fe2d554e73f379eae658711276acc - Sigstore transparency entry: 192809836
- Sigstore integration time:
-
Permalink:
himbeles/sensitivities@4b651e4123fe636390b748dd9924b66f68c989e6 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/himbeles
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4b651e4123fe636390b748dd9924b66f68c989e6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file sensitivities-1.1.0-py3-none-any.whl.
File metadata
- Download URL: sensitivities-1.1.0-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b2edbd805db386d4a140b5b1f7e6e3f41d31b5812039d4ecc24ce9e766e4cee
|
|
| MD5 |
3614e78b709d51b799c4e4ad7d15c1d3
|
|
| BLAKE2b-256 |
6d4f4bf93c9aebb5a0a0c20d60c0d9153be0c9b90211ccb1c7df53dd52a4db9e
|
Provenance
The following attestation bundles were made for sensitivities-1.1.0-py3-none-any.whl:
Publisher:
release.yml on himbeles/sensitivities
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sensitivities-1.1.0-py3-none-any.whl -
Subject digest:
5b2edbd805db386d4a140b5b1f7e6e3f41d31b5812039d4ecc24ce9e766e4cee - Sigstore transparency entry: 192809837
- Sigstore integration time:
-
Permalink:
himbeles/sensitivities@4b651e4123fe636390b748dd9924b66f68c989e6 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/himbeles
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4b651e4123fe636390b748dd9924b66f68c989e6 -
Trigger Event:
release
-
Statement type: