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(lowhigh=Nonesize=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具体含义的更多相关文章

  1. numpy.random.uniform()

    numpy.random.uniform均匀分布 2018年06月19日 23:28:03 徐小妹 阅读数:4238   numpy.random.uniform介绍: 1. 函数原型:  numpy ...

  2. numpy.random.rand()/randn()/randint()/normal()/choice()/RandomState()

    这玩意用了很多次,但每次用还是容易混淆,今天来总结mark一下~~~ 1. numpy.random.rand(d0,d1,...,dn) 生成一个[0,1)之间的随机数或N维数组 np.random ...

  3. numpy.random.shuffle()与numpy.random.permutation()的区别

    参考API:https://docs.scipy.org/doc/numpy/reference/routines.random.html 1. numpy.random.shuffle()   AP ...

  4. numpy.random之常用函数

    在实际开发中,我们经常会使用随机函数,比如交叉验证,构造测试数据等.下面,是我常用的几个生成随机样本的函数: 1,rand(n1,n2,…,nn) 每一维度都是[0.0,1.0)半闭半开区间上的随机分 ...

  5. [转]numpy.random.randn()用法

    在python数据分析的学习和应用过程中,经常需要用到numpy的随机函数,由于随机函数random的功能比较多,经常会混淆或记不住,下面我们一起来汇总学习下. import numpy as np ...

  6. Python的numpy库下的几个小函数的用法

    numpy库是Python进行数据分析和矩阵运算的一个非常重要的库,可以说numpy让Python有了matlab的味道 本文主要介绍几个numpy库下的小函数. 1.mat函数 mat函数可以将目标 ...

  7. numpy.random.seed()方法

    先贴参考链接: https://stackoverflow.com/questions/21494489/what-does-numpy-random-seed0-do numpy.random.se ...

  8. numpy.random中的shuffle和permutation以及mini-batch调整数据集(X, Y)

    0. numpy.random中的shuffle和permutation numpy.random.shuffle(x) and numpy.random.permutation(x),这两个有什么不 ...

  9. DataPipeline丨金融行业如何统一管理单个任务下所有API的同步情况

    目前,依靠"手工人力"的电子表格数据治理模式逐渐被"自动智能"的专业工具取代.数据管理员.业务分析师开始采用"平台工具"来梳理主数据.元数据 ...

随机推荐

  1. 解决ie7下overflow:hidden失效问题

    但父亲元素下面的子节点或者孙子节点有position:relative:或者absolute时,父亲即使设置了overflow:hidden:依然会溢出 解决方法可以: 在父亲元素上加上*positi ...

  2. POJ 2029 Get Many Persimmon Trees (二维树状数组)

    Get Many Persimmon Trees Time Limit:1000MS    Memory Limit:30000KB    64bit IO Format:%I64d & %I ...

  3. 正则化--L2正则化

    请查看以下泛化曲线,该曲线显示的是训练集和验证集相对于训练迭代次数的损失. 图 1 显示的是某个模型的训练损失逐渐减少,但验证损失最终增加.换言之,该泛化曲线显示该模型与训练集中的数据过拟合.根据奥卡 ...

  4. Android文章收藏

     Android集 1.Himi李华明的<Android游戏开发专栏>http://blog.csdn.net/column/details/androidgame.html2.老罗的&l ...

  5. asp.net core mvc视频A:笔记3-2.表单使用

    页面上呈现表单的两种方式 新建项目,增加Test控制器,增加Index视图 方式一:HTML构建表单 运行 方式二:HTML 运行 数据绑定 处理方法 调用结果 登录后返回值 默认值绑定 方式一: 控 ...

  6. Python---copy()、deepcopy()与赋值的区别

    copy()与deepcopy()之间的主要区别是python对数据的存储方式. 首先直接上结论: —–深复制,即将被复制对象完全再复制一遍作为独立的新个体单独存在.所以改变原有被复制对象不会对已经复 ...

  7. mac权限

    mac文件后面出现@权限 去除方法: xattr -c 文件名  目录也可以

  8. idea实时编译代码

    实时编译就不解释了,出现错误的代码在命令行能给你提示出来.看图操作吧:

  9. VM虚拟机内ubuntu无法连接到网络

    VM虚拟机内ubuntu无法连接到网络 解决:编辑网络,将网路都删除掉.又一次加入网络桥接和NAT链接. .又一次连接就可以,查看一下ip地址. 方法2: 虚拟机中新装ubuntu 编辑虚拟网络,先恢 ...

  10. spark standlone 伪分布式安装

    一,在官网下载对应的版本http://spark.apache.org/downloads.html 二在linux中解压下来的spark包   三:配置环境变量     (1)在/etc/profi ...