[Numpy-discussion] Find the N maximum values and correspondingindexes in an array

Nadav Horesh nadavh at visionsense.com
Thu Dec 3 01:34:34 EST 2009


Is it relevant to scipy.stats.scoreatpercentile?
There is a comment is that function:

    # TODO: this should be a simple wrapper around a well-written quantile
    # function.  GNU R provides 9 quantile algorithms (!), with differing
    # behaviour at, for example, discontinuities.

  Nadav.

-----Original Message-----
From: numpy-discussion-bounces at scipy.org on behalf of Neal Becker
Sent: Thu 03-Dec-09 05:26
To: numpy-discussion at scipy.org
Subject: Re: [Numpy-discussion] Find the N maximum values and correspondingindexes in an array
 
Neal Becker wrote:

> Keith Goodman wrote:
> ...
>> Oh, I thought he meant there was a numpy function for partial 
sorting.
>> 
Try this one:

template<typename in_t>
inline void partial_sort (in_t in, int n_el) {
  std::partial_sort (boost::begin (in), boost::begin(in) + n_el, 
boost::end (in));
}
...
  def ("partial_sort", 
&partial_sort<pyublas::numpy_strided_vector<int32_t> >);
  def ("partial_sort", 
&partial_sort<pyublas::numpy_strided_vector<int64_t> >);
  def ("partial_sort", 
&partial_sort<pyublas::numpy_strided_vector<double> >);
---------
import pyublas
import numpy as np
u = np.arange (20)[::-1]
from numpy_fncs import partial_sort
partial_sort (u, 4)
In [2]: u
Out[2]: 
array([ 0,  1,  2,  3, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10,  9,  8,  
7,
        6,  5,  4])

_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion at scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

-------------- next part --------------
A non-text attachment was scrubbed...
Name: winmail.dat
Type: application/ms-tnef
Size: 3850 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20091203/288b4e14/attachment.bin>


More information about the NumPy-Discussion mailing list