[Numpy-discussion] speedy remove mean of rows

John Hunter jdhunter at ace.bsd.uchicago.edu
Thu Feb 27 20:27:15 CST 2003


I have a large (40,000 x 128) Numeric array, X, with typecode Float.
In some cases the number of rows may be approx 10x greater.

I want to create an array Y with the same dimensions as X, where each
element of Y is the corresponding element of X with the mean of the
row on which it occurs subtracted away.  Ie,

  Y = X - transpose(resize(mean(X,1), (X.shape[1],X.shape[0])))

I am wondering if this is the most efficient way (speed and memory).

Thanks for any suggestions,
John Hunter




More information about the Numpy-discussion mailing list