"RonnyM" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> e.g. y = [ 1, 2, 3, 4, 5, 6 ,7 ,8, 9 ]

> ybar = [ 1, (1 + 3)*.5,(2 + 4)*.5,(3 + 5)*.5,..., (n-1 + n+1)*.5 ], n =
> 1,...len(y) -1
> How do I make a vectorized version of this, I will prefer not to
> utilize Map or similar functions, but numeric instead.


You treat the first element asymmetrically, so that does not vectorize.
The rest does:
>>> import numpy as N
>>> y=N.arange(1,10)
>>> slice1 = slice(0,-2,1)
>>> slice2 = slice(2,None,1)
>>> ybar = 0.5*(y[slice1]+y[slice2])
>>> ybar
array([ 2.,  3.,  4.,  5.,  6.,  7.,  8.])

hth,
Alan Isaac


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to