本文簡要介紹 python 語言中 numpy.random.SeedSequence
的用法。
用法:
class numpy.random.SeedSequence(entropy=None, *, spawn_key=(), pool_size=4)
SeedSequence 以可重現的方式混合熵源,為獨立且很可能不重疊的 BitGenerators 設置初始狀態。
一旦實例化SeedSequence,您就可以調用
generate_state
方法來獲取適當大小的種子。調用spawn(n)
將創建n
SeedSequences,可用於播種獨立的BitGenerators,即用於不同的線程。- entropy: {無,整數,序列[整數]},可選
創建
SeedSequence
的熵。- spawn_key: {(),序列[int]},可選
第三個熵源,在調用
SeedSequence.spawn
時在內部使用- pool_size: {int},可選
要存儲的合並熵的大小。默認值為 4 以提供 128 位熵池。如果使用較大的 PRNG,8(對於 256 位)是另一個合理的選擇,但選擇另一個值幾乎沒有什麽好處。
- n_children_spawned: {int},可選
已經產卵的孩子數量。僅當從序列化形式重建
SeedSequence
時才傳遞此參數。
參數:
注意:
實現可重現比特流的最佳實踐是使用默認
None
作為初始熵,然後使用SeedSequence.entropy
記錄/ pickleentropy
以實現重現性:>>> sq1 = np.random.SeedSequence() >>> sq1.entropy 243799254704924441050048792905230269161 # random >>> sq2 = np.random.SeedSequence(sq1.entropy) >>> np.all(sq1.generate_state(10) == sq2.generate_state(10)) True
- entropy:
- n_children_spawned:
- pool:
- pool_size:
- spawn_key:
- state:
屬性:
相關用法
- Python numpy random.mtrand.RandomState.wald用法及代碼示例
- Python numpy random.mtrand.RandomState.multivariate_normal用法及代碼示例
- Python numpy random.standard_exponential用法及代碼示例
- Python numpy random.mtrand.RandomState.gumbel用法及代碼示例
- Python numpy random.mtrand.RandomState.multinomial用法及代碼示例
- Python numpy random.rand用法及代碼示例
- Python numpy random.mtrand.RandomState.logistic用法及代碼示例
- Python numpy random.mtrand.RandomState.shuffle用法及代碼示例
- Python numpy random.triangular用法及代碼示例
- Python numpy random.noncentral_f用法及代碼示例
- Python numpy random.mtrand.RandomState.poisson用法及代碼示例
- Python numpy random.lognormal用法及代碼示例
- Python numpy random.mtrand.RandomState.seed用法及代碼示例
- Python numpy random.mtrand.RandomState.triangular用法及代碼示例
- Python numpy random.gumbel用法及代碼示例
- Python numpy random.mtrand.RandomState.weibull用法及代碼示例
- Python numpy random.shuffle用法及代碼示例
- Python numpy random.geometric用法及代碼示例
- Python numpy random.multinomial用法及代碼示例
- Python numpy random.logseries用法及代碼示例
- Python numpy random.mtrand.RandomState.rand用法及代碼示例
- Python numpy random.mtrand.RandomState.power用法及代碼示例
- Python numpy random.mtrand.RandomState.randint用法及代碼示例
- Python numpy random.chisquare用法及代碼示例
- Python numpy random.mtrand.RandomState.choice用法及代碼示例
注:本文由純淨天空篩選整理自numpy.org大神的英文原創作品 numpy.random.SeedSequence。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。