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. GROUP BY和HAVING 以及mysql中常用的日期函数

    一.mysql中的GROUP BY和HAVINGGROUP BY常见的是和聚合函数(SUM,MIN,MAX,COUNT)搭配使用. 比如:SELECT category,SUM(money) AS ` ...

  2. sort-colors——排序3种数字

    题目描述 Given an array with n objects colored red, white or blue, sort them so that objects of the same ...

  3. 仿IOS中下拉刷新的“雨滴”效果

    在IOS中,有非常赞的"水滴"下拉效果.非常久之前也想在Android上实现,可是苦于能力有限,一直未能付诸行动.这几天趁着空隙时间.写了一版初步实现,基本达到了"水滴& ...

  4. 超高逼格Log日志打印

    代码地址如下:http://www.demodashi.com/demo/12646.html 前言 Log日志的打印一直是一个比较头疼的事,怎样才能让自己的log显示更多信息,怎样才能让自己的log ...

  5. go http请求基础

    1.请求方法: get post get 加请求参数,请求参数会加到url后面 post加请求参数,请求参数会放在body里面 请求方式:1.直接在url后面加参数  如:http://www.tes ...

  6. Atitit.ioc 动态配置文件guice 设计原理

    Atitit.ioc 动态配置文件guice 设计原理 1. Bat启动时注入配置文件1 2. ioc调用1 3. Ioc 分发器 配合 apche  MethodUtils.invokeStatic ...

  7. GNU LD 脚本学习笔记

    LD脚本(linker script)是什么 GNU ld是链接器,ld实际并不是GCC的一部分,ld属于binutils软件包.但是嵌入式开发时,下载的linaro GCC工具集中是包含 arm-l ...

  8. eclipse +cygwin+C++

    用Android eclipse做C++开发,一开始提示no binary的错误,貌似是因为没有编译二进制出来,我本机装了cygwin, 在命令台输入gcc,无显示,说明我没有把cygwin/bin的 ...

  9. 【elasticsearch】安装合集

    [elasticsearch](1)centos7 使用yum安装elasticsearch 2.X [elasticsearch](2)centos7 超简单安装elasticsearch 的监控. ...

  10. python3读取BJDA药品经营企业数据

    #-*- coding:utf-8 -*- #读取北京FDA的药品经营企业数据 # 20161125 zhangshaohua import re import urllib.request impo ...