Numpy补充1(random)

import numpy as np
#np.random.normal(loc,scale,size)loc:均值,scale:标准差,size
a=np.random.normal(0,1,[3,3])
print(a)
"""[[-1.01790376 -0.40799346  0.00415742]
 [ 0.68951924 -0.27962098 -0.71226574]
 [-2.17177824 -0.75665673 -0.9358477 ]]"""
#np.random.uniform(low,high,size)从一个均匀分布[low,high)中随机采样。size是int类型或者tuple
a=np.random.uniform(1,2,10)
print(a)
"""[1.86654332 1.07251167 1.24567232 1.0030098  1.5985645  1.40962215
 1.0442022  1.57880712 1.85671955 1.08382754]"""
#产生随机整数
a=np.random.randint(1,10,(3,2))
print(a)
"""[[8 7]
 [5 2]
 [7 4]]"""
#在闭区间上产生随机整数
a=np.random.random_integers(1,10,(3,2))
print(a)
"""[[ 8  6]
 [ 7 10]
 [ 5 10]]"""

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值