SobolEngine#
- class torch.quasirandom.SobolEngine(dimension, scramble=False, seed=None)[source]#
The
torch.quasirandom.SobolEngine
是一个生成(打散的)Sobol序列的引擎。Sobol序列是低差异拟随机序列的例子。此 Sobol 序列引擎实现能够采样高达 21201 维度的序列。它使用了来自 https://web.maths.unsw.edu.au/~fkuo/sobol/ 的方向数,这些方向数是通过搜索准则 D(6) 获得的,最高可达 21201 维度。这是作者推荐的选择。
参考文献
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) – 要绘制的序列的维度
scramble (bool, optional) – 将此设置为
True
将生成打散的 Sobol 序列。打散能够生成更好的 Sobol 序列。默认为False
。seed (Int, optional) – 这是打散的种子。如果指定了此参数,则随机数生成器的种子将被设置为此值。否则,它会使用随机种子。默认为
None
示例
>>> 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]#
从 Sobol 序列中抽取
n
个点序列的函数。请注意,样本依赖于之前的样本。结果的大小为 。- 参数
n (Int, optional) – 要抽取的点序列的长度。默认为 1
out (Tensor, optional) – 输出张量
dtype (
torch.dtype
, optional) – 返回张量的所需数据类型。默认为None
- 返回类型
- draw_base2(m, out=None, dtype=None)[source]#
从 Sobol 序列中抽取
2**m
个点序列的函数。请注意,样本依赖于之前的样本。结果的大小为 。- 参数
m (Int) – 要抽取的点数的(以 2 为底的)指数。
out (Tensor, optional) – 输出张量
dtype (
torch.dtype
, optional) – 返回张量的所需数据类型。默认为None
- 返回类型