美文网首页
permutation()的使用

permutation()的使用

作者: Xindolia_Ring | 来源:发表于2019-07-05 16:12 被阅读0次

permutation()的使用

  • 语法格式:
numpy.random.permutation(x) 

随机排列一个序列,或者数组。
如果x是多维数组,则沿其第一个坐标轴的索引随机排列数组。

  • 参数:
    x : 整数或者数组
    如果x是整数,则随机排列np.arange(x)。若果x是数组,对其复制之后再搅乱其元素。

  • 返回:
    out : 排列的序列或数组

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]])

作者:yangsong95
来源:CSDN
原文:https://blog.csdn.net/yangsong95/article/details/82502812
版权声明:本文为博主原创文章,转载请附上博文链接!

相关文章

网友评论

      本文标题:permutation()的使用

      本文链接:https://www.haomeiwen.com/subject/zijehctx.html