import numpy as np rng = np.random.default_rng() rfloat = rng.random()
这里rng是一个缺省的
Generator
对象,每一个Generator对象有一个
BitGenerator的输入参数,上述
Generator对象的缺省
BitGenerator是PCG64,除了该
外,还有MT19937等PCG64
BitGenerator。
同时每一个BitGenerator也有一个seed参数,默认提供的seed可能质量比较低,可以通过
SeedSequence将低质量的种子转换为高质量的种子。
seed = get_user_seed() ss = SeedSequence(seed) print('seed = {}'.format(ss.entropy)) bg = PCG64(ss)