Squared error (aka loss function) of x with respect to data, as function of x. Additional argument jacobian is the Jacobian matrix of the (vector) quantity of interest with respect to problem parameters. Such matrices are computed by, e.g., solvers based on adjoint state method.

squared_error(x, data, jacobian = NULL)

Arguments

x

numeric or complex vector, computed (simulated) data.

data

numeric or complex vector, observed data, must have the same length as x (this is the number of quantities of interest).

jacobian

numeric or complex matrix, can be NULL, its number of rows must equal the length of x and data, its number of columns is the number of parameters in considered problem.

Value

List with one or two components:

value

numeric scalar;

gradient

numeric vector with length equal to ncol(jacobian), missing if jacobian is NULL.