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. SpringBoot学习笔记(12)----SpringBoot实现多个 账号轮询发送邮件

    首先,引入发送邮件的依赖,由于freemarker自定义模板,所以也需要把freemarker的依赖引入 pom.xml文件 <dependency> <groupId>org ...

  2. css兼容性问题总结

    DIV+CSS设计IE6.IE7.FF 兼容性 DIV+CSS网页布局这是一种趋势,我也开始顺应这股趋势了,不过在使用DIV+CSS网站设计的时候,应该注意css样式兼容不同浏览器问题,特别是对完全使 ...

  3. 多任务-进程之PID

    1.进程pid,如何在程序中获取我们的进程号,从而查看当前的进程 # -*- coding:utf-8 -*- from multiprocessing import Process import o ...

  4. 物理机安装CentOS7

    最近捯饬到一台很老的机器,装Win7吧卡的不要不要的,思来想去的,搞个CentOS来玩玩,玩玩python的一些个人项目,一般装机啥的,都要做启动盘啥的,但是,这个都的话有很多网友已经分享了很多好的文 ...

  5. mysql 密码的破解

    现在的主流的数据库一般是mysql  ,sql  server ,  oracle. 有的时候我们忘记了数据库密码的时候我们要怎么办,破解别人的数据库的密码的时候我们要怎么搞  忘记密码是一件很头痛的 ...

  6. 洛谷 P1045 麦森数 (快速幂+高精度+算位数骚操作)

    这道题太精彩了! 我一开始想直接一波暴力算,然后叫上去只有50分,50分超时 然后我改成万位制提高运算效率,还是只有50分 然后我丧心病狂开long long用10的10次方作为一位,也就是100亿进 ...

  7. 【转】C# 正则表达式大全

    [转]C# 正则表达式大全 前言 在网上看到一个不错的简易版正则匹配和替换的工具,现在补充进来,感觉还不错,效果如下(输入验证中文汉字的正则表达式) 在线下载   密码:5tpt 注:好像也是一位园友 ...

  8. 程序员之---C语言细节12(指针和数组细节,&quot;//&quot;的可移植性说明)

    主要内容:指针和数组细节,"//"的可移植性说明 #include <stdio.h> int main(int argc, char **argv) { int a[ ...

  9. 程序设计基石与实践系列之编写高效的C程序与C代码优化

    原文出处: codeproject:Writing Efficient C and C Code Optimization 虽然对于优化C代码有非常多有效的指导方针,可是对于彻底地了解编译器和你工作的 ...

  10. STL_算法_查找算法(binary_search、includes)

    C++ Primer 学习中.. . 简单记录下我的学习过程 (代码为主) 全部容器适用(O(log(n)))     已序区间查找算法 binary_search             //二分查 ...