Preconditioner
self, reference: Reference, dim: int) Preconditioner(
The base class for preconditioning mappings.
Ideally, the pushforward of the reference density under the preconditioning mapping will be as similar as possible to the target density; this makes the subsequent construction of the DIRT approximation to the target density more efficient.
The mapping, which we denote using \(Q(\cdot)\), needs to be invertible. There are additional benefits if the mapping is lower or upper triangular (or both):
- If the mapping is lower triangular, one can evaluate the marginal densities of the corresponding DIRT object in the first \(k\) variables, and condition on the first \(k\) variables, where \(1 \leq k < d\).
- If the mapping is upper triangular, one can evaluate the marginal densities of the corresponding DIRT object in the last \(k\) variables, and condition on the final \(k\) variables, where \(1 \leq k < d\).
Parameters
reference : Reference
-
The density of the reference random variable.
dim : int
-
The dimension, \(d\), of the target (and reference) random variable.
Notes
To construct a custom preconditioning mapping, the user must construct a class derived from this class with methods Q()
, Q_inv()
, neglogdet_Q()
, and neglogdet_Q_inv()
.
Methods
Name | Description |
---|---|
Q | Applies the mapping \(Q(\cdot)\) to a set of samples. |
Q_inv | Applies the mapping \(Q^{-1}(\cdot)\) to a set of samples. |
neglogdet_Q | Applies the mapping \(Q(\cdot)\) to a set of samples. |
neglogdet_Q_inv | Applies the mapping \(Q^{-1}(\cdot)\) to a set of samples. |
Q
str | None = None) Preconditioner.Q(us: Tensor, subset:
Applies the mapping \(Q(\cdot)\) to a set of samples.
Parameters
us : Tensor
-
An \(n \times k\) matrix containing samples from the reference domain.
subset : str | None = None
-
If \(k < d\), whether the samples are samples of the first (
subset='first'
) or last (subset='last'
) \(k\) variables.
Returns
xs : Tensor
-
An \(n \times k\) matrix containing samples from the approximation domain, after applying the mapping \(Q(\cdot)\) to each sample.
Q_inv
str | None = None) Preconditioner.Q_inv(xs: Tensor, subset:
Applies the mapping \(Q^{-1}(\cdot)\) to a set of samples.
Parameters
xs : Tensor
-
An \(n \times k\) matrix containing samples from the approximation domain.
subset : str | None = None
-
If \(k < d\), whether the samples are samples of the first (
subset='first'
) or last (subset='last'
) \(k\) variables.
Returns
us : Tensor
-
An \(n \times k\) matrix containing samples from the reference domain, after applying the mapping \(Q^{-1}(\cdot)\) to each sample.
neglogdet_Q
str | None = None) Preconditioner.neglogdet_Q(us: Tensor, subset:
Applies the mapping \(Q(\cdot)\) to a set of samples.
Parameters
us : Tensor
-
An \(n \times k\) matrix containing samples from the reference domain.
subset : str | None = None
-
If \(k < d\), whether the samples are samples of the first (
subset='first'
) or last (subset='last'
) \(k\) variables.
Returns
neglogdets : Tensor
-
An \(n\)-dimensional vector containing the negative log-determinant of \(Q(\cdot)\) evaluated at each sample.
neglogdet_Q_inv
str | None = None) Preconditioner.neglogdet_Q_inv(xs: Tensor, subset:
Applies the mapping \(Q^{-1}(\cdot)\) to a set of samples.
Parameters
xs : Tensor
-
An \(n \times k\) matrix containing samples from the approximation domain.
subset : str | None = None
-
If \(k < d\), whether the samples are samples of the first (
subset='first'
) or last (subset='last'
) \(k\) variables.
Returns
neglogdets : Tensor
-
An \(n\)-dimensional vector containing the negative log-determinant of \(Q^{-1}(\cdot)\) evaluated at each sample.