[Numpy-discussion] indexing question

Robin robince@gmail....
Thu Mar 5 04:40:14 CST 2009


Hi,

I have an indexing problem, and I know it's a bit lazy to ask the
list, sometime when people do interesting tricks come up so I hope no
one minds!

I have a 2D array X.shape = (a,b)

and I want to change it into new array which is shape (2,(a*b)) which
has the following form:
[  X[0,0], X[0,1]
   X[1,0], X[1,1]
   X[2,0], X[2,1]
   ....
   X[a,0], X[a,1]
   X[0,1], X[0,2]
   X[1,1], X[1,2]
...
]

The first access is trials and the second axis is the different
outputs, which I am trying to represent as an overlapping sliding
window of 2 samples (but in general n). Because of the repeats I'm not
sure if I can do it without loops.

Thanks for any help

 Cheers

Robin


More information about the Numpy-discussion mailing list