什么是python和numpy中的随机数生成器? [英] What is the random number generator in python and numpy?

查看:263
本文介绍了什么是python和numpy中的随机数生成器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

import random
import numpy.random

randomnumpy.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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆