什么是python和numpy中的随机数生成器? [英] What is the random number generator in python and numpy?
问题描述
import random
import numpy.random
random
和numpy.random
的算法是什么.通常,Mersenne Twister是Matlab的默认生成器,可以选择使用哪种生成器. python呢,随机生成器有选择吗?
What is the algorithm for random
and numpy.random
. Usually Mersenne Twister is the default generator for matlab, and there are choice to choose which generator to use. What about python, is there a choice for random generator?
推荐答案
两者 numpy.random
使用Mersenne Twister.
Both cpython random
and numpy.random
use Mersenne Twister.
cpython random
和 numpy.random
在UNIX上使用/dev/(u)random
和Windows上的CryptGenRandom
来获取熵.
Both cpython random
and numpy.random
use /dev/(u)random
on UNIX and CryptGenRandom
on Windows for entropy.
Cpython允许使用Wichman Hill 作为替代PRNG ,numpy则不会(但是您可以使用random.WichmanHill
来填充先前分配的数组).
Cpython allows to use Wichman Hill as an alternative PRNG, numpy does not (however you can use random.WichmanHill
to fill a previously allocated array).
这篇关于什么是python和numpy中的随机数生成器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!