# objectives.neg_log_marglik

``` python
objectives.neg_log_marglik(posterior, /)
```

Laplace negative log marginal likelihood of the fit data, `-post.log_marglik()`.

For a posterior $\mathcal{N}(\mu, \Lambda^{-1})$ with prior precision $\Lambda_0$ and prior location $\mu_0$, it is

$$-\log p(\mathcal{D} \mid \mu)
    + \tfrac{1}{2} \left( \log \det \Lambda - \log \det \Lambda_0 \right)
    + \tfrac{1}{2} (\mu - \mu_0)^\top \Lambda_0 (\mu - \mu_0).$$

`lk.MarginalLikelihood()` minimizes it; `lk.Minimize(neg_log_marglik)` is the same.

## Parameters

| Name | Type | Description | Default |
|----|----|----|----|
| posterior | LaplacePosterior\[Any, Any\] | A posterior fitted on data with targets. | *required* |

## Returns

| Name | Type   | Description     |
|------|--------|-----------------|
|      | Tensor | A 0-dim tensor. |

## Raises

| Name | Type | Description |
|----|----|----|
|  | ValueError | The posterior has no data-fit term (a fit without targets). |
|  | StructureError | As `LaplacePosterior.log_marglik`. |
