scipy.stats.qmc.QMCEngine.
integers#
- QMCEngine.integers(l_bounds, *, u_bounds=None, n=1, endpoint=False, workers=1)[source]#
從 l_bounds (包含) 到 u_bounds (不包含) 繪製 n 個整數,或者如果 endpoint=True,則從 l_bounds (包含) 到 u_bounds (包含)。
- 參數:
- l_boundsint 或 類似陣列的 int
要繪製的最小(帶符號)整數(除非
u_bounds=None
,在這種情況下,此參數為 0,並且此值用於 u_bounds)。- u_boundsint 或 類似陣列的 int,可選
如果提供,則為要繪製的最大(帶符號)整數之上的一個整數(有關
u_bounds=None
時的行為,請參閱上文)。如果類似陣列,則必須包含整數值。- nint,可選
要在參數空間中產生的樣本數。預設值為 1。
- endpointbool,可選
如果為 true,則從區間
[l_bounds, u_bounds]
而不是預設的[l_bounds, u_bounds)
中取樣。預設值為 False。- workersint,可選
用於平行處理的 worker 數量。如果給定 -1,則使用所有 CPU 執行緒。僅在使用
Halton
時支援。預設值為 1。
- 返回:
- samplearray_like (n, d)
QMC 樣本。
註解
可以安全地將相同的
[0, 1)
到整數的映射與 QMC 一起使用,就像您將與 MC 一起使用一樣。您仍然會獲得不偏性、強大數法則、漸近無限的變異數縮減和有限樣本變異數界限。要將樣本從 \([0, 1)\) 轉換為 \([a, b), b>a\),其中 \(a\) 是下界,\(b\) 是上界,使用以下轉換
\[\text{floor}((b - a) \cdot \text{sample} + a)\]