Skip to main content

A Python 3 package for mathematical calculations with uncertain numbers

Project description

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

d = -b+2*a**(b/3)
  • 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

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

uncertain-0.0.10.tar.gz (20.5 kB view details)

Uploaded Source

Built Distribution

uncertain-0.0.10-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

Details for the file uncertain-0.0.10.tar.gz.

File metadata

  • Download URL: uncertain-0.0.10.tar.gz
  • Upload date:
  • Size: 20.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.8

File hashes

Hashes for uncertain-0.0.10.tar.gz
Algorithm Hash digest
SHA256 4f85be7cc0aebbac5c6556274da6ec4ca00cde2e9555e36d7e1755d5dceac928
MD5 cbcc8300c6932352870eadf79d7f9ce6
BLAKE2b-256 84df940a373760fb0346c50b9add85c05094c2537a7d6827f2a6074d2d06e79b

See more details on using hashes here.

File details

Details for the file uncertain-0.0.10-py3-none-any.whl.

File metadata

  • Download URL: uncertain-0.0.10-py3-none-any.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.8

File hashes

Hashes for uncertain-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 0d200e67343cf5f866c95b83d18a32930861b15b92d6e1e5ea8b12be68b6856e
MD5 4ae8ef92b732f2f5727bffc539b67332
BLAKE2b-256 e7869360805ee78f7853616ad664336c446c71db43e1dbabdf244b9b8fc79181

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page