deerlab.FitResult

class FitResult[source]

Represents the results of either the deerlab.fit or deerlab.snlls functions. Depending on which function is used, the attributes and methods of the FitResult will be different.

Attributes:
modelndarray

The fitted model response.

modelUncert

Uncertainty quantification of the fitted model response.

paramndarray

Fitted parameter vector ordered according to the model parameter indices.

paramUncertdeerlab.UQResult

Uncertainty quantification of the parameter vector ordered according to the model parameter indices.

regparamfloat scalar

Regularization parameter used in the fit.

noiselvl: ndarray

Estimated noise level of the data or user-provided noise level.

successbool

Whether or not the optimizer exited successfully.

costfloat

Value of the cost function at the solution.

residualsndarray

Vector of residuals at the solution.

statsdict

Goodness of fit statistical estimators:

  • stats['chi2red'] - Reduced chi^2 test

  • stats['r2'] - R^2 test

  • stats['rmsd'] - Root-mean squared deviation (RMSD)

  • stats['aic'] - Akaike information criterion

  • stats['aicc'] - Corrected Akaike information criterion

  • stats['bic'] - Bayesian information criterion

  • stats['autocorr'] - Autocorrelation based on Durbin–Watson statistic

nonlinndarray

Fitted non-linear parameters. [deerlab.snlls specific attribute]

nonlinUncertdeerlab.UQResult

Uncertainty quantification of the non-linear parameter set. [deerlab.snlls specific attribute]

linndarray

Fitted linear parameters. [deerlab.snlls specific attribute]

linUncertdeerlab.UQResult

Uncertainty quantification of the linear parameter set. [deerlab.snlls specific attribute]

Methods table

evaluate(model, *constants)

Evaluate a model at the fitted parameter values.

plot([axis, xlabel, gof, fontsize])

Function to display the results.

propagate(model, *constants[, lb, ub])

Propagate the uncertainty in the fit results to a model's response.

Methods

FitResult.evaluate(model, *constants)[source]

Evaluate a model at the fitted parameter values.

Takes a model object or callable function model to be evaluated. All the parameters in the model or in the callable definition must match their corresponding parameter names in the FitResult object. Any model constants present required by the model must be specified as a second argument constants. It returns the model’s response at the fitted parameter values as an ndarray.

Parameters:
modeldeerlab.Model or callable

Model object or callable function to be evaluated. All the parameters in the model or in the callable definition must match their corresponding parameter names in the FitResult object.

constantsarray_like

Any model constants present required by the model.

Returns:
responsearray_like

Model response at the fitted parameter values.

FitResult.plot(axis=None, xlabel=None, gof=False, fontsize=13)[source]

Function to display the results.

This can also plot goodness-of-fit tests if requested.

  • Plot of residuals along with the estimated noise level and mean value

  • Histogram of the residuals weighted by the noise level, compared to the standard normal distribution

  • Autocorrelogram of the residuals, along the confidence region for a white noise vector

Parameters:
axisarray_like, optional

Vector for the x-axis. If not specified, the default is the array indices.

xlabelstr, optional

Label for the x-axis. If not specified, the default is ‘Array elements’.

gofbool, optional

If set to True, the goodness-of-fit plots will be displayed, the default is False.

fontsizeint, optional

Fontsize of the figure labels, the default is 13.

Returns:
figmatplotlib.Figure

Figure object containing the plot.

FitResult.propagate(model, *constants, lb=None, ub=None)[source]

Propagate the uncertainty in the fit results to a model’s response.

Takes a model object or callable function model to be evaluated. All the parameters in the model or in the callable definition must match their corresponding parameter names in the FitResult object. Any model constants present required by the model must be specified as a second argument constants. The lower bounds lb and upper bounds ub of the model’s response can be specified as a third and fourth argument respectively. It returns the model’s response uncertainty quantification as a UQResult object.

Parameters:
modeldeerlab.Model or callable

Model object or callable function to be evaluated. All the parameters in the model or in the callable definition must match their corresponding parameter names in the FitResult object.

constantsarray_like

Model constants.

lbarray_like, optional

Lower bounds of the model response.

ubarray_like, optional

Upper bounds of the model response.

Returns:
responseUncertdeerlab.UQResult

Uncertainty quantification of the model’s response.

Inherited Methods

FitResult.__init__(*args, **kwargs)
FitResult.clear() None.  Remove all items from D.
FitResult.copy() a shallow copy of D
FitResult.fromkeys(iterable, value=None, /)

Create a new dictionary with keys from iterable and values set to value.

FitResult.get(key, default=None, /)

Return the value for key if key is in the dictionary, else default.

FitResult.items() a set-like object providing a view on D's items
FitResult.keys() a set-like object providing a view on D's keys
FitResult.pop(key, default=<unrepresentable>, /)

If the key is not found, return the default if given; otherwise, raise a KeyError.

FitResult.popitem(/)

Remove and return a (key, value) pair as a 2-tuple.

Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.

FitResult.setdefault(key, default=None, /)

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

FitResult.update([E, ]**F) None.  Update D from dict/iterable E and F.

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

FitResult.values() an object providing a view on D's values