>>> np.random.randn() 2.1923875335537315 #random
生成正态分布矩阵:For random samples from
, use:
sigma * np.random.randn(...) + mu
2.5 * np.random.randn(2, 4) + 3 #生成2行4列的符合(3,2.5^2)正态分布矩阵 其中u=3 σ=2.5 array([[-4.49401501, 4.00950034, -1.81814867, 7.29718677], #random [ 0.39924804, 4.68456316, 4.99394529, 4.84057254]]) #randomrandn(30)生成6*5矩阵 N~(0,1) randn(50)生成10*5矩阵matplotlib中注解函数
# annotate参数说明:xy = (2, 1) :所要标注的位置坐标
# xytext:标注文本所在位置
# arrowprops:标注箭头属性信息(它的内用可以自己试验一下)
# ‘local max':标注文本,可以随意替换annotate(r'$\cos(\frac{2\pi}{3})=-\frac{1}{2}$', xy=(t, np.cos(t)), xycoords='data', xytext=(-90, -50), textcoords='offset points', fontsize=16, arrowprops=dict(arrow, connection))matplotlib中画点函数解析
t = 2 * np.pi / 3 #第一个参数点的横坐标集合 #第二个参数点的纵坐标集合 #第三个参数该点的半径大小 #第四个参数该点的颜色 scatter([t, t], [np.cos(t), np.sin(t)], 20, color='red')# 该函数意义为从(t,0)-(t,np.sin(t))画虚线 # 第一个参数为所有点的x坐标集合 # 第二个参数为所有点的y坐标集合 plot([t, t], [0, np.sin(t)], color='red', linewidth=2.5, line)
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/hz/133077.html