[PYTHON MATRIX-SIG] reduce methods

Konrad Hinsen hinsen@ibs.ibs.fr
Thu, 30 Jan 1997 12:32:39 +0100


> If we don't change the axis to 1 we can't 'easy' subtract the mean
> from a field.

I am not quite sure what you mean by "field" and "mean of a field".
If a rank-2 array a is supposed to represent a list of vectors,
then m=add.reduce(a)/len(a) will be its mean, and a-m will subtract
the mean vector from each vector in a.

Of course there may be other cases: if a is a matrix and you want to
subtract the mean of all its elements, you need a-add.reduce(ravel(a)).
Again, no explicit axis argument.

You do need to specify the axis if you want to subtract the mean of
all columns of a, which seems what you were after in your example.

Konrad.
-- 
-------------------------------------------------------------------------------
Konrad Hinsen                          | E-Mail: hinsen@ibs.ibs.fr
Laboratoire de Dynamique Moleculaire   | Tel.: +33-4.76.88.99.28
Institut de Biologie Structurale       | Fax:  +33-4.76.88.54.94
41, av. des Martyrs                    | Deutsch/Esperanto/English/
38027 Grenoble Cedex 1, France         | Nederlands/Francais
-------------------------------------------------------------------------------

_______________
MATRIX-SIG  - SIG on Matrix Math for Python

send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
_______________