# core.OutputCov

``` python
core.OutputCov()
```

Covariance of model outputs for a batch of inputs, never formed as an $NE \times NE$ matrix.

Shapes follow the mean, for example `[N, C]` for $N$ inputs, and $E$ is the flattened event size. `per_input()` holds no cross-input blocks; `sample` may draw jointly across the batch (`SampleCov`, `FactorCov`: one weight draw per sample).

## Methods

| Name | Description |
|----|----|
| [diagonal](#laplacekit.core.OutputCov.diagonal) | The marginal variances. |
| [per_input](#laplacekit.core.OutputCov.per_input) | The covariance block of each input, without the cross-input blocks. |
| [sample](#laplacekit.core.OutputCov.sample) | Zero-mean draws from the covariance. |
| [scaled](#laplacekit.core.OutputCov.scaled) | The covariance times $s$. |

### diagonal

``` python
core.OutputCov.diagonal()
```

The marginal variances.

#### Returns

| Name | Type   | Description                    |
|------|--------|--------------------------------|
|      | Tensor | A tensor shaped like the mean. |

### per_input

``` python
core.OutputCov.per_input()
```

The covariance block of each input, without the cross-input blocks.

#### Returns

| Name | Type   | Description              |
|------|--------|--------------------------|
|      | Tensor | The blocks, `[N, E, E]`. |

#### Raises

| Name | Type | Description |
|----|----|----|
|  | StructureError | Implementations may raise it when $E$ is too large for dense blocks, as `SampleCov` and `FactorCov` do above `MAX_DENSE_EVENT`. |

### sample

``` python
core.OutputCov.sample(n_samples, /, *, generator=None)
```

Zero-mean draws from the covariance.

#### Parameters

| Name | Type | Description | Default |
|----|----|----|----|
| n_samples | int | Number of draws. | *required* |
| generator | torch.Generator \| None | The generator to draw with, on any device: the draws move to the covariance’s. `None` means torch’s global RNG. | `None` |

#### Returns

| Name | Type   | Description                            |
|------|--------|----------------------------------------|
|      | Tensor | The draws, `[n_samples, *mean.shape]`. |

#### Raises

| Name | Type | Description |
|----|----|----|
|  | ValueError | Implementations may raise it when they can’t give `n_samples` draws, as `SampleCov` does. |

### scaled

``` python
core.OutputCov.scaled(s, /)
```

The covariance times $s$.

#### Parameters

| Name | Type   | Description                           | Default    |
|------|--------|---------------------------------------|------------|
| s    | Tensor | The factor $s \ge 0$, a 0-dim tensor. | *required* |

#### Returns

| Name | Type | Description                    |
|------|------|--------------------------------|
|      | Self | A covariance of the same type. |
