DIRT
DIRT(
self,
target_func: TargetFunc,
preconditioner: Preconditioner,
ftt: FTT,
bridge: Bridge | None = None,
options: DIRTOptions | None = None,
)Deep (squared) inverse Rosenblatt transport.
Parameters
target_func : TargetFunc-
The density function to be approximated.
preconditioner : Preconditioner-
An initial guess as to the mappings between the reference random variable and the target random variable.
ftt : FTT-
A functional tensor train object (used to construct each layer of the DIRT).
bridge : Bridge | None = None-
An object used to generate the ratio functions to approximate at each layer of the DIRT construction.
options : DIRTOptions | None = None-
Options which control the DIRT construction process.
Methods
| Name | Description |
|---|---|
| eval_potential | Evaluates the potential function. |
| eval_potential_cond | Evaluates the conditional potential function. |
| eval_rt | Evaluates the deep Rosenblatt transport. |
| eval_irt | Evaluates the deep inverse Rosenblatt transport. |
| eval_cirt | Evaluates the conditional inverse Rosenblatt transport. |
| eval_irt_pullback | Evaluates the pullback of a density function. |
| eval_cirt_pullback | Evaluates the pullback of a conditional density function. |
| random | Generates a set of random samples. |
| sobol | Generates a set of QMC samples. |
eval_potential
DIRT.eval_potential(
xs: Tensor,
subset: str | None = None,
num_layers: int | None = None,
)Evaluates the potential function.
Returns the joint potential function, or the marginal potential function for the first \(k\) variables or the last \(k\) variables, corresponding to the pullback of the reference measure under a given number of layers of the DIRT.
Parameters
xs : Tensor-
An \(n \times k\) matrix containing a set of samples from the approximation domain.
subset : str | None = None-
If the samples contain a subset of the variables, (i.e., \(k < d\)), whether they correspond to the first \(k\) variables (
subset='first') or the last \(k\) variables (subset='last'). num_layers : int | None = None-
The number of layers of the current DIRT construction to use when computing the potential. If not specified, all layers will be used when computing the potential.
Returns
neglogfxs : Tensor-
An \(n\)-dimensional vector containing the potential function of the target density evaluated at each element in
xs.
eval_potential_cond
DIRT.eval_potential_cond(
ys: Tensor,
xs: Tensor,
subset: str = 'first',
num_layers: int | None = None,
)Evaluates the conditional potential function.
Returns the conditional potential function evaluated at a set of samples in the approximation domain.
Parameters
ys : Tensor-
An \(n \times k\) matrix containing samples from the approximation domain.
xs : Tensor-
An \(n \times (d-k)\) matrix containing samples from the approximation domain.
subset : str = 'first'-
Whether
yscorresponds to the first \(k\) variables (subset='first') of the approximation, or the last \(k\) variables (subset='last'). num_layers : int | None = None-
The number of layers of the deep inverse Rosenblatt transport to push the samples forward under. If not specified, the samples will be pushed forward through all the layers.
Returns
neglogfxs : Tensor-
An \(n\)-dimensional vector containing the potential function of the approximation to the conditional density of \(X \textbar Y\) evaluated at each sample in
xs.
eval_rt
DIRT.eval_rt(
xs: Tensor,
subset: str | None = None,
num_layers: int | None = None,
)Evaluates the deep Rosenblatt transport.
Parameters
xs : Tensor-
An \(n \times k\) matrix of samples from the approximation domain.
subset : str | None = None-
If the samples contain a subset of the variables, (i.e., \(k < d\)), whether they correspond to the first \(k\) variables (
subset='first') or the last \(k\) variables (subset='last'). num_layers : int | None = None-
The number of layers of the deep inverse Rosenblatt transport to push the samples forward under. If not specified, the samples will be pushed forward through all the layers.
Returns
rs : Tensor-
An \(n \times k\) matrix containing the composition of mappings evaluated at each value of
xs. neglogfxs : Tensor-
An \(n\)-dimensional vector containing the potential function of the pullback of the reference density under the current composition of mappings evaluated at each sample in
xs.
eval_irt
DIRT.eval_irt(
rs: Tensor,
subset: str | None = None,
num_layers: int | None = None,
)Evaluates the deep inverse Rosenblatt transport.
Parameters
rs : Tensor-
An \(n \times k\) matrix containing samples from the reference domain.
subset : str | None = None-
If the samples contain a subset of the variables, (i.e., \(k < d\)), whether they correspond to the first \(k\) variables (
subset='first') or the last \(k\) variables (subset='last'). num_layers : int | None = None-
The number of layers of the deep inverse Rosenblatt transport to pull the samples back under. If not specified, the samples will be pulled back through all the layers.
Returns
xs : Tensor-
An \(n \times k\) matrix containing the corresponding samples from the approximation domain, after applying the deep inverse Rosenblatt transport.
neglogfxs : Tensor-
An \(n\)-dimensional vector containing the potential function of the pullback of the reference density under the current composition of mappings, evaluated at each sample in
xs.
eval_cirt
DIRT.eval_cirt(
ys: Tensor,
rs: Tensor,
subset: str = 'first',
num_layers: int | None = None,
)Evaluates the conditional inverse Rosenblatt transport.
Returns the conditional inverse Rosenblatt transport evaluated at a set of samples in the approximation domain.
Parameters
ys : Tensor-
A matrix containing samples from the approximation domain. The matrix should have dimensions \(1 \times k\) (if the same realisation of \(Y\) is to be used for all samples in
rs) or \(n \times k\) (if a different realisation of \(Y\) is to be used for each samples inrs). rs : Tensor-
An \(n \times (d-k)\) matrix containing samples from the reference domain.
subset : str = 'first'-
Whether
yscorresponds to the first \(k\) variables (subset='first') of the approximation, or the last \(k\) variables (subset='last'). num_layers : int | None = None-
The number of layers of the DIRT object to use when evaluating the CIRT. If not specified, all layers will be used.
Returns
xs : Tensor-
An \(n \times (d-k)\) matrix containing the realisations of \(X\) corresponding to the values of
rsafter applying the conditional inverse Rosenblatt transport. neglogfxs : Tensor-
An \(n\)-dimensional vector containing the potential function of the approximation to the conditional density of \(X \textbar Y\) evaluated at each sample in
xs.
eval_irt_pullback
DIRT.eval_irt_pullback(
potential: Callable[[Tensor], Tensor],
rs: Tensor,
subset: str | None = None,
num_layers: int | None = None,
)Evaluates the pullback of a density function.
This function evaluates \(\mathcal{T}^{\sharp}f(r)\), where \(\mathcal{T}(\cdot)\) denotes the inverse Rosenblatt transport and \(f(\cdot)\) denotes an arbitrary density function.
Parameters
potential : Callable[[Tensor], Tensor]-
A function that takes an \(n \times k\) matrix of samples from the approximation domain, and returns an \(n\)-dimensional vector containing the potential function associated with \(f(\cdot)\) evaluated at each sample.
rs : Tensor-
An \(n \times k\) matrix containing a set of samples from the reference domain.
subset : str | None = None-
If the samples contain a subset of the variables, (i.e., \(k < d\)), whether they correspond to the first \(k\) variables (
subset='first') or the last \(k\) variables (subset='last'). num_layers : int | None = None-
The number of layers of the deep inverse Rosenblatt transport to pull the samples back under. If not specified, the samples will be pulled back through all the layers.
Returns
neglogTfrs : Tensor-
An \(n\)-dimensional vector containing the potential of the pullback function evaluated at each element in
rs; that is, \(-\log(\mathcal{T}^{\sharp}f(r))\). neglogfxs : Tensor-
An \(n\)-dimensional vector containing the potential of the target function evaluated at each element in
rs, pushed forward under the IRT; that is, \(-\log(f(\mathcal{T}(r)))\).
eval_cirt_pullback
DIRT.eval_cirt_pullback(
potential: Callable[[Tensor], Tensor],
ys: Tensor,
rs: Tensor,
subset: str = 'first',
num_layers: int | None = None,
)Evaluates the pullback of a conditional density function.
This function evaluates \(\mathcal{T}^{\sharp}f(r\|y)\), where \(\mathcal{T}(\cdot)\) denotes the inverse Rosenblatt transport and \(f(\cdot\|y)\) denotes an arbitrary conditional density function.
Parameters
potential : Callable[[Tensor], Tensor]-
A function that takes an \(n \times (d-k)\) matrix of samples from the approximation domain, and returns an \(n\)-dimensional vector containing the potential function associated with \(f(\cdot\\|y)\) evaluated at each sample.
ys : Tensor-
A matrix containing samples from the approximation domain. The matrix should have dimensions \(1 \times k\) (if the same realisation of \(Y\) is to be used for all samples in
rs) or \(n \times k\) (if a different realisation of \(Y\) is to be used for each samples inrs). rs : Tensor-
An \(n \times (d-k)\) matrix containing a set of samples from the reference domain.
subset : str = 'first'-
Whether
yscorresponds to the first \(k\) variables (subset='first') of the approximation, or the last \(k\) variables (subset='last'). num_layers : int | None = None-
The number of layers of the deep inverse Rosenblatt transport to pull the samples back under. If not specified, the samples will be pulled back through all the layers.
Returns
neglogTfrs : Tensor-
An \(n\)-dimensional vector containing the potential of the pullback function evaluated at each element in
rs; that is, \(-\log(\mathcal{T}^{\sharp}f(r\\|y))\). neglogfxs : Tensor-
An \(n\)-dimensional vector containing the potential of the target function evaluated at each element in
rs, pushed forward under the IRT; that is, \(-\log(f(\mathcal{T}(r)\\|y))\).
random
DIRT.random(n: int)Generates a set of random samples.
The samples are distributed according to the DIRT approximation to the target density.
Parameters
n : int-
The number of samples to generate.
Returns
xs : Tensor-
An \(n \times d\) matrix containing the generated samples.
sobol
DIRT.sobol(n: int)Generates a set of QMC samples.
The samples are distributed according to the DIRT approximation to the target density.
Parameters
n : int-
The number of samples to generate.
Returns
xs : Tensor-
An \(n \times d\) matrix containing the generated samples.