That's cool. Thanks for your fast answer. Greetings, Uwe
On 15 Okt., 12:56, "Charles R Harris" <[EMAIL PROTECTED]> wrote: > On Wed, Oct 15, 2008 at 4:47 AM, Uwe Schmitt <[EMAIL PROTECTED] > > > > > wrote: > > Hi, > > > I got a matrix of 2100 lines, and I want to calculate blockwise mean > > vectors. > > Each block consists of 10 consecutive rows. > > > My code looks like this: > > > rv = [] > > for i in range(0, 2100, 10): > > rv.append( mean(matrix[i:i+10], axis=0)) > > > return array(rv) > > > Is there a more elegant and may be faster method to perform this > > calculation ? > > Something like > > In [1]: M = np.random.ranf((40,5)) > > In [2]: M.reshape(4,10,5).mean(axis=1) > Out[2]: > array([[ 0.57979278, 0.50013352, 0.66783389, 0.4009187 , 0.36379445], > [ 0.46938844, 0.34449102, 0.56419189, 0.49134703, 0.61380198], > [ 0.5644788 , 0.61734034, 0.3656104 , 0.63147275, 0.46319345], > [ 0.56556899, 0.59012606, 0.39691084, 0.26566127, 0.57107896]]) > > Chuck > > _______________________________________________ > Numpy-discussion mailing list > [EMAIL PROTECTED]://projects.scipy.org/mailman/listinfo/numpy-discussion _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion