python - python中使用numpy生成随机数

标签 python numpy random

我想使用round(random.uniform(1.5, 1.9),2)生成随机数并使用 numpy.random.random((5,10))生成一个包含 5 个元素的列表,每个元素有 10 个项目。 我可以同时进行这些操作吗?

最佳答案

只需使用numpy.random.uniform()numpy.round():

numpy.round(numpy.random.uniform(low=1.5, high=1.9, size=(5, 10)), decimals=2)

关于python - python中使用numpy生成随机数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44244537/

相关文章:

Python/Scipy : Find "bounded" min/max of a matrix

python - 如何为 2D 直方图选择自定义 bin 大小?

random - GO:操纵随机生成的 float64

python - 为什么 random.random() 占用两个 random.randint() 值?

python - Google App Engine 上的多人游戏

python - 如何通过 Django 中的 'status' 变量对对象进行排序

python - Bamboo 日志输出顺序问题

python - 在 Portable Python 中使用 Win32 扩展需要什么

python - 我需要一个 numpy 数组中的 N 个最小(索引)值

r - 在向量中生成随机长度的 NA 随机序列