Skip to main content

MCUP will propagate uncertainty of your data points to the parameters of the regression using a Monte Carlo approach.

Project description


MCUP (Monte Carlo Uncertainity Propagation) is a Python library that estimates the uncertainty of least squares fit parameters with Monte Carlo.


PyPI pyversions PyPI version master Documentation Status codecov


The aim of this package is to estimate the error of regression parameters based on error intervals of the input data.

PEE – Parameter Error Estimator, a bootstraping method which, takes input data for lsq (x, y, x_err, y_err), generates datapoints within given errors and calculate mean and std of parameters from lsq fit.

Installing MCUP


To install mlxtend, just execute

python3 -m pip install mcup  

Dev Version

The MCUP version on PyPI may always be one step behind. You can install the latest development version from the GitHub repository by executing

python3 -m pip install git+


import numpy as np
from mcup import Measurement

x_data = np.array([0.0, 1.0, 2.0, 3.0, 4.0, 5.0])
y_data = np.array([0.1, 0.9, 2.2, 2.8, 3.9, 5.1])

y_sigma = np.array([0.0, 0.1, 0.1, 0.1, 0.1, 0.1])

def fun(x, c):
    return c[0] * x + c[1]

c_initial_guess = [0.0, 0.0]

measurement = Measurement(x=x_data, y=y_data, y_err=y_sigma)
measurement.set_function(fun, c_initial_guess)

params_mean, params_std = measurement.evaluate_params(iter_num=1000)
# [0.9901532  0.02477131]
# [0.01881003 0.04965347]

params_mean, params_std = measurement.evaluate_params(atol=1e-4, rtol=1e-4)
# [0.98854127 0.02771339]
# [0.0172098  0.04729087]


When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.

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

mcup-0.1.1.tar.gz (6.4 kB view hashes)

Uploaded source

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