[Numpy-discussion] any better way to normalise a matrix
devnew at gmail.com
devnew at gmail.com
Thu Dec 27 23:34:55 EST 2007
in my code i am trying to normalise a matrix as below
mymatrix=matrix(..# items are of double type..can be negative
values....)
numrows,numcols=mymatrix.shape
for i in range(numrows):
temp=mymatrix[i].max()
for j in range(numcols):
mymatrix[i,j]=abs(mymatrix[i,j]/temp)
# i am using abs() to make neg vals positive
this way the code takes too much time to run for a case of
numrows=25, and numcols=8100 etc..
being a beginner in numpy and python ,i would like to know if this can
be done more efficiently..can anyone advise?
thanx
dn
More information about the NumPy-Discussion
mailing list