mc_iter

threadcount.lmfit_ext.mc_iter(self, n_mc_iterations=0, distribution='normal')[source]

ModelResult extension to change the data related to sigma and refit.

The new data will be randomly n_mc_iterations times, using the data value and the sigma as inputs to the random number generator.

distribution options may be:

  • “normal”, which returns a normal distribution where mean = data value and sigma = sigma.

  • “uniform”, which returns a uniform distribution in the range [data - 2*sigma, data + 2*sigma)

The original ModelResult will be returned as the 0th element, meaning an array of 1+`n_mc_iterations` will be returned.

Parameters:
  • n_mc_iterations (int, optional) – The number of new data sets to generate and fit, by default 0

  • distribution ("normal" or "uniform", optional) – The type of random distribution to use, by default “normal”

Returns:

a list of 1+`n_mc_iterations` ModelResults, where the first element contains the original ModelResult (i.e. the real measured data.)

Return type:

list of ModelResult

Raises:

NotImplementedError – If distribution is not recognized, this function cannot complete.