[Numpy-discussion] A better median function?

Sturla Molden sturla@molden...
Tue Aug 25 16:43:27 CDT 2009

Chad Netzer skrev:
> My current plan of attack is to deliver a partition() function that
> basically returns an array such that elements less than the pivot(s)
> come first, then the pivot(s), then the elements greater than the
> pivot(s).  

I'm actually trying to write a fast median replacement myself. I was 
thinking in the same lines, except I don't store those two arrays. I 
just keep track of counts in them. For the even case, I also keep track 
the elements closest to the pivot (smaller and bigger). It's incredibly 
simple actually. So lets see who gets there first :-)

Sturla Molden

More information about the NumPy-Discussion mailing list