SobolEngine(dimension, scramble=False, seed=None)¶
torch.quasirandom.SobolEngineis an engine for generating (scrambled) Sobol sequences. Sobol sequences are an example of low discrepancy quasi-random sequences.
This implementation of an engine for Sobol sequences is capable of sampling sequences up to a maximum dimension of 1111. It uses direction numbers to generate these sequences, and these numbers have been adapted from here.
Art B. Owen. Scrambling Sobol and Niederreiter-Xing points. Journal of Complexity, 14(4):466-489, December 1998.
I. M. Sobol. The distribution of points in a cube and the accurate evaluation of integrals. Zh. Vychisl. Mat. i Mat. Phys., 7:784-802, 1967.
dimension (Int) – The dimensionality of the sequence to be drawn
scramble (bool, optional) – Setting this to
Truewill produce scrambled Sobol sequences. Scrambling is capable of producing better Sobol sequences. Default:
seed (Int, optional) – This is the seed for the scrambling. The seed of the random number generator is set to this, if specified. Otherwise, it uses a random seed. Default:
>>> soboleng = torch.quasirandom.SobolEngine(dimension=5) >>> soboleng.draw(3) tensor([[0.5000, 0.5000, 0.5000, 0.5000, 0.5000], [0.7500, 0.2500, 0.7500, 0.2500, 0.7500], [0.2500, 0.7500, 0.2500, 0.7500, 0.2500]])
draw(n=1, out=None, dtype=torch.float32)¶
Function to draw a sequence of
npoints from a Sobol sequence. Note that the samples are dependent on the previous samples. The size of the result is .
n (Int, optional) – The length of sequence of points to draw. Default: 1
out (Tensor, optional) – The output tensor
torch.dtype, optional) – the desired data type of the returned tensor. Default:
Function to fast-forward the state of the
nsteps. This is equivalent to drawing
nsamples without using the samples.
n (Int) – The number of steps to fast-forward by.
Function to reset the
SobolEngineto base state.