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. CentOS——yum命令运行错误解决办法

    问题: [root@name user]# yum File "/usr/bin/yum", line 30 except KeyboardInterrupt, e:        ...

  2. cpu、内存、磁盘

    例一:内存使用率 #!/bin/bash total=$(free -m|grep Mem|awk '{print $2}') used=$(free -m|grep Mem|awk '{print ...

  3. jquery:选择器(转)

    http://www.cnblogs.com/kissdodog/archive/2012/11/05/2755103.html

  4. Git学习小结

    版本控制工具 集中式: CVS SVN 集大成者 分布式:git 创始人:inux Towards 2005年 工具 最好使用linux(oh-my-zsh) gitbash -> cygwin ...

  5. PJSIP dialog inv销毁

    PJSIP的Diaglog(类型为pjsip_dialog) 可以被外部调用,同时PJSIP有自己的机制销毁用户创建的 Dialog,如PJSIP内部销毁了某个Diaglog,用户在不知情的情况下继续 ...

  6. Ubuntu安装sublime test 3 (Build 3126)

    Ubuntu下 Sublime Text 3 (Build 3143) 存在一些bug........ 满心欢喜地更新后, 又默默换回Build 3126 1. 安装 sudo apt-get upd ...

  7. linux无线网络配置_转

    转自:http://www.cnblogs.com/dartagnan/archive/2010/12/05/2003521.html   一位资生linux 原文:http://www.hpl.hp ...

  8. 【SQLServer2008】之Win10 安装 SQL Server 2008

    查看安装步骤链接: http://jingyan.baidu.com/article/1709ad8092be974634c4f0e7.html

  9. 排序算法 python

    1.先写个原始数组和测试算法是否正确,输出多次,方便计算算法运算的平均值 2.开始第一个最简单的冒泡排序 3.“”选择排序“”,跟冒泡很像,每次选最大/最小,放进新list中. 3.1发现测试test ...

  10. 嵌入式开发之simulation--- 双目移动dsp机器人

    http://foundy.blog.163.com/blog/static/263383442014112391130207/