fitAlgs.leastsq module

Author:Dominic Hunt
class fitAlgs.leastsq.Leastsq(method='dogbox', jacobian_method='3-point', **kwargs)[source]

Bases: fitAlgs.fitAlg.FitAlg

Fits data based on the least squared optimizer scipy.optimize.least_squares

Not properly developed and will not be documented until upgrade

Parameters:
  • fit_sim (fitAlgs.fitSims.FitSim instance, optional) – An instance of one of the fitting simulation methods. Default fitAlgs.fitSims.FitSim
  • fit_measure (string, optional) – The name of the function used to calculate the quality of the fit. The value it returns provides the fitter with its fitting guide. Default -loge
  • fit_measure_args (dict, optional) – The parameters used to initialise fit_measure and extra_fit_measures. Default None
  • extra_fit_measures (list of strings, optional) – List of fit measures not used to fit the model, but to provide more information. Any arguments needed for these measures should be placed in fit_measure_args. Default None
  • bounds (dictionary of tuples of length two with floats, optional) – The boundaries for methods that use bounds. If unbounded methods are specified then the bounds will be ignored. Default is None, which translates to boundaries of (0, np.inf) for each parameter.
  • boundary_excess_cost (str or callable returning a function, optional) – The function is used to calculate the penalty for exceeding the boundaries. Default is boundFunc.scalarBound()
  • boundary_excess_cost_properties (dict, optional) – The parameters for the boundary_excess_cost function. Default {}
  • method ({‘trf’, ‘dogbox’, ‘lm’}, optional) – Algorithm to perform minimization. Default dogbox
Name

The name of the fitting method

Type:string

See also

fitAlgs.fitAlg.fitAlg
The general fitting method class, from which this one inherits
fitAlgs.fitSims.fitSim
The general fitting class
scipy.optimize.least_squares
The fitting class this wraps around
fit(simulator, model_parameter_names, model_initial_parameters)[source]

Runs the model through the fitting algorithms and starting parameters and returns the best one.

Parameters:
  • simulator (function) – The function used by a fitting algorithm to generate a fit for given model parameters. One example is fitAlg.fitness
  • model_parameter_names (list of strings) – The list of initial parameter names
  • model_initial_parameters (list of floats) – The list of the initial parameters
Returns:

  • fitParams (list of floats) – The best fitting parameters
  • fit_quality (float) – The quality of the fit as defined by the quality function chosen.
  • testedParams (tuple of two lists) – The two lists are a list containing the parameter values tested, in the order they were tested, and the fit qualities of these parameters.

See also

fitAlgs.fitAlg.fitness()