https://blog.csdn.net/christianashannon/article/details/78867204
1、np.random.rand 用於生成[0.0, 1.0)之間的隨機浮點數, 當沒有參數時,返回一個隨機浮點數,當有一個參數時,返回該參數長度大小的一維隨機浮點數數組,參數建議是整數型,因為未來版本的numpy可能不支持非整形參數。 import numpy as np >>> np.random.rand(10) array([ 0.89103033, 0.60550521, 0.13856488, 0.57468244, 0.370697 , 0.31823162, 0.58358377, 0.97177935, 0.76400592, 0.11269547]) 2、np.random.randn該函數返回一個樣本,具有標准正態分布。 >>> np.random.randn(10) array([-0.42625455, -1.86248727, 0.96323332, -0.32809754, -0.79697695, -0.07145189, 2.89728643, 2.32095237, 1.12925633, -0.39210317]) 3、np.random.randint(low[, high, size]) 返回隨機的整數,位於半開區間 [low, high)。 >>> np.random.randint(10,size=10) array([4, 1, 4, 3, 8, 2, 8, 5, 8, 9]) 4、random_integers(low[, high, size]) 返回隨機的整數,位於閉區間 [low, high]。 >>> np.random.random_integers(5) 2 5、 np.random.shuffle(x) 類似洗牌,打亂順序;np.random.permutation(x)返回一個隨機排列 >>> arr = np.arange(10) >>> np.random.shuffle(arr) >>> arr [1 7 5 2 9 4 3 6 0 8] >>>> np.random.permutation(10) array([1, 7, 4, 3, 0, 9, 2, 5, 8, 6])