Skip to content

eggzec/mcerp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

122 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mcerp

Real-time latin-hypercube sampling-based Monte Carlo ERror Propagation for Python

Tests Documentation Ruff

codecov Quality Gate Status License

PyPI Downloads Python versions

Overview

mcerp is a stochastic calculator for Monte Carlo methods that uses latin-hypercube sampling to perform non-order specific error propagation (or uncertainty analysis).

With this package you can easily and transparently track the effects of uncertainty through mathematical calculations. Advanced mathematical functions, similar to those in the standard math module, and statistical functions like those in the scipy.stats module, can also be evaluated directly.

If you are familiar with Excel-based risk analysis programs like @Risk, Crystal Ball, ModelRisk, etc., this package will work wonders for you (and probably even be faster!) and give you more modelling flexibility with the powerful Python language. This package also doesn't cost a penny, compared to those commercial packages which cost thousands of dollars for a single-seat license. Feel free to copy and redistribute this package as much as you desire!

  1. Transparent calculations. No or little modification to existing code required.

  2. Basic NumPy support without modification. (I haven't done extensive testing, so please let me know if you encounter bugs.)

  3. Advanced mathematical functions supported through the mcerp.umath sub-module. If you think a function is in there, it probably is. If it isn't, please request it!

  4. Easy statistical distribution constructors. The location, scale, and shape parameters follow the notation in the respective Wikipedia articles and other relevant web pages.

  5. Correlation enforcement and variable sample visualization capabilities.

  6. Probability calculations using conventional comparison operators.

  7. Advanced Scipy statistical function compatibility with package functions. Depending on your version of Scipy, some functions might not work.

Installation

You have several easy, convenient options to install the mcerp package.

pip

pip install mcerp

To install with plotting support:

pip install mcerp[plot]

To install all optional dependencies:

pip install mcerp[all]

uv

uv add mcerp
uv sync

Or in an existing uv environment:

uv pip install mcerp

git

To install the latest version from git:

pip install --upgrade "git+https://github.com/eggzec/mcerp.git#egg=mcerp"

Requirements

  • Python >=3.10
  • NumPy : Numeric Python
  • SciPy : Scientific Python (the nice distribution constructors require this)
  • Matplotlib : Python plotting library (optional)

See Also

About

Real-time latin-hypercube sampling-based Monte Carlo ERror Propagation for Python

Resources

License

Stars

Watchers

Forks

Contributors

Languages