python中生成随机数组/向量

使用numpy.random模块来生成随机数组转载

1、np.random.rand 用于生成[0.0, 1.0)之间的随机浮点数, 当没有参数时,返回一个随机浮点数,当有一个参数时,返回该参数长度大小的一维随机浮点数数组,参数建议是整数型,因为未来版本的numpy可能不支持非整形参数。

2、np.random.randn(10)该函数返回一个10维向量,具有标准正态分布

3、np.random.randint(low[, high, size]) 返回随机的整数,位于半开区间 [low, high)。
4、np.random_integers(low[, high, size]) 返回随机的整数,位于闭区间 [low, high]。
5、np.random.shuffle(x) 类似洗牌,打乱顺序;np.random.permutation(x)返回一个随机排列

猜你喜欢

转载自blog.csdn.net/u_7890/article/details/84027293
今日推荐