[SciPy-User] reversing or avoiding the need to reverse argsort()

Vincent Davis vincent@vincentdavis....
Sat Mar 20 10:37:21 CDT 2010


What I want to do is simple but not sure the best way to go about it.

I have an array a, shape(a) = rXc I need to sort each column
aargsort = a.argsort(axis=0)  # May use this later
aSort = a.sort(axis=0)

now average each row
aSortRM = asort.mean(axis=1)

now replace each col in a row with the row mean.
is there a better way than this

aWithMeans = ones_like(a)
for ind in range(r)  # r = number of rows
    aWithMeans[ind]* aSortRM[ind]

Now I need to undo the sort I did in the first step.
I think this is where I need the aargsort (argsort of a before any
modification) I am kinda stumped on this step. Everything I think of is
rather convoluted.
Is it possible to do this whole process without actually rearranging the
original array and just using the index info from the argsort() and would I
want to do this?



  *Vincent Davis
720-301-3003 *
vincent@vincentdavis.net
 my blog <http://vincentdavis.net> |
LinkedIn<http://www.linkedin.com/in/vincentdavis>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20100320/4dc29e14/attachment.html 


More information about the SciPy-User mailing list