# 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.data_misfit.BaseDataMisfit(*args, **kwargs)[source]

BaseDataMisfit

Note

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

Required Properties:

Optional Properties:

property simulation

simulation (BaseSimulation): A SimPEG simulation, an instance of BaseSimulation

property debug

debug (Boolean): Print debugging information, a boolean, Default: False

property counter

counter (Counter): Set this to a SimPEG.utils.Counter() if you want to count things, an instance of Counter

property data

data (Data): A SimPEG data class containing the observed data, an instance of Data

property nP

number of model parameters

property nD

number of data

property shape
property W

The data weighting matrix. The default is based on the norm of the data plus a noise floor. :rtype: scipy.sparse.csr_matrix :return: W

residual(m, f=None)[source]
property Wd

W.Wd has been deprecated. See W for documentation

## Common Data Misfits¶

### l2 norm¶

class SimPEG.data_misfit.L2DataMisfit(*args, **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$

Required Properties:

Optional Properties:

deriv(m, f=None)[source]

Derivative of the data misfit

$\mathbf{J}^{ op} \mathbf{W}^{ op} \mathbf{W} (\mathbf{d} - \mathbf{d}^{obs})$
Parameters
deriv2(m, v, f=None)[source]
$\mathbf{J}^{ op} \mathbf{W}^{ op} \mathbf{W} \mathbf{J}$
Parameters