np.random.rand() # 没有参数则直接⽣成⼀个[0,1)区间的随机数
0.1065982531337718
>>> np.random.rand(3) # 只有⼀个参数则⽣成n*1个随机数
array([0.24640203, 0.81910232, 0.79941588])
>>> np.random.rand(2, 3, 4) # 有多个参数,则⽣成对应形状随机数,如本例⽣成shape为2*3*4的随机数

np.random.uniform(2,7,(4,5))#⽣成2到7之间的随机数,维度4⾏5列

np.random.randint(10,29,(3,7))#产生10到29之间的3行7列整数矩阵
array([[25,10,20,25,21,26,26],
[10,11,16,28,12,20,26],.....
-------------------------------------------------------------------
产⽣随机数
rand(d0, d1, …, dn) Random values in a given shape.
randn(d0, d1, …, dn) Return a sample (or samples) from the “standard normal” distribution.
randint(low[, high, size, dtype]) Return random integers from low (inclusive) to high (exclusive).
random_integers(low[, high, size]) Random integers of type np.int between low and high, inclusive.
random_sample([size]) Return random floats in the half-open interval [0.0, 1.0).
random([size]) Return random floats in the half-open interval [0.0, 1.0).
ranf([size]) Return random floats in the half-open interval [0.0, 1.0).
sample([size]) Return random floats in the half-open interval [0.0, 1.0).
choice(a[, size, replace, p]) Generates a random sample from a given 1-D array
bytes(length) Return random bytes.
打乱随机数
shuffle(x) Modify a sequence in-place by shuffling its contents.
permutation(x) Randomly permute a sequence, or return a permuted range
--------------------------------------------------------
作者:天神太院明骞骞010
链接:https://wenku.baidu.com/view/01418630084e767f5acfa1c7aa00b52acfc79c62.html
0.1065982531337718
>>> np.random.rand(3) # 只有⼀个参数则⽣成n*1个随机数
array([0.24640203, 0.81910232, 0.79941588])
>>> np.random.rand(2, 3, 4) # 有多个参数,则⽣成对应形状随机数,如本例⽣成shape为2*3*4的随机数
np.random.uniform(2,7,(4,5))#⽣成2到7之间的随机数,维度4⾏5列
np.random.randint(10,29,(3,7))#产生10到29之间的3行7列整数矩阵
array([[25,10,20,25,21,26,26],
[10,11,16,28,12,20,26],.....
-------------------------------------------------------------------
产⽣随机数
rand(d0, d1, …, dn) Random values in a given shape.
randn(d0, d1, …, dn) Return a sample (or samples) from the “standard normal” distribution.
randint(low[, high, size, dtype]) Return random integers from low (inclusive) to high (exclusive).
random_integers(low[, high, size]) Random integers of type np.int between low and high, inclusive.
random_sample([size]) Return random floats in the half-open interval [0.0, 1.0).
random([size]) Return random floats in the half-open interval [0.0, 1.0).
ranf([size]) Return random floats in the half-open interval [0.0, 1.0).
sample([size]) Return random floats in the half-open interval [0.0, 1.0).
choice(a[, size, replace, p]) Generates a random sample from a given 1-D array
bytes(length) Return random bytes.
打乱随机数
shuffle(x) Modify a sequence in-place by shuffling its contents.
permutation(x) Randomly permute a sequence, or return a permuted range
--------------------------------------------------------
作者:天神太院明骞骞010
链接:https://wenku.baidu.com/view/01418630084e767f5acfa1c7aa00b52acfc79c62.html












