random.randint和numpy.random.randint

版权声明:作者:Britesun 欢迎转载,与人分享是进步的源泉! https://blog.csdn.net/qq_34807908/article/details/82025312
  • random.randint()的函数原型为:random.randint(a, b),用于生成一个指定范围内的整数。其中参数a是下限,参数b是上限,生成的随机数n: a <= n <= b

  • numpy.random.randint()的函数原型为:numpy.random.randint(low,high=None,size=None,dtype) 生成在半开半闭区间[low,high)上离散均匀分布的整数值;若high=None,则取值区间变为[0,low)
    numpy.random.randint(a, b)返回开区间 [a, b)范围内的整数值,生成的随机数n: a <= n < b
    这里写图片描述

  • numpy.random.randint(low, high, size)
    low、high、size三个参数。默认high是None,如果只有low,那范围就是[0,low)。如果有high,范围就是[low,high);size是输出数组的维度(形状),可以是列表,或者元组
    这里写图片描述

猜你喜欢

转载自blog.csdn.net/qq_34807908/article/details/82025312