[PYTHON MATRIX-SIG] reduce methods
janko hauser
jhauser@ifm.uni-kiel.de
Thu, 30 Jan 1997 09:14:06 +0100
If we don't change the axis to 1 we can't 'easy' subtract the mean
from a field.
Old mean (no axis=1)
>>> a
0 1 2
3 4 5
6 7 8
>>> a-M.mean(a)
-3. -3. -3.
0. 0. 0.
3. 3. 3.
>>> a-M.mean(a,1)
-1. -3. -5.
2. 0. -2.
5. 3. 1.
New mean (with axis=1)
>>> a-M.mean(a,1)
-1. 0. 1.
-1. 0. 1.
-1. 0. 1.
And the "sum of a list of numbers" is a number.
msum(a,None) => 36
Konrad Hinsen writes:
> > In the second case, we're finding the minimum value in each row, so the
> > result I would expect is:
> >
> > 2
> > 4
> >
> > In other words, I'd expect the axis that was "reduced" to change to a length
> > of one instead of completely going away. Modifying Janko's min function to
>
> But this is not how reduction works in Python (the built-in function
> "reduce") or in any of the array languages I know. It's also not what
> I would expect from a plain-English description: for me, a "sum of
> a list of numbers" is a number, not a list of length one.
>
> 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
> _______________
_______________
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
_______________