Rate this Page

SobolEngine#

classtorch.quasirandom.SobolEngine(dimension,scramble=False,seed=None)[source]#

Thetorch.quasirandom.SobolEngine is an engine for generating(scrambled) Sobol sequences. Sobol sequences are an example of lowdiscrepancy quasi-random sequences.

This implementation of an engine for Sobol sequences is capable ofsampling sequences up to a maximum dimension of 21201. It uses directionnumbers fromhttps://web.maths.unsw.edu.au/~fkuo/sobol/ obtained using thesearch criterion D(6) up to the dimension 21201. This is the recommendedchoice by the authors.

References

  • 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 accurateevaluation of integrals.Zh. Vychisl. Mat. i Mat. Phys., 7:784-802, 1967.

Parameters
  • dimension (Int) – The dimensionality of the sequence to be drawn

  • scramble (bool,optional) – Setting this toTrue will producescrambled Sobol sequences. Scrambling iscapable of producing better Sobolsequences. Default:False.

  • seed (Int,optional) – This is the seed for the scrambling. The seedof the random number generator is set to this,if specified. Otherwise, it uses a random seed.Default:None

Examples:

>>>soboleng=torch.quasirandom.SobolEngine(dimension=5)>>>soboleng.draw(3)tensor([[0.0000, 0.0000, 0.0000, 0.0000, 0.0000],        [0.5000, 0.5000, 0.5000, 0.5000, 0.5000],        [0.7500, 0.2500, 0.2500, 0.2500, 0.7500]])
draw(n=1,out=None,dtype=None)[source]#

Function to draw a sequence ofn points from a Sobol sequence.Note that the samples are dependent on the previous samples. The sizeof the result is(n,dimension)(n, dimension).

Parameters
  • n (Int,optional) – The length of sequence of points to draw.Default: 1

  • out (Tensor,optional) – The output tensor

  • dtype (torch.dtype, optional) – the desired data type of thereturned tensor.Default:None

Return type

Tensor

draw_base2(m,out=None,dtype=None)[source]#

Function to draw a sequence of2**m points from a Sobol sequence.Note that the samples are dependent on the previous samples. The sizeof the result is(2m,dimension)(2**m, dimension).

Parameters
  • m (Int) – The (base2) exponent of the number of points to draw.

  • out (Tensor,optional) – The output tensor

  • dtype (torch.dtype, optional) – the desired data type of thereturned tensor.Default:None

Return type

Tensor

fast_forward(n)[source]#

Function to fast-forward the state of theSobolEngine byn steps. This is equivalent to drawingn sampleswithout using the samples.

Parameters

n (Int) – The number of steps to fast-forward by.

reset()[source]#

Function to reset theSobolEngine to base state.