NumpyRNGContext¶
- class astropy.utils.misc.NumpyRNGContext(seed)[ソース]¶
ベースクラス:
object
コンテキストマネージャ(と
with
文)は,デジタル乱数生成器(RNG)を特定の値に設定し,RNG状態を以前の状態に戻す.これは主に星間テストセットで使用するためであるが,モンテカルロシミュレーションの科学的背景下での再現性を確保する上で有用である可能性がある。
- パラメータ
- seed集積する.
Numpy RNG種子を設定するための値
実例.
典型的な使用例は
with NumpyRNGContext(<some seed value you pick>): from numpy import random randarr = random.randn(100) ... run your test using `randarr` ... #Any code using numpy.random at this indent level will act just as it #would have if it had been before the with statement - e.g. whatever #the default seed is.