# 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)[source]

Note

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

debug = False

Print debugging information

counter = None

Set this to a SimPEG.Utils.Counter() if you want to count things

nP
Wd

## Common Data Misfits¶

### l2 norm¶

class SimPEG.DataMisfit.l2_DataMisfit(survey, **kwargs)[source]

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$
eps_factor = 1e-05

factor to multiply by the norm of the data to create floor

std = 0.05

default standard deviation if not provided by survey

eps = None

default floor

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)[source]

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)[source]
$\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