# fitbenchmarking.cost_func.nlls_base_cost_func module

Implements the base non-linear least squares cost function

class fitbenchmarking.cost_func.nlls_base_cost_func.BaseNLLSCostFunc(problem)

This defines a base cost function for objectives of the type

$\min_p \sum_{i=1}^n r(y_i, x_i, p)^2$

where $$p$$ is a vector of length $$m$$, and we start from a given initial guess for the optimal parameters.

eval_cost(params, **kwargs)

Evaluate the square of the L2 norm of the residuals, $$\sum_i r(x_i,y_i,p)^2$$ at the given parameters

Parameters

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

Returns

The sum of squares of residuals for the datapoints at the given parameters

Return type

numpy array

abstract eval_r(params, **kwargs)

Calculate residuals used in Least-Squares problems

Parameters

params (list) – The parameters to calculate residuals for

Returns

The residuals for the datapoints at the given parameters

Return type

numpy array

hes_cost(params, **kwargs)

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

Parameters

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

Returns

evaluated Hessian of the cost function

Return type

2D numpy array

jac_cost(params, **kwargs)

Uses the Jacobian of the model to evaluate the Jacobian of the cost function, $$\nabla_p F(r(x,y,p))$$, at the given parameters. :param params: The parameters at which to calculate Jacobians :type params: list :return: evaluated Jacobian of the cost function :rtype: 1D numpy array