qspec logo qspec logo

A physics toolbox for laser spectroscopy.

Static Badge Static Badge Static Badge

Static Badge Static Badge

© 2026 Patrick Müller. All rights reserved.

qspec. propagate_fit  (  f ,  x ,  popt ,  pcov ,  sample_size=1000000  )[source]

Propagate the uncertainties of fitted parameters through the function f using Monte-Carlo sampling.

Parameters:
fCallable

The function f(x, *popt) to compute. f needs to be vectorized.

xarray_like

The input values.

poptarray_like

An array of the fitted parameters, e.g., from scipy.optimize.curve_fit.

pcovarray_like

A 2d-array of the estimated covariances of popt.

sample_sizeint

The number of random variates used for the calculation. The default is 1,000,000.

Returns:
(med, per_0, per_1)tuple[ndarray, ndarray, ndarray]

The median and the left- and right-sided 1-sigma percentiles of the sampled function values at x.