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. 接口测试工具篇--jmeter

    jmeter的安装及使用在这里不进行讲解了,网上有很多资料 下面开始讲解如何使用jmeter做http接口测试 在jmeter中添加一个http请求,添加方式:测试计划上邮件添加线程组,线程组上邮件选 ...

  2. Docker中免去sudo的设置方法

    Add the docker group if it doesn't already exist: sudo groupadd docker Add the connected user " ...

  3. 找tensorboard

    一开始因为用户不对,提示tensorboard:未找到命令 切换正确账户寻找tensorboard 然后打开Xstart,输入firefox,把链接输入进去 即可

  4. Json相关内容

    一. 导入包:net.sf.json.JSONObject 代码 import net.sf.json.JSON; import net.sf.json.JSONArray; import net.s ...

  5. HTTP 文件共享服务器工具 - chfs

    CuteHttpFileServer/chfs是一个免费的.HTTP协议的文件共享服务器,使用浏览器可以快速访问.它具有以下特点: 单个文件,整个软件只有一个可执行程序,无配置文件等其他文件 跨平台运 ...

  6. Python: 自定义类对象序列化为Json串

    之前已经实现了Python: Json串反序列化为自定义类对象,这次来实现了Json的序列化. 测试代码和结果如下: import Json.JsonTool class Score: math = ...

  7. 素数计数函数$\pi(x)\sim \Theta(\frac{x}{\log{x}})$的一个初等方法——素数定理的估计

    $\DeclareMathOperator{\lcm}{lcm}$ 本文的方法来源于GTM 190:"Problems in Algebraic Number Theory",给出 ...

  8. HTTP——学习笔记(1)

    名词解释: 协议: HTTP:HyperText Transfer Protocol,超文本传输协议,属于应用层的协议 FTP:File Transfer Protocol,文件传输协议,相比于HTT ...

  9. Codeforces Round #256 (Div. 2) B. Suffix Structures(模拟)

    题目链接:http://codeforces.com/contest/448/problem/B --------------------------------------------------- ...

  10. python批量下载色影无忌和蜂鸟的图片 爬虫小应用

    有些冗余信息.由于之前測试正則表達式.所以没有把它们给移走.只是不影响使用. # -*- coding:utf-8 -*- import re,urllib,sys,os,time def getAl ...