[Numpy-discussion] Broadcasting rules (Ticket 76).

Sasha ndarray at mac.com
Thu Apr 27 10:52:01 CDT 2006


On 4/27/06, Keith Goodman <kwgoodman at gmail.com> wrote:
> [...]
> In Octave or Matlab, all you need to do is sum(x,1). For example:
>
> >> x = rand(1,4)
> x =
>
>   0.56755  0.24575  0.53804  0.36521
>
> >> sum(x,1)
> ans =
>
>   0.56755  0.24575  0.53804  0.36521
>

How is this different from Numpy:

>>> x = matrix(rand(4))
>>> sum(x.T, 1)
matrix([[ 0.36186805],
       [ 0.90198107],
       [ 0.60407661],
       [ 0.49523327]])




More information about the Numpy-discussion mailing list