On Tue, May 31, 2011 at 8:36 PM, Skipper Seabold <[email protected]>wrote:
> On Tue, May 31, 2011 at 9:31 PM, Benjamin Root <[email protected]> wrote: > > > > > > On Tue, May 31, 2011 at 8:18 PM, Warren Weckesser > > <[email protected]> wrote: > >> > >> > >> On Tue, May 31, 2011 at 8:08 PM, Charles R Harris > >> <[email protected]> wrote: > >>> > >>> Hi All, > >>> > >>> I've been contemplating new functions that could be added to numpy and > >>> thought I'd run them by folks to see if there is any interest. > >>> > >>> 1) Modified sort/argsort functions that return the maximum k values. > >>> This is easy to do with heapsort and almost as easy with mergesort. > >>> > >> > >> > >> While you're at, how about a function that finds both the max and min in > >> one pass? (Mentioned previously in this thread: > >> http://mail.scipy.org/pipermail/numpy-discussion/2010-June/051072.html) > >> > >> > > > > +1 from myself and probably just about anybody in matplotlib. If both > the > > maxs and mins are searched during the same run through an array, I would > > imagine that would result in a noticeable speedup with automatic range > > finding. > > > > I don't know if it's one pass off the top of my head, but I've used > percentile for interpercentile ranges. > > [docs] > [1]: X = np.random.random(1000) > > [docs] > [2]: np.percentile(X,[0,100]) > [2]: [0.00016535235312509222, 0.99961513543316571] > > [docs] > [3]: X.min(),X.max() > [3]: (0.00016535235312509222, 0.99961513543316571) > > percentile() isn't one pass; using percentile like that is much slower: In [25]: %timeit np.percentile(X,[0,100]) 10000 loops, best of 3: 103 us per loop In [26]: %timeit X.min(),X.max() 100000 loops, best of 3: 11.8 us per loop Warren > Skipper > _______________________________________________ > NumPy-Discussion mailing list > [email protected] > http://mail.scipy.org/mailman/listinfo/numpy-discussion >
_______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
