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. SQL语句练习手册--第一篇

    表架构 Student(S#,Sname,Sage,Ssex) 学生表 Course(C#,Cname,T#) 课程表 SC(S#,C#,score) 成绩表 Teacher(T#,Tname) 教师 ...

  2. Linux shell快捷键

    Ctrl + a 可以快速切换到命令行开始处Ctrl + e 切换到命令行末尾Ctrl + r 在历史命令中查找 ctrl + u      删除光标前面所有字符相当于VIM里d shift+^ ct ...

  3. hdu4930 Fighting the Landlords(模拟 多校6)

    题目链接:pid=4930">http://acm.hdu.edu.cn/showproblem.php? pid=4930 Fighting the Landlords Time L ...

  4. STL学习笔记(string)

    动机 C++标准程序库中的string class使我们可以将string当做一个一般型别.我们可以像对待基本型别那样地复制.赋值和比较string, 再也不必但系内存是否足够.占用的内存实际长度等问 ...

  5. 【Excle】使用&拼接,拼接后复制到文本编辑器存在引号(“”)问题

    1.错误的操作 如下图:拼接 拼接后,复制到文本编辑器: 1.1错误原因 出现上述问题的原因:是由于在拼接字符串的时候, INSERT INTO CST(ID,NAME)values( 上述这段字符& ...

  6. 基于Android Classic Bluetooth的蓝牙聊天软件

    代码地址如下:http://www.demodashi.com/demo/12133.html BluetoothChat 基于Android Classic Bluetooth的蓝牙聊天软件,目前仅 ...

  7. python单元测试框架 pyunit

    概况 系统要求 使用PyUnit构建自己的测试 安装 测试用例介绍 创建一个简单测试用例 复用设置代码:创建固件 包含多个测试方法的测试用例类 将测试用例聚合成测试套件 嵌套测试用例 测试代码的放置位 ...

  8. WordPress函数:get_bloginfo()用法详解

    描述 返回你博客的信息,这些信息可以用在任何地方的 PHP 代码中.这个函数,和 bloginfo() 一样,可以用来在模板文件的任何地方显示你博客的信息. 用法 <?php $bloginfo ...

  9. sublime 插件(持续更新)

    sublime text 3创建新文件插件-AdvanceNewFile 这里要记录sublime text 3 在创建新文件时安装的插件–AdvanceNewFile ST本来自带的创建新文件的快捷 ...

  10. Httpclient 实现带参文件上传

    这里直接贴出的是我封装好的doPostFile方法,httpclient 的版本是3.1. public static String doPostFile(String url, Part[] par ...