botorch.qmc

botorch.qmc.normal

Quasi Monte-Carlo sampling from Normal distributions.

References:

[Pages2018numprob](1, 2) G. Pages. Numerical Probability: An Introduction with Applications to Finance. Universitext. Springer International Publishing, 2018.

NormalQMCEngine

class botorch.qmc.normal.NormalQMCEngine(d, seed=None, inv_transform=False)[source]

Engine for qMC sampling from a Multivariate Normal N(0, I_d).

By default, this implementation uses Box-Muller transformed Sobol samples following pg. 123 in [Pages2018numprob]. To use the inverse transform instead, set inv_transform=True.

Example

>>> engine = NormalQMCEngine(3)
>>> samples = engine.draw(10)

Engine for drawing qMC samples from a multivariate normal N(0, I_d).

Parameters:
  • d (int) – The dimension of the samples.
  • seed (Optional[int]) – The seed with which to seed the random number generator of the underlying SobolEngine.
  • inv_transform (bool) – If True, use inverse transform instead of Box-Muller.
draw(n=1, out=None, dtype=torch.float32)[source]

Draw n qMC samples from the standard Normal.

Parameters:
  • n (int) – The number of samples to draw.
  • out (Optional[Tensor]) – An option output tensor. If provided, draws are put into this tensor, and the function returns None.
  • dtype (dtype) – The desired torch data type (ignored if out is provided).
Return type:

Optional[Tensor]

Returns:

A n x d tensor of samples if out=None and None otherwise.

MultivariateNormalQMCEngine

class botorch.qmc.normal.MultivariateNormalQMCEngine(mean, cov, seed=None, inv_transform=False)[source]

Engine for qMC sampling from a multivariate Normal N(mu, Sigma).

By default, this implementation uses Box-Muller transformed Sobol samples following pg. 123 in [Pages2018numprob]. To use the inverse transform instead, set inv_transform=True.

Example

>>> mean = torch.tensor([1.0, 2.0])
>>> cov = torch.tensor([[1.0, 0.25], [0.25, 2.0]])
>>> engine = MultivariateNormalQMCEngine(mean, cov)
>>> samples = engine.draw(10)

Engine for qMC sampling from a multivariate Normal N(mu, Sigma).

Parameters:
  • mean (Tensor) – The mean vector.
  • cov (Tensor) – The covariance matrix.
  • seed (Optional[int]) – The seed with which to seed the random number generator of the underlying SobolEngine.
  • inv_transform (bool) – If True, use inverse transform instead of Box-Muller.
draw(n=1, out=None)[source]

Draw n qMC samples from the multivariate Normal.

Parameters:
  • n (int) – The number of samples to draw.
  • out (Optional[Tensor]) – An option output tensor. If provided, draws are put into this tensor, and the function returns None.
Return type:

Optional[Tensor]

Returns:

A n x d tensor of samples if out=None and None otherwise.