numpy是否可以生成大于64位的随机数?

时间:2019-03-14 04:34:39

标签: python python-3.x numpy

我正在尝试使用numpy.random.randint从均匀分布中抽样随机数。但是,有时大小会大于64位整数,并且会产生numpy扼流圈:

>>> np.random.randint(0, 371993326789901217467999448150835200000000)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "mtrand.pyx", line 991, in mtrand.RandomState.randint
ValueError: high is out of bounds for int64

我认为这就是引入dtype的原因,但是无论我尝试哪种类型,它仍然会给出相同的错误:

>>> np.random.randint(0, 371993326789901217467999448150835200000000, dtype=np.long)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "mtrand.pyx", line 991, in mtrand.RandomState.randint
ValueError: high is out of bounds for int64

有没有办法用numpy做到这一点?还是有另一种方法可以做到这一点?

0 个答案:

没有答案