-
官方文档
numpy.random.randint(low, high=None, size=None, dtype='l')
low (inclusive) to high (exclusive)的随机整数。
如果默认high=None,则取[0, low)
-
Parameters
-
low
从分布中提取的最小的整数
-
high
分布中提取的最大值
-
size:int or tuple of ints, optional
输出形态,例如(m,n,k),默认为None,表示给出单值
-
dtype:dtype, optional
获得的数据类型
返回值:int or ndarray of ints。size-shaped array
-
-
示例
np.random.randint(5, size=(2, 4)) array([[4, 0, 2, 1], [3, 2, 2, 0]])
np.random.randint()详解
最新推荐文章于 2024-05-03 20:40:51 发布