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. windows 路由

    route ? 查看帮助 route print 查看路由表 添加一条路由: route add 10.10.10.0 mask 255.255.255.0  192.168.1.1 #到达10.10 ...

  2. Base64编码字符串时数据量明显变大

    那就是当把byte[]通过Convert.ToBase64String转换成Base64编码字符串时数据量明显变大 Base64编码的思想是是采用64个基本的ASCII码字符对数据进行重新编码.它将需 ...

  3. svn 验证位置失败 Authorization failed

    进入svn的conf目录下 修改svnserve.conf [general] anon-access = none  #未登录用户不允许访问 auth-access = write  passwor ...

  4. windows系统关闭端口占用进程

    1.查找端口占用进程ID netstat -ano|findstr " 2.通过进程ID查找进程名 tasklist |findstr " 3.杀死进程(指定进程ID或进程名) t ...

  5. mycat读写分离+垂直切分+水平切分+er分片+全局表 测试

    原文http://blog.163.com/bigoceanwu@126/blog/static/172718064201683031639683/ 读写分离:利用最基础的mysql主从复制,事务性的 ...

  6. Hibernate简单的保存操作

    1.这里面我想先说一下session对象的创建,这个是我们操纵数据库的核心对象,因此首先我们应该获取相应的session对象. public static Configuration cfg; pub ...

  7. Mac安装软件时,提示文件已损坏,需要移动到废纸篓的解决方法

    1.修改系统偏好设置,安全性与隐私-->将“允许从以下位置下载的应用” ☑️任何来源. 2. mac10.12以上的系统一般没有“任何来源”这个选项,需打开terminnal终端,输入 sudo ...

  8. Json学习总结(2)——Java 下的 JSON库性能比较:JSON.simple vs. GSON vs. Jackson vs. JSONP

    JSON已经成为当前服务器与WEB应用之间数据传输的公认标准,不过正如许多我们所习以为常的事情一样,你会觉得这是理所当然的便不再深入思考了.我们很少会去想用到的这些JSON库到底有什么不同,但事实上它 ...

  9. MarkDown 图片大小问题

    本系列文章由 @YhL_Leo 出品,转载请注明出处. 文章链接: http://blog.csdn.net/yhl_leo/article/details/50099843 MarkDown里显示图 ...

  10. Apache activemq入门示例(maven项目)

    http://outofmemory.cn/java/mq/apache-activemq-demo