huffle与permutation的区别

函数shuffle与permutation都是对原来的数组进行重新洗牌(即随机打乱原来的元素顺序);区别在于shuffle直接在原来的数组上进行操作,改变原来数组的顺序,无返回值。而permutation不直接在原来的数组上进行操作,而是返回一个新的打乱顺序的数组,并不改变原来的数组。

示例:

a = np.arange(12)
print a
np.random.shuffle(a)
print a
print
a = np.arange(12)
print a
b = np.random.permutation(a)
print b
print a
[ 0  1  2  3  4  5  6  7  8  9 10 11]
[11 6 4 10 3 0 7 1 9 2 5 8] [ 0 1 2 3 4 5 6 7 8 9 10 11]
[10 4 8 11 1 7 6 2 0 9 5 3]
[ 0 1 2 3 4 5 6 7 8 9 10 11]

--------------------------------------------------------------------------------

转载自:http://blog.csdn.net/lyy14011305/article/details/76207327

Numpy.random中shuffle与permutation的区别(转)的更多相关文章

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

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

  2. 洗牌算法及 random 中 shuffle 方法和 sample 方法浅析

    对于算法书买了一本又一本却没一本读完超过 10%,Leetcode 刷题从来没坚持超过 3 天的我来说,算法能力真的是渣渣.但是,今天决定写一篇跟算法有关的文章.起因是读了吴师兄的文章<扫雷与算 ...

  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.randn()与numpy.random.rand()的区别(转)

    numpy中有一些常用的用来产生随机数的函数,randn()和rand()就属于这其中. numpy.random.randn(d0, d1, …, dn)是从标准正态分布中返回一个或多个样本值. n ...

  5. numpy.random.randn()与rand()的区别【转】

    本文转载自:https://blog.csdn.net/u010758410/article/details/71799142 numpy中有一些常用的用来产生随机数的函数,randn()和rand( ...

  6. 【转】numpy.random.randn()与rand()的区别

    转自: https://blog.csdn.net/u010758410/article/details/71799142 numpy中有一些常用的用来产生随机数的函数,randn()和rand()就 ...

  7. numpy.random.shuffle(x)的用法

    numpy.random.shuffle(x) Modify a sequence in-place by shuffling its contents. Parameters: x : array_ ...

  8. numpy.random.randn()与numpy.random.rand()的区别

    numpy中有一些常用的用来产生随机数的函数,randn()和rand()就属于这其中. numpy.random.randn(d0, d1, …, dn)是从标准正态分布中返回一个或多个样本值. n ...

  9. numpy中关于*和dot的区别

    1.numpy乘法运算中"*"是数组元素逐个计算 >>> import numpy as np >>> a = np.array([[2,3], ...

随机推荐

  1. C++STL priority_queue

    priority_queue优先级队列 最大值优先级队列(队头是最大值)  最小值优先级队列(队头是最小值) priority_queue<int> q1;//默认定义为最大值优先级队列 ...

  2. Spring Boot 入门实践

    一.Eclipse配置Spring Boot环境 1.查看eclipse版本信息: 2.登录:http://spring.io/tools/sts/all 看eclipse对应的插件版本对应的ecli ...

  3. css基本图形绘制(基本的矩形、圆形、椭圆、三角形、多边形,也包括稍微复杂一点的爱心、钻石、阴阳八卦等)

    正方形: 代码: <style> .square { width: 100px; height: 100px; background-color: cornflowerblue; } &l ...

  4. 1.9yield方法

    yield()方法的作用放弃当前的cpu资源,将他让给其他的任务去占用cpu的执行时间,但放弃的时间不确定,有可能刚放弃,马上又获得cpu时间片 测试 package com.cky.thread; ...

  5. Cacti Install Error

    Cacti Error happened while installing: ERROR: Your MySQL TimeZone database is not populated. Please ...

  6. Write Markdown Syntax Online Document with Sphinx and Pandoc

    There is no doubt that we have to write doc while we are developing software. But How do you write d ...

  7. Java类、超类、包

    定义和实例化与C#相同   特殊变量     super当前对象的父类,用于调用父类的变量和方法     this当前类对象                存取限制有3个     没有C#的inter ...

  8. poj1741(点分模板)

    #include<iostream> #include<cstring> #include<cmath> #include<cstdio> #inclu ...

  9. (BestCoder Round #64 (div.2))Array

    BestCoder Round #64 (div.2) Array 问题描述 Vicky是个热爱数学的魔法师,拥有复制创造的能力. 一开始他拥有一个数列{1}.每过一天,他将他当天的数列复制一遍,放在 ...

  10. Java案例:超市库存管理系统

    案例介绍: 模拟真实的库存管理逻辑,完成超市管理系统的日常功能实现,见下图 案例需求分析: 根据案例介绍,我们进行分析,首先需要一个功能菜单,然后输入功能序号后,调用序号对应的功能方法,实现想要的操作 ...