一篇优秀的文章——资源无处不在https://www.cnblogs.com/chenhuabin/p/11412818.html
完整的学习文档https://www.osgeo.cn/numpy/user/quickstart.html
1、np.random.random()
系列函数:
(1) np.random.rand():随机生成均匀分布的[0,1]的随机小数
(2) np.random.randint()、np.random.ranom.random_integers():生成均匀分布的整数。根据所传的参数,前者范围为[start,end),后者为[start,end]
(3) np.random.random()、np.random.sanmple() 、np.random.random_sanmple() 、np.random.randf():生成随机浮点数,取值范围:[0,1)
(4) np.random.randn():随机生成服从正态分布~N(0,1)的浮点数
2、numpy
的字符串切片,非常清晰明了的图
3、浅复制copy与==
的区别
"=="
,联动
>>> a = np.arange(12)
>>> b = a # 赋值
>>> a is b
True
>>> b.shape = (3, 4)
>>> b
array([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11]])
>>> a
array([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11]])
copy
,岿然不动
>>> a = np.arange(12)
>>> b = a.view() # 使用视图
>>> a is b
False
>>> b
array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])
>>> b.shape = (3, 4) # 改变b的形状
>>> a
array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])
>>> b
array([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11]])
>>> b[0] = 0
>>> a
array([ 0, 0, 0, 0, 4, 5, 6, 7, 8, 9, 10, 11])
>>> b
array([[ 0, 0, 0, 0],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11]])