numpy用法:numpy.random.randint

这篇博客介绍了如何使用numpy.random.randint函数生成指定范围内的随机整数,并给出了多个示例,包括创建不同形状的数组。同时,文章还提到了numpy.linspace函数用于等间距取值的用法,以及matplotlib库在绘制图形上的应用,如直方图。
摘要由CSDN通过智能技术生成

https://www.w3cschool.cn/doc_numpy_1_12/numpy_1_12-generated-numpy-random-randint.html

numpy.random.randint(low, high=None, size=None, dtype=‘l’)
Return random integers from low (inclusive) to high (exclusive).

Return random integers from the “discrete uniform” distribution of the specified dtype in the “half-open” interval [low, high). If high is None (the default), then results are from [0, low).

np.random.randint(5, size=(2, 4))
array([[4, 0, 2, 1],
[3, 2, 2, 0]])
np.random.randint(2, size=10)
array([1, 0, 0, 0, 1, 1, 0, 0, 1, 0])

np.random.randint(1, size=10)
array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])

‘’‘生成0~100的随机数作为样本’’’
pop = np.random.randint(0,100,100)
pop

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值