# core.LateLikelihood

``` python
core.LateLikelihood()
```

A likelihood whose hyperparameters are applied after the fit.

The fit uses `unit()` for curvature and sampling, and keeps the additive statistic `fit_stat` in place of the log-likelihood. The posterior multiplies the unit curvature by `curvature_scale()` and turns the summed statistic into the log-likelihood with `log_lik`. So both read the hyperparameters at the time they are called.

`unit()` returns the likelihood itself (`unit() is lik`) exactly when there is no late hyperparameter, as for a `Gaussian` with a fixed sigma. Methods that can’t apply hyperparameters late (`Requirements.late_scale=False`) accept those and refuse the rest. A likelihood whose hyperparameter shapes the curvature, such as a per-output sigma, returns itself from `unit()`.

A leaf that `unit()` shares (by identity) is applied at fit time; the hyper tuners refuse to change it. A likelihood that is not a `LateLikelihood` is its own `unit()`, so all its leaves are refused. A leaf left out of `unit()` is late and tunable, so it must be read only by `curvature_scale` and `log_lik`.

The hyper tuners change the leaves a likelihood lists in `tunable()` (`TunableLikelihood`), such as the learned `sigma` of the built-in `Gaussian`.

## Methods

| Name | Description |
|----|----|
| [curvature_scale](#laplacekit.core.LateLikelihood.curvature_scale) | The factor the posterior multiplies the unit curvature by. |
| [fit_stat](#laplacekit.core.LateLikelihood.fit_stat) | The additive statistic the fit keeps in place of the log-likelihood. |
| [log_lik](#laplacekit.core.LateLikelihood.log_lik) | The log-likelihood from the summed statistic. |
| [unit](#laplacekit.core.LateLikelihood.unit) | The likelihood the fit uses for curvature and sampling. |

### curvature_scale

``` python
core.LateLikelihood.curvature_scale()
```

The factor the posterior multiplies the unit curvature by.

#### Returns

| Name | Type   | Description                                         |
|------|--------|-----------------------------------------------------|
|      | Tensor | A tensor computed from the current hyperparameters. |

### fit_stat

``` python
core.LateLikelihood.fit_stat(f, y, weights, /)
```

The additive statistic the fit keeps in place of the log-likelihood.

The fit sums it over batches.

#### Parameters

| Name | Type | Description | Default |
|----|----|----|----|
| f | Outputs | Model outputs for a batch. | *required* |
| y | Targets | Targets for the same batch. | *required* |
| weights | Tensor \| None | Per-example weights, or `None` for all ones. | *required* |

#### Returns

| Name | Type   | Description            |
|------|--------|------------------------|
|      | Tensor | The batch’s statistic. |

### log_lik

``` python
core.LateLikelihood.log_lik(stat, /)
```

The log-likelihood from the summed statistic.

#### Parameters

| Name | Type   | Description                         | Default    |
|------|--------|-------------------------------------|------------|
| stat | Tensor | `fit_stat` summed over all batches. | *required* |

#### Returns

| Name | Type   | Description                                               |
|------|--------|-----------------------------------------------------------|
|      | Tensor | The summed log-likelihood at the current hyperparameters. |

### unit

``` python
core.LateLikelihood.unit()
```

The likelihood the fit uses for curvature and sampling.

#### Returns

| Name | Type | Description |
|----|----|----|
|  | Likelihood | The likelihood without its late hyperparameters, or `self` (by identity) when there are none. |
