有关numpy.random下的API具体含义
1.numpy.random.random(size=None)
Return random floats in the half-open interval [0.0, 1.0).
返回size大小的左闭右开区间[0.0,1.0)之间的任意数
例子:
import numpy as np
>>> np.random.random((3,2))
array([[ 0.14334653, 0.77302772],
[ 0.29343 , 0.3616797 ],
[ 0.74033689, 0.27422447]])
2.numpy.random.random_sample()
Return random floats in the half-open interval [0.0, 1.0).
>>> np.random.random_sample()
0.20764369973602625
>>> np.random.random_sample((5,))
array([ 0.92364552, 0.20655286, 0.22086714, 0.89360228, 0.2601571 ])
Three-by-two array of random numbers from [-5, 0):
>>> 5 * np.random.random_sample((3, 2)) - 5
array([[-4.13201957, -1.74491577],
[-4.40046347, -4.26736193],
[-4.70610327, -0.24798093]])
1和2是相同的
3.numpy.random.randint(low, high=None, size=None)
Return random integers from low (inclusive) to high (exclusive).
Return random integers from the “discrete uniform” distribution of the specified dtype in the “half-open” interval [low, high).
If high is None (the default), then results are from [0, low).
>>> np.random.randint(2, size=10)
array([0, 1, 0, 0, 1, 1, 0, 1, 0, 1])
>>> np.random.randint(1, size=10)
array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
>>> np.random.randint(5, size=(2, 4))
array([[1, 1, 4, 3],
[1, 3, 4, 2]])
4.numpy.random.permutation
Randomly permute a sequence, or return a permuted range.随机对序列进行重新排列,或者返回一个重新排列的范围
举例如:
>>> np.random.permutation(10)
array([1, 7, 4, 3, 0, 9, 2, 5, 8, 6])
>>> np.random.permutation([1, 4, 9, 12, 15])
array([15, 1, 9, 4, 12])
>>> arr = np.arange(9).reshape((3, 3))
>>> np.random.permutation(arr)
array([[6, 7, 8],
[0, 1, 2],
[3, 4, 5]])
有关numpy.random下的API具体含义的更多相关文章
- numpy.random.uniform()
numpy.random.uniform均匀分布 2018年06月19日 23:28:03 徐小妹 阅读数:4238 numpy.random.uniform介绍: 1. 函数原型: numpy ...
- numpy.random.rand()/randn()/randint()/normal()/choice()/RandomState()
这玩意用了很多次,但每次用还是容易混淆,今天来总结mark一下~~~ 1. numpy.random.rand(d0,d1,...,dn) 生成一个[0,1)之间的随机数或N维数组 np.random ...
- numpy.random.shuffle()与numpy.random.permutation()的区别
参考API:https://docs.scipy.org/doc/numpy/reference/routines.random.html 1. numpy.random.shuffle() AP ...
- numpy.random之常用函数
在实际开发中,我们经常会使用随机函数,比如交叉验证,构造测试数据等.下面,是我常用的几个生成随机样本的函数: 1,rand(n1,n2,…,nn) 每一维度都是[0.0,1.0)半闭半开区间上的随机分 ...
- [转]numpy.random.randn()用法
在python数据分析的学习和应用过程中,经常需要用到numpy的随机函数,由于随机函数random的功能比较多,经常会混淆或记不住,下面我们一起来汇总学习下. import numpy as np ...
- Python的numpy库下的几个小函数的用法
numpy库是Python进行数据分析和矩阵运算的一个非常重要的库,可以说numpy让Python有了matlab的味道 本文主要介绍几个numpy库下的小函数. 1.mat函数 mat函数可以将目标 ...
- numpy.random.seed()方法
先贴参考链接: https://stackoverflow.com/questions/21494489/what-does-numpy-random-seed0-do numpy.random.se ...
- numpy.random中的shuffle和permutation以及mini-batch调整数据集(X, Y)
0. numpy.random中的shuffle和permutation numpy.random.shuffle(x) and numpy.random.permutation(x),这两个有什么不 ...
- DataPipeline丨金融行业如何统一管理单个任务下所有API的同步情况
目前,依靠"手工人力"的电子表格数据治理模式逐渐被"自动智能"的专业工具取代.数据管理员.业务分析师开始采用"平台工具"来梳理主数据.元数据 ...
随机推荐
- python-mysql-replication
python处理mysql binlog增量日志 http://python-mysql-replication.readthedocs.io/en/latest/examples.html 同样的项 ...
- BZOJ 4216 Pig 分块乱搞
题意:id=4216">链接 方法:分块以节约空间. 解析: 这题坑的地方就是他仅仅有3M的内存限制,假设我们开longlong前缀和是必死的. 所以考虑缩小这个long long数组 ...
- 把数据库里面的stu表中的数据,导出到excel中
# 2.写代码实现,把我的数据库里面的stu表中的数据,导出到excel中 #编号 名字 性别 # 需求分析:# 1.连接好数据库,写好SQL,查到数据 [[1,'name1','男'],[1,'na ...
- d3系列2--api攻坚战02
<html> <head> <style type="text/css"> .area{ fill:steelblue; } </styl ...
- android性能优化学习笔记(加快应用程序启动速度:)
一:安卓中应用程序的启动方式有两种: 冷启动:后台没有该应用进程,系统会重新创建一个进程分配给该应用(所以会先创建和初始化Application类,再创建和初始化MainActivity,包括测量,布 ...
- IDEA下配置Spring Boot的热部署
© 版权声明:本文为博主原创文章,转载请注明出处 devtools简介 spring-boot-devtools会监听classpath下的文件变动,并且会立即重启应用(发生在保存时机),因为其采用的 ...
- linux rm -rf * 文件恢复记
手太快,肠子都毁清了.本来是删除一个文件 rm path/myfile.txt结果不知为何加了个*,变成了rm path/myfile.txt *赶紧ls,发现所有代码都化为了乌有,还没提交,还没备份 ...
- Python中运算符与while初识
一.运算符 1.算术运算: 2.比较运算: 3.赋值运算: 4.位运算: 注: ~ 举例: ~5 = -6 解释: 将二进制数+1之后乘以-1,即~x = -(x+1),-(101 + 1) = ...
- Android开发系列之系统源码目录
相信大家对于Google给出的那副经典Android架构图非常的熟悉,从下往上依次是Linux内核层(主要是负责硬件管理调度),HAL层(主要是硬件抽象层),libs层+Runtime,Framewo ...
- webpack 功能大全 【环境配置】
1. webpack简介 webpack 是一个模块打包工具.它使得模块相互依赖并且可构建等价于这些模块的静态资源.相比于已经存在的模块打包器(module bundler),webpack的开发动机 ...