# testing.check_likelihood

``` python
testing.check_likelihood(likelihood, f, y, /)
```

Check a likelihood’s laws at outputs `f` and targets `y` (one batch).

Not `core.check_likelihood`, which checks that a likelihood has the hooks a method’s `Requirements` ask for.

- It satisfies `Likelihood`, and `core.log_prob` is shaped `[N]`, one value per example.
- `HasDistribution`: `distribution(f).log_prob(y)`, summed over each example’s positions, equals `core.log_prob`.
- `LateLikelihood`: `unit()` returns self unless it drops a hyperparameter, that is, unless some leaf of the likelihood (by identity) is not a leaf of `unit()`; and, when `unit()` is itself a `LateLikelihood`, `unit().unit()` is `unit()`.
- `HasOutputHessian`: with $H$ = `dense()`, $H$ is shaped `[N, E, E]`, $\mathrm{mv}(v) = H v$ for a random $v$, $H = H^\top$, and $H$ is positive semi-definite: its smallest eigenvalue is at least $-\mathrm{RTOL} \cdot \max |H|$. These run only for events up to `MAX_DENSE_EVENT` entries and a tensor `f`.

Masks are not applied: `log_prob` is compared over every position. Equalities hold up to `RTOL`. Errors that the likelihood raises propagate, except a `StructureError` from `core.log_prob`, which fails the shape law.

## Parameters

| Name | Type | Description | Default |
|----|----|----|----|
| likelihood | Likelihood | The likelihood. | *required* |
| f | Outputs | Model outputs for one batch. Pass float64 so that `RTOL` holds. | *required* |
| y | Targets | Targets for the same batch. | *required* |

## Raises

| Name | Type | Description |
|----|----|----|
|  | AssertionError | A law above fails. The message names the law and `likelihood`. |
