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/ 的方向數,這些方向數是使用搜索準則 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][source]¶
從 Sobol 序列中繪製
n個點組成的序列的函式。請注意,樣本依賴於先前的樣本。結果的大小為 。- 引數
n (Int, optional) – 要繪製的點序列的長度。預設值:1
out (Tensor, optional) – 輸出張量
dtype (
torch.dtype, optional) – 返回張量所需的資料型別。預設值:None
- 返回型別
- draw_base2(m, out=None, dtype=None)[source][source]¶
從 Sobol 序列中繪製
2**m個點組成的序列的函式。請注意,樣本依賴於先前的樣本。結果的大小為 。- 引數
m (Int) – 要繪製點數的 (以 2 為底的) 指數。
out (Tensor, optional) – 輸出張量
dtype (
torch.dtype, optional) – 返回張量所需的資料型別。預設值:None
- 返回型別