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