# fitbenchmarking.cost_func.hellinger_nlls_cost_func module

Implements the root non-linear least squares cost function

class fitbenchmarking.cost_func.hellinger_nlls_cost_func.HellingerNLLSCostFunc(problem)

This defines the Hellinger 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 Hellinger least-squares sense by solving:

$\min_p \sum_{i=1}^n \left(\sqrt{y_i} - \sqrt{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 and for the Hellinger distance measure see here.

eval_r(params, **kwargs)

Calculate the residuals, $$\sqrt{y_i} - \sqrt{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

Return type

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