OptMethod

class sherpa.optmethods.OptMethod(name, optfunc)[source] [edit on github]

Bases: NoNewAttributesAfterInit

Base class for the optimisers.

Parameters:
  • name (str) – The name of the optimiser.

  • optfunc (function) – The function which optimises the model: its arguments are a function which evalutes the statistic given a list of parameter values, the starting parameters, minima, and maxima, followed by keyword arguments matching the configuration data.

Attributes Summary

default_config

The default settings for the optimiser.

Methods Summary

fit(statfunc, pars, parmins, parmaxes[, ...])

Run the optimiser.

Attributes Documentation

default_config

The default settings for the optimiser.

Methods Documentation

fit(statfunc, pars, parmins, parmaxes, statargs=(), statkwargs=None)[source] [edit on github]

Run the optimiser.

Changed in version 4.16.0: The statkwargs argument now defaults to None rather than {}.

Parameters:
  • statfunc (function) – Given a list of parameter values as the first argument and, as the remaining positional arguments, statargs and statkwargs as keyword arguments, return the statistic value.

  • pars (sequence) – The start position of the model parameter values.

  • parmins (sequence) – The minimum allowed values for each model parameter. This must match the length of pars.

  • parmaxes (sequence) – The maximum allowed values for each model parameter. This must match the length of pars.

  • statargs (optional) – Additional positional arguments to send to statfunc.

  • statkwargs (dict, optional) – Additional keyword arguments to send to statfunc.

Returns:

newpars – The tuple contains: boolean indicating whether the optimization succeeded or not, the best fit parameters as a NumPy array, the statistic value at the best-fit location, a string message indicating the status, and a dictionary containing information about the optimisation (this depends on the optimiser).

Return type:

tuple