# Data Misfit¶

The data misfit using an l_2 norm is:

$\mu_\text{data} = {1\over 2}\left| \mathbf{W}_d (\mathbf{d}_\text{pred} - \mathbf{d}_\text{obs}) \right|_2^2$

If the field, u, is provided, the calculation of the data is fast:

\begin{align}\begin{aligned}\mathbf{d}_\text{pred} = \mathbf{Pu(m)}\\\mathbf{R} = \mathbf{W}_d (\mathbf{d}_\text{pred} - \mathbf{d}_\text{obs})\end{aligned}\end{align}

Where P is a projection matrix that brings the field on the full domain to the data measurement locations; u is the field of interest; d_obs is the observed data; and $$\mathbf{W}_d$$ is the weighting matrix.

The derivative of this, with respect to the model, is:

$\frac{\partial \mu_\text{data}}{\partial \mathbf{m}} = \mathbf{J}^\top \mathbf{W}_d \mathbf{R}$

The second derivative is:

$\frac{\partial^2 \mu_\text{data}}{\partial^2 \mathbf{m}} = \mathbf{J}^\top \mathbf{W}_d \mathbf{W}_d \mathbf{J}$

## The API¶

class SimPEG.DataMisfit.BaseDataMisfit(survey, **kwargs)

Note

You should inherit from this class to create your own data misfit term.

Wd
counter = None
debug = False
nP

## Common Data Misfits¶

### l2 norm¶

class SimPEG.DataMisfit.l2_DataMisfit(survey, **kwargs)

The data misfit with an l_2 norm:

$\mu_\text{data} = {1\over 2}\left| \mathbf{W}_d (\mathbf{d}_\text{pred} - \mathbf{d}_\text{obs}) \right|_2^2$
W

The data weighting matrix.

The default is based on the norm of the data plus a noise floor.

Return type: scipy.sparse.csr_matrix W
deriv(m, f=None)

Derivative of the data misfit

$\mathbf{J}^{ op} \mathbf{W}^{ op} \mathbf{W} (\mathbf{d} - \mathbf{d}^{obs})$
Parameters: m (numpy.ndarray) – model f (SimPEG.Fields.Fields) – fields object
deriv2(m, v, f=None)
$\mathbf{J}^{ op} \mathbf{W}^{ op} \mathbf{W} \mathbf{J}$
Parameters: m (numpy.ndarray) – model v (numpy.ndarray) – vector f (SimPEG.Fields.Fields) – fields object
eps = None
eps_factor = 1e-05
std = None