Re: [Numpy-discussion] A question about argmax and argsort

2006-12-20 Thread Robert Kern
Pierre GM wrote: > On Wednesday 20 December 2006 18:02, Tom Denniston wrote: >> If you want the n largest item i would recommend quicksort > ... >> I don't know of a way to do this in numpy. I think it would require >> adding a cfunction to numpy. Perhaps an "argnth" function? >> >> Does anyone

Re: [Numpy-discussion] A question about argmax and argsort

2006-12-20 Thread Pierre GM
On Wednesday 20 December 2006 18:02, Tom Denniston wrote: > If you want the n largest item i would recommend quicksort ... > I don't know of a way to do this in numpy. I think it would require > adding a cfunction to numpy. Perhaps an "argnth" function? > > Does anyone else know of an existing m

Re: [Numpy-discussion] A question about argmax and argsort

2006-12-20 Thread Tom Denniston
If you want the n largest item i would recommend quicksort but at each partition you only recurse into the side of the pivot that has the values you care about. This is easy to determine because you know how many items are on either side of the pivot and you know that you want the nth item. This

[Numpy-discussion] A question about argmax and argsort

2006-12-19 Thread asaf david
Hello Let's say i have an N sized array, and i want to get the positions of the K largest items. for K = 1 this is simply argmax. is there any way to generalize it for k !=1? currently I use argsort and take only K items from it, but I'm paying an additional ~lg(N)... Thanks in advance, asaf