Logo

A physics toolbox for laser spectroscopy.

Static Badge Static Badge Static Badge

Static Badge Static Badge

© 2025 Patrick Müller. All rights reserved.

qspec.analyze.linear_monte_carlo  (  x y sigma_x = None sigma_y = None corr = None optimize_cov = True n_samples = None n_accepted = None optimize_sampling = True return_samples = False method = 'py' report = True ** kwargs  )[source]

Wrapper for linear_nd_monte_carlo.

Parameters:
xndarray | Iterable

The x data. Must be a 1-d array.

yndarray | Iterable

The y data. Must be a 1-d array.

sigma_xndarray | Iterable

The 1-sigma uncertainties of the x data. Must be a 1-d array.

sigma_yndarray | Iterable

The 1-sigma uncertainties of the y data. Must be a 1-d array.

corrndarray | Iterable

The correlation coefficients between the x and y data. Must be a 1-d array.

optimize_covbool

If True, the origin vector of the straight is optimized to yield the smallest covariances.

n_samplesint

Maximum number of generated samples. If None and method == 'cpp', samples are generated until 'n_accepted' samples get accepted.

n_acceptedint

The number of samples to be accepted for each data point. Only available if method == 'cpp'.

optimize_samplingbool

Whether to optimize the sampling from the data.

return_samplesbool

Whether to also return the generated points 'p'. 'p' has shape (n_samples, k ,2).

methodstr

The method to generate the collinear points. Can be one of {'py', 'cpp'}. The 'py' version is faster but only allows to specify 'n_samples'. The 'cpp' version is slower but allows to specify both 'n_accepted' and 'n_samples'.

reportbool

Whether to print the result of the fit.

kwargsNone

Additional keyword arguments.

Returns:
outNone

a, b, sigma_a, sigma_b, corr_ab. The best y-intercept and slope, their respective 1-sigma uncertainties and their correlation coefficient.

API navigation