Compositional input warping for GPs

Warped Gaussian Distribution

class vanguard.warps.distribution.WarpedGaussian(warp, *args, **kwargs)[source]

Bases: Normal

A warped Gaussian distribution.

\[X\sim \mathcal{WN}(\psi; \mu, \sigma) ~ \iff \psi(X)\sim\mathcal{N}(\mu, \sigma).\]
Parameters:
__init__(warp, *args, **kwargs)[source]
Parameters:
  • warp` – The warp to be used to define the distribution.

  • warp (WarpFunction)

  • args (Any)

  • kwargs (Any)

enumerate_support(expand=True)[source]

Returns tensor containing all values supported by a discrete distribution. The result will enumerate over dimension 0, so the shape of the result will be (cardinality,) + batch_shape + event_shape (where event_shape = () for univariate distributions).

Note that this enumerates over all batched tensors in lock-step [[0, 0], [1, 1], …]. With expand=False, enumeration happens along dim 0, but with the remaining batch dimensions being singleton dimensions, [[0], [1], ...

To iterate over the full Cartesian product use itertools.product(m.enumerate_support()).

Args:
expand (bool): whether to expand the support over the

batch dims to match the distribution’s batch_shape.

Returns:

Tensor iterating over dimension 0.

Parameters:

expand (bool)

Return type:

Tensor

classmethod from_data(warp, samples, optimiser=<class 'torch.optim.adam.Adam'>, n_iterations=100, lr=0.001)[source]

Fit a warped Gaussian distribution to the given data using the supplied warp.

The mean and variance will be optimised along with the free parameters of the warp.

Parameters:
Return type:

Self

Returns:

A fit distribution.

log_prob(value)[source]

Calculate the log-probability of the values under the warped Gaussian distribution.

Parameters:

value (Tensor) – Shape should be compatible with the distributions shape.

Return type:

Tensor

Returns:

The log probability of the values.

sample(*args, **kwargs)[source]

Sample from the distribution.

Parameters:

Input Warping

Contains the Python decorators for applying input warping.

class vanguard.warps.input.SetInputWarp(warp_function, **kwargs)[source]

Apply input warping to a GP to achieve non-Gaussian input uncertainty.

Example:
>>> from vanguard.base import GPController
>>> from vanguard.warps.warpfunctions import BoxCoxWarpFunction
>>>
>>> @SetInputWarp(BoxCoxWarpFunction(1))
... class MyController(GPController):
...     pass
Parameters:
__init__(warp_function, **kwargs)[source]

Initialise self.

Parameters:
  • warp_function (WarpFunction) – The warp function to be applied to the GP inputs.

  • kwargs (Any) – Keyword arguments passed to Decorator.

property safe_updates: dict[type, set[str]]

Get a dictionary (class -> set[names]) of overrides/new methods that we consider “safe”.