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的更多相关文章

  1. python的random模块

    As an example of subclassing, the random module provides the WichmannHill class that implements an a ...

  2. Generating Gaussian Random Numbers(转)

    Generating Gaussian Random Numbers http://www.taygeta.com/random/gaussian.html This note is about th ...

  3. python数据分析第二版:numpy

    一:Numpy # 数组和列表的效率问题,谁优谁劣 # 1.循环遍历 import numpy as np import time my_arr = np.arange(1000000) my_lis ...

  4. C++ Standard-Library Random Numbers

    Extracted from Section 17.4 Random Numbers, C++ Primer 5th. Ed. The random-number library generates ...

  5. 【转载】python 模块 - random生成随机数模块

    随机数种子 要每次产生随机数相同就要设置种子,相同种子数的Random对象,相同次数生成的随机数字是完全相同的: random.seed(1) 这样random.randint(0,6, (4,5)) ...

  6. Python:机器学习三剑客之 NumPy

    一.numpy简介 Numpy是高性能科学计算和数据分析的基础包,机器学习三剑客之一.Numpy库中最核心的部分是ndarray 对象,它封装了同构数据类型的n维数组.部分功能如下: ndarray, ...

  7. python数据分析---第04章 NumPy基础:数组和矢量计算

    NumPy(Numerical Python的简称)是Python数值计算最重要的基础包.大多数提供科学计算的包都是用NumPy的数组作为构建基础. NumPy的部分功能如下: ndarray,一个具 ...

  8. ZH奶酪:【Python】random模块

    Python中的random模块用于随机数生成,对几个random模块中的函数进行简单介绍.如下:random.random() 用于生成一个0到1的随机浮点数.如: import random ra ...

  9. linux python 安装 nose lapack atlas numpy scipy

    linux python 安装 nose lapack atlas numpy scipy --http://lib.csdn.net/article/python/1262 作者:maple1149 ...

随机推荐

  1. 关于RoI pooling 层

    ROIs Pooling顾名思义,是pooling层的一种,而且是针对ROIs的pooling: 整个 ROI 的过程,就是将这些 proposal 抠出来的过程,得到大小统一的 feature ma ...

  2. CentOS-1810系统DHCP服务器ISC DHCP软件配置说明

    DHCP 全称Dynamic Host configuration protocol, 动态主机配置协议.是一个局域网的网络协议,使用UDP协议工作,它可以为客户机自动分配IP地址.子网掩码以及缺省网 ...

  3. linux下mysqldump简单命令导出数据库和表

    进入mysql的bin目录执行: 导出单个表: mysqldump -uroot -ppassword --database dbname --tables users > /home/root ...

  4. BZOJ 2794 [Poi2012]Cloakroom(离线+背包)

    2794: [Poi2012]Cloakroom Time Limit: 20 Sec  Memory Limit: 128 MBSubmit: 406  Solved: 241[Submit][St ...

  5. 【Paper Reading】Object Recognition from Scale-Invariant Features

    Paper: Object Recognition from Scale-Invariant Features Sorce: http://www.cs.ubc.ca/~lowe/papers/icc ...

  6. iview中单击行,使得checkbox状态的方法

    直接贴代码,这是一组jquery全选,全不选,反选代码 <!DOCTYPE html> <html lang="en"> <head> < ...

  7. mayan 游戏 search

    纯搜索,,,模拟,,还不算太难,,就是细节略繁琐 首先因为题目要求保证字典序,所以显然把右边的块换到左边不如把左边的块换到右边优, 所以可以进行不小规模的剪枝,之后显然交换两块相同的色块没有意义,至此 ...

  8. 洛谷——P1455 搭配购买

    https://www.luogu.org/problem/show?pid=1455 题目描述 明天就是母亲节了,电脑组的小朋友们在忙碌的课业之余挖空心思想着该送什么礼物来表达自己的心意呢?听说在某 ...

  9. HDU 3108 Ant Trip

    Ant Trip Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Su ...

  10. "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然后 ...