fitbenchmarking.cost_func.nlls_cost_func module

Implements the non-weighted non-linear least squares cost function

class fitbenchmarking.cost_func.nlls_cost_func.NLLSCostFunc(problem)

This defines the non-linear least squares cost function where, given a set of $$n$$ data points $$(x_i,y_i)$$, associated errors $$e_i$$, and a model function $$f(x,p)$$, we find the optimal parameters in the root least-squares sense by solving:

$\min_p \sum_{i=1}^n \left(y_i - f(x_i, p)\right)^2$

where $$p$$ is a vector of length $$m$$, and we start from a given initial guess for the optimal parameters. More information on non-linear least squares cost functions can be found here.

eval_r(params, **kwargs)

Calculate the residuals, $$y_i - f(x_i, p)$$

Parameters

params (list) – The parameters, $$p$$, to calculate residuals for

Returns

The residuals for the datapoints at the given parameters

Return type

numpy array

hes_res(params, **kwargs)

Uses the Hessian of the model to evaluate the Hessian of the cost function residual, $$\nabla_p^2 r(x,y,p)$$, at the given parameters.

Parameters

params (list) – The parameters at which to calculate Hessians

Returns

evaluated Hessian and Jacobian of the residual at

each x, y pair :rtype: tuple(list of 2D numpy arrays, list of 1D numpy arrays)

jac_res(params, **kwargs)

Uses the Jacobian of the model to evaluate the Jacobian of the cost function residual, $$\nabla_p r(x,y,p)$$, at the given parameters.

Parameters

params (list) – The parameters at which to calculate Jacobians

Returns

evaluated Jacobian of the residual at each x, y pair

Return type

a list of 1D numpy arrays