文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > IT/计算机 > 计算机软件及应用 > NumPy - Tentative NumPy Tutorial
侵权投诉

NumPy - Tentative NumPy Tutorial

However, we can not do this by putting i and j into an array, because this array will be interpreted asindexing the first dimension of a.

>>> s = array( [i,j] )

>>> a[s] # not what we want

Traceback (most recent call last):

File "<stdin>", line 1, in ?

IndexError: index (3) out of range (0<=index<=2) in dimension 0

>>>

>>> a[tuple(s)] # same as a[i,j]

array([[ 2, 5],

[ 7, 11]])

Another common use of indexing with arrays is the search of the maximum value of time-dependentseries :

>>> time = linspace(20, 145, 5) # time scale

>>> data = sin(arange(20)).reshape(5,4) # 4 time-dependent series

>>> time

array([ 20. , 51.25, 82.5 , 113.75, 145. ])

>>> data

array([[ 0. , 0.84147098, 0.90929743, 0.14112001],

[-0.7568025 , -0.95892427, -0.2794155 , 0.6569866 ],

[ 0.98935825, 0.41211849, -0.54402111, -0.99999021],

[-0.53657292, 0.42016704, 0.99060736, 0.65028784],

[-0.28790332, -0.96139749, -0.75098725, 0.14987721]])

>>>

>>> ind = data.argmax(axis=0) # index of the maxima for each series

>>> ind

array([2, 0, 3, 1])

>>>

>>> time_max = time[ ind] # times corresponding to the

maxima

>>>

>>> data_max = data[ind, xrange(data.shape[1])] # => data[ind[0],0],

data[ind[1],1]...

>>>

>>> time_max

array([ 82.5 , 20. , 113.75, 51.25])

>>> data_max

array([ 0.98935825, 0.84147098, 0.99060736, 0.6569866 ])

>>>

>>> all(data_max == data.max(axis=0))

True

上一页第20页

你可能喜欢

热门文档

相关文档

  • Tentative NumPy Tutorial -

    Tentative NumPy Tutorial -_计算机软件及应用_IT/计算机_专业资料 暂无评价0人阅读0次下载举报文档 Tentative NumPy Tutorial -_计算机软件及应用_IT/计算机_...

  • numpy官方参考手册

    See Also: numpy.doc.ufuncs Section “Output arguments” Examples >>> a = np.arange(10) >>> np.clip(a, 1, 8) array([1, 1, 2, 3, 4, 5,...

  • NumPy使用手记

    NumPy使用手记_计算机软件及应用_IT/计算机_专业资料。NumPy 使用手记[z] Posted...Tentative NumPy Tutori... 16页 免费 喜欢此文档的还喜欢 numpy官方参考手册 ...

  • Python教程:numpy的基本介绍

    Python 教程:numpy 的基本介绍 2012-04-10 12:58 作者: bukunu 来源: 本站 浏览: 1,430 views 我要评论(1 条) 字号: 大中小 摘要: 标准安装的 Python ...

  • Python下科学计算包numpy和SciPy的安装

    4、安装 numpy numpy 和 scipy 的安装过程都要显式的指明所用 fortran 编译器的类型,而且要与前面编译 atlas 时一致(在本文中即:gfortran),这一点非常重要,...

  • numpy学习

    numpy学习_计算机软件及应用_IT/计算机_专业资料。1. tile 函数 tile 函数是模板...NumPy 中的多维迭代器 暂无评价 31页 免费 Tentative NumPy Tutori... 暂无评...

  • 安装python numpy

    安装python numpy_计算机软件及应用_IT/计算机_专业资料。安装python numpy,出现问题,如何解决。安装python numpy 研究 python-nltk 时,需要安装 numpy。 采用下面的...

  • Python之路numpy用法

    Python之路numpy用法_计算机软件及应用_IT/计算机_专业资料。Python 之路——numpy 各函数简介之生成数组函数(Array creation routines) 1、empty(shape[, dtype, ...

  • numpy各函数简介之生成数组函数

    numpy各函数简介之生成数组函数_计算机软件及应用_IT/计算机_专业资料。numpy 各函数简介之生成数组函数 1. empty(shape[, dtype, order]): 依据给定形状和类型(...

  • 非root权限安装numpy和scipy

    非root权限安装numpy和scipy_生物学_自然科学_专业资料。linux上可行。Install Numpy and Scipy on CentOS without Root Privilege Sometimes you want to install Nu...

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email