[Python] Generating random numbers using numpy lib
import numpy as np def test_run():
data=np.random.random((3,4))
"""
[[ 0.80150549 0.96756513 0.18914514 0.85937016]
[ 0.23563908 0.75685996 0.46804508 0.91735016]
[ 0.70541929 0.04969046 0.75052217 0.2801136 ]]
""" data=np.random.rand(3,4)
"""
[[ 0.48137826 0.82544788 0.24014543 0.56807129]
[ 0.02557921 0.50690438 0.29423376 0.85673923]
[ 0.32648763 0.97304461 0.6034564 0.70554691]]
""" data=np.random.normal(size=(2,3)) #mean=0, sd=1
"""
[[ 1.57598046 0.06976049 -1.6502364 ]
[ 0.30437287 -0.88249543 -0.04233034]]
"""
data=np.random.normal(50,10,size=(2,3)) #mean=50, sd=10
"""
[[ 34.40308274 56.17179863 36.05758636]
[ 57.38723594 41.43156664 65.54296858]]
"""
print(np.random.randint(10)) #
print(np.random.randint(0,10)) #
print(np.random.randint(0,10,size=(5))) #[2 1 8 4 1]
print(np.random.randint(0,10,size=(2,3)))
"""
[[0 2 4]
[3 8 3]]
""" if __name__ == "__main__":
test_run()
[Python] Generating random numbers using numpy lib的更多相关文章
- python的random模块
As an example of subclassing, the random module provides the WichmannHill class that implements an a ...
- Generating Gaussian Random Numbers(转)
Generating Gaussian Random Numbers http://www.taygeta.com/random/gaussian.html This note is about th ...
- python数据分析第二版:numpy
一:Numpy # 数组和列表的效率问题,谁优谁劣 # 1.循环遍历 import numpy as np import time my_arr = np.arange(1000000) my_lis ...
- C++ Standard-Library Random Numbers
Extracted from Section 17.4 Random Numbers, C++ Primer 5th. Ed. The random-number library generates ...
- 【转载】python 模块 - random生成随机数模块
随机数种子 要每次产生随机数相同就要设置种子,相同种子数的Random对象,相同次数生成的随机数字是完全相同的: random.seed(1) 这样random.randint(0,6, (4,5)) ...
- Python:机器学习三剑客之 NumPy
一.numpy简介 Numpy是高性能科学计算和数据分析的基础包,机器学习三剑客之一.Numpy库中最核心的部分是ndarray 对象,它封装了同构数据类型的n维数组.部分功能如下: ndarray, ...
- python数据分析---第04章 NumPy基础:数组和矢量计算
NumPy(Numerical Python的简称)是Python数值计算最重要的基础包.大多数提供科学计算的包都是用NumPy的数组作为构建基础. NumPy的部分功能如下: ndarray,一个具 ...
- ZH奶酪:【Python】random模块
Python中的random模块用于随机数生成,对几个random模块中的函数进行简单介绍.如下:random.random() 用于生成一个0到1的随机浮点数.如: import random ra ...
- linux python 安装 nose lapack atlas numpy scipy
linux python 安装 nose lapack atlas numpy scipy --http://lib.csdn.net/article/python/1262 作者:maple1149 ...
随机推荐
- 关于RoI pooling 层
ROIs Pooling顾名思义,是pooling层的一种,而且是针对ROIs的pooling: 整个 ROI 的过程,就是将这些 proposal 抠出来的过程,得到大小统一的 feature ma ...
- CentOS-1810系统DHCP服务器ISC DHCP软件配置说明
DHCP 全称Dynamic Host configuration protocol, 动态主机配置协议.是一个局域网的网络协议,使用UDP协议工作,它可以为客户机自动分配IP地址.子网掩码以及缺省网 ...
- linux下mysqldump简单命令导出数据库和表
进入mysql的bin目录执行: 导出单个表: mysqldump -uroot -ppassword --database dbname --tables users > /home/root ...
- BZOJ 2794 [Poi2012]Cloakroom(离线+背包)
2794: [Poi2012]Cloakroom Time Limit: 20 Sec Memory Limit: 128 MBSubmit: 406 Solved: 241[Submit][St ...
- 【Paper Reading】Object Recognition from Scale-Invariant Features
Paper: Object Recognition from Scale-Invariant Features Sorce: http://www.cs.ubc.ca/~lowe/papers/icc ...
- iview中单击行,使得checkbox状态的方法
直接贴代码,这是一组jquery全选,全不选,反选代码 <!DOCTYPE html> <html lang="en"> <head> < ...
- mayan 游戏 search
纯搜索,,,模拟,,还不算太难,,就是细节略繁琐 首先因为题目要求保证字典序,所以显然把右边的块换到左边不如把左边的块换到右边优, 所以可以进行不小规模的剪枝,之后显然交换两块相同的色块没有意义,至此 ...
- 洛谷——P1455 搭配购买
https://www.luogu.org/problem/show?pid=1455 题目描述 明天就是母亲节了,电脑组的小朋友们在忙碌的课业之余挖空心思想着该送什么礼物来表达自己的心意呢?听说在某 ...
- HDU 3108 Ant Trip
Ant Trip Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Su ...
- "pom.xml" could not be activated because it does not exist.
"pom.xml" could not be activated because it does not exist. 在sts中使用maven build,输入package然后 ...