Skip to main content

UNCERTAIN

Python module to keep track of uncertainties in mathematical calculations.

Usage example

  • Define uncertain values

import uncertain as uc

# Uncertain value between 3 and 8 and a normal distribution with
# mean=5 and standard deviation=1.
a = uc.UncertainValue(5, 3, 8, 'normal', [5, 1])

# Uncertain value with a uniform distribution between 0.1 and 4
b = uc.UncertainValue(1, 0.1, 4)

# Uncertain value from measured data points
c = uc.from_data([1, 2, 3, 4, 5])
  • Perform mathematical calculations: addition, substraction, multiplication, power, sine, cosine, tangent. In order for the trigonometric functions to work, they need to be called from numpy (math does not work).

d = -b+2*a**(b/3)
import numpy as np
e = np.pi / 180 * uc.UncertainValue(40, 35, 45)
f = np.sin(e) + np.cos(e) + np.cos(e)
  • Display properties and plot results in density plots or cumulative density plots

print(c.describe(),
"\n\nThe standard deviation of b is "+str(b.std),
"\n\nThe probability of /c/ being between 2 and 6 is " +
str(probability_in_interval(c, [2, 6])))

a.plot_distribution(title="Uncertain numbers", label="a")
b.plot_distribution(label="b", alpha=0.5)
d.plot_distribution(label="d", alpha=0.5)

d.plot_distribution(plot_type='cdf', new_figure=True)

Output:

This variable is an uncertain value. It has the following properties:

    - Nominal value: 2.4199518933533937

    - Mean: 5.1973349566661415
    - Median: 3.8063419262133795
    - Variance: 13.086116036143682
    - Standard deviation: 3.6174737091157527
    - Skewness: 1.5519941650511524

    - Lower bound: -1.9254016053940988
    - Percentile 5: 2.0248565203431506
    - Q1: 2.432100693608657
    - Q3: 6.832833238201248
    - Percentile 95: 12.808458201483177
    - Upper bound: 31.899999999999995

    - Probability distribution type: custom
    - Number of samples: 100000


The standard deviation of b is 1.1245368594834484

The probability of /c/ being between 2 and 6 is 0.67164
https://gitlab.com/mnn/uncertain/-/raw/master/resources/density_plot.png https://gitlab.com/mnn/uncertain/-/raw/master/master/resources/cdf_plot.png

Metadata

Release files for uncertain 0.0.13

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

Source distribution (sdist)

Source distribution for uncertain 0.0.13
File Size Uploaded Provenance
uncertain-0.0.13.tar.gz 22.5 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 42.0 kB

Release files / uncertain-0.0.13.tar.gz

Download URL uncertain-0.0.13.tar.gz
Size 22.5 kB
Tags Source
SHA-256 checksum
How to use checksums
88530b3793e9ad442ee1d3a6ed28285cf66b6270a36dddf0ba0932a95dc196f1
BLAKE2b-256 checksum
How to use checksums
90a586ec70a432b2a25b8dcedfc4f65891ce7c83031fe27de01ae39758e91399
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.2

Release files / uncertain-0.0.13-py3-none-any.whl

Download URL uncertain-0.0.13-py3-none-any.whl
Size 19.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c0c6ded4022814167a6c758353bce1e80d7f001946af898ea5988e1529400403
BLAKE2b-256 checksum
How to use checksums
2fa68ee4e906629a76ccd312f9f10a19c1672ac4b646e91e402f090162975a9e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.2

Security for uncertain 0.0.13

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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