# likelihood_l_pdaf

The page document the user-supplied call-back routine `likelihood_l_pdaf`

.

The routine `likelihood_l_pdaf`

(called `U_likelihood_l`

inside the PDAF core routines) is a call-back routine that has to be provided by the user.
The routine is used in the localized nonlinear filter LNETF and has to compute the likelihood of the observation for a given ensemble member according to the observations used for the local analysis.
The likelihood depends on the assumed observation error distribution. For a Gaussian observation error, the likelihood is **exp(-0.5*(y-Hx) ^{T}*R^{-1}*(y-Hx))** for the local observations. The vector

**y-HX =**

`resid_l`

is provided as an input argument. The likelihood has to be returned in the variable `likely_l`

.
This routine is also the place to perform observation localization. To initialize a vector of weights, the routine `PDAF_local_weight`

can be called. The procedure is used in the example implementation and also demonstrated in the template routine.

The interface is the following:

SUBROUTINE likelihood_l_pdaf(domain_p, step, dim_obs_l, obs_l, resid_l, likely_l)

with

`domain_p`

:`integer, intent(in)`

Index of current local analysis domain`step`

:`integer, intent(in)`

Current time step`dim_obs_l`

:`integer, intent(in)`

Number of local observations at current time step (i.e. the size of the local observation vector)`obs_l`

:`real, intent(in), dimension(dim_obs_l)`

Local vector of observations`resid_l`

:`real, intent(in), dimension(dim_obs_l)`

Input vector holding the local residual`likely`

:`real, intent(out)`

Output value of the local likelihood

Hints:

- The routine is a local variant of the routine likelihood_pdaf. Thus, if that routine has been implemented before, it can be adapted here for the local filter.
- The routine is very similar to the routine prodRinvA_l_pdaf. The main addition is the computation of the likelihood after computing
**R**, which corresponds to^{-1}*(y-Hx)**R**in prodRinvA_l_pdaf.^{-1}*A_l - The routine does not require that the product is implemented as a real matrix-vector product. Rather, the product can be implemented in its most efficient form. For example, if the observation error covariance matrix is diagonal, only the multiplication of the inverse diagonal with the vector
`resid_l`

has to be implemented. - The observation vector
`obs_l`

is provided through the interface for cases where the observation error variance is relative to the actual value of the observations. - To perform observation localization (i.e. observation weighting by modifying the inverse observation error covariance matrix) one computes for each observations the distance of it from the local analysis domain and then computes a weight for each observation according to this distance. For the computation of the weight, the routine
`PDAF_local_weight`

can be used.