np.random.normal()
函数语法:
np.random.normal(loc=0.0, scale=1.0, size=None)
参数解释:
loc(float):此概率分布的均值(对应着整个分布的中心)loc=0说明这一个以Y轴为对称轴的正态分布;
scale(float):此概率分布的标准差(对应于分布的宽度,scale越大,图形越矮胖;scale越小,图形越瘦高)
size(int or tuple of ints):输出的shape,默认为None,只输出一个值
一维数组案例:
np.random.normal(loc=0, scale=0.1, size=(6,))
输出结果为(随机值):
array([ 0.09736213, -0.03682408, -0.09351674, -0.01328731, -0.07754017, -0.06989368])
二维数组案例:
np.random.normal(loc=0, scale=0.1, size=(6,9))
输出结果为(随机值):
array([[ 0.14108501, 0.02065082, -0.02172175, -0.03566968, -0.1094184 , 0.10293469, -0.01514898, 0.1311312 , 0.02048962], [ 0.02085788, 0.19274365, 0.06129001, 0.03252575, 0.01168505, -0.04672872, -0.07054097, 0.00920761, -0.20387396], [-0.05845842, 0.16218316, -0.05721935, -0.16218828, 0.15147394, 0.10821882, -0.15191695, -0.07859211, -0.05901268], [-0.07774481, 0.14025618, 0.06106578, -0.02571557, -0.05214018, 0.19703169, 0.04401803, -0.02625809, -0.0375809 ], [-0.06675171, -0.04819038, -0.03322535, -0.00253635, -0.09559504, 0.08110814, -0.22089351, -0.07093244, 0.05891612], [-0.08564555, -0.09143438, 0.13916872, -0.14321324, -0.00169849, 0.03734903, -0.00843369, -0.0436277 , -0.07125109]])
原创文章,作者:朋远方,如若转载,请注明出处:https://caovan.com/01-yongyushujukexuede-python-jichuzhishi/.html