[Numpy-discussion] Can this be done more efficiently using numpy?
Vishal Rana
ranavishal@gmail....
Thu Apr 1 01:13:54 CDT 2010
Hi,
A calculation which goes like this...
n = 5
a = np.arange(1000)
b = np.arange(n - 1, 1000)
l = []
for i in range(b.size):
# Absolute difference of n a elements and nth b element
x = np.abs(a[i:i + n] - b[i])
# Average of x
y = x.sum() / n
l.append(y)
It takes a while if I have like 200K records!
Is there a more efficient way to do this using numpy?
Thanks
Vishal Rana
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20100331/b7421049/attachment-0001.html
More information about the NumPy-Discussion
mailing list