numpy rand randn

numpy.random.randn()

import numpy as np
print(np.random.rand(5,5))

随机生成的结果

[[0.30819634 0.56391944 0.00456188 0.34257512 0.92346913]
 [0.19165846 0.80794476 0.95644317 0.03782372 0.56703904]
 [0.48562555 0.46470402 0.73034291 0.20103078 0.25895095]
 [0.56059468 0.36032061 0.77386907 0.08395726 0.41184531]
 [0.43837033 0.61163308 0.57600399 0.36423174 0.55719615]]
import numpy as np
print(np.random.randn(5,5))

随机生成的结果

[[ 1.08220285 -0.64341078 -0.39921111 -0.24039955 -0.22294299]
 [ 0.75884996  0.83006651 -0.03750708  0.23933474 -1.65981367]
 [-0.0129976   0.55587384  1.00970429 -0.3575224  -2.2324373 ]
 [-0.51980036 -0.90226635  0.90852877  0.52404465  0.43280609]
 [-0.75421884 -0.84320439 -0.05095735 -1.01362965  0.2944501 ]]

numpy.random.randn(x1,x2,x3.....)是从标准正态分布中返回一个或多个样本值。
numpy.random.rand(x1,x2,x3.....)的随机样本位于[0, 1)中。

###################

QQ 3087438119
原文地址:https://www.cnblogs.com/herd/p/14986754.html