[Numpy-discussion] Familiar w/ reduce ?
Pierre GM
pgmdevlist@gmail....
Mon Jun 25 18:27:53 CDT 2007
All,
I have a (m_1+1,m_2+1) matrix of 0 and 1, and I need to compute a second
matrix U by recurrence.
A double-loop as such
#............................
U = empty((m_1+1, m_2+1))
U[:,0] = C[:,0]
U[0,:] = C[0,:]
for i in range(1,m_1+1):
for j in range(1,m_2+1):
U[i,j] = C[i,j] * (U[i,j-1] + U[i-1,j])
#............................
does the trick, but I suspect there is not a simpler, more elegant solution.
Would anybody have any idea ?
Thanks a lot in advance, and all my apologies for being a tad lazy...
(PS: FYI, it's for a reimplementation of the Kolmogorov-Smirnov test
statistic, where ties occur)
P.
More information about the Numpy-discussion
mailing list