# core.SampleCov

``` python
core.SampleCov(draws)
```

Zero-mean draws $J z_s$, $z_s \sim \mathcal{N}(0, \Sigma)$. For large output events.

$J$ is the Jacobian of the outputs and $\Sigma$ the weight covariance. The moments are empirical, computed from the stored draws.

## Parameters

| Name  | Type   | Description                      | Default    |
|-------|--------|----------------------------------|------------|
| draws | Tensor | The $S$ draws, `[S, N, *event]`. | *required* |

## Methods

| Name | Description |
|----|----|
| [diagonal](#laplacekit.core.SampleCov.diagonal) | The mean of the squared draws, `[N, *event]`. |
| [per_input](#laplacekit.core.SampleCov.per_input) | The mean outer product of the draws, per input. |
| [sample](#laplacekit.core.SampleCov.sample) | `n_samples` of the stored draws, chosen at random without replacement. |
| [scaled](#laplacekit.core.SampleCov.scaled) | The draws times $\sqrt{s}$. |

### diagonal

``` python
core.SampleCov.diagonal()
```

The mean of the squared draws, `[N, *event]`.

#### Returns

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

### per_input

``` python
core.SampleCov.per_input()
```

The mean outer product of the draws, per input.

#### Returns

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

#### Raises

| Name | Type | Description |
|----|----|----|
|  | StructureError | An input has more than `MAX_DENSE_EVENT` output entries. |

### sample

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

`n_samples` of the stored draws, chosen at random without replacement.

#### Parameters

| Name | Type | Description | Default |
|----|----|----|----|
| n_samples | int | Number of draws. | *required* |
| generator | torch.Generator \| None | The generator that picks them, on any device. `None` means torch’s global RNG. | `None` |

#### Returns

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

#### Raises

| Name | Type       | Description                                                |
|------|------------|------------------------------------------------------------|
|      | ValueError | `n_samples` is larger than the number of stored draws $S$. |

### scaled

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

The draws times $\sqrt{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. |
