我正在尝试使用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做到这一点?还是有另一种方法可以做到这一点?