Re: [Numpy-discussion] algorithm for faster median calculation ?

2013-01-15 Thread Sturla Molden
On 15.01.2013 20:50, Sturla Molden wrote: You might want to look at this first: https://github.com/numpy/numpy/issues/1811 Yes it is possible to compute the median faster by doing quickselect instead of quicksort. Best case O(n) for quickselect, O(n log n) for quicksort. But adding selection

Re: [Numpy-discussion] argsort

2013-01-15 Thread eat
Hi, On Tue, Jan 15, 2013 at 1:50 PM, Mads Ipsen wrote: > Hi, > > I simply can't understand this. I'm trying to use argsort to produce > indices that can be used to sort an array: > > from numpy import * > > indices = array([[4,3],[1,12],[23,7],[11,6],[8,9]]) > args = argsort(indices, axis

Re: [Numpy-discussion] algorithm for faster median calculation ?

2013-01-15 Thread Sturla Molden
You might want to look at this first: https://github.com/numpy/numpy/issues/1811 Yes it is possible to compute the median faster by doing quickselect instead of quicksort. Best case O(n) for quickselect, O(n log n) for quicksort. But adding selection and partial sorting to NumPy is a bigger is

Re: [Numpy-discussion] algorithm for faster median calculation ?

2013-01-15 Thread Christoph Deil
On Jan 15, 2013, at 8:31 PM, Jerome Caron wrote: > Dear all, > I am new to the Numpy-discussion list. > I would like to follow up some possibly useful information about calculating > median. > The message below was posted today on the AstroPy mailing list. > Kind regards > Jerome Caron > > #-

[Numpy-discussion] algorithm for faster median calculation ?

2013-01-15 Thread Jerome Caron
Dear all, I am new to the Numpy-discussion list. I would like to follow up some possibly useful information about calculating median. The message below was posted today on the AstroPy mailing list. Kind regards Jerome Caron # I think the calculation of medi

Re: [Numpy-discussion] dtype "reduction" [SOLVED]

2013-01-15 Thread Nicolas Rougier
I ended coding the dtype reduction, it's not foolproof but it might be useful for others as well. Nicolas import numpy as np def dtype_reduce(dtype, level=0, depth=0): """ Try to reduce dtype up to a given level when it is possible dtype = [ ('vertex', [('x', 'f4'), ('y', 'f4

Re: [Numpy-discussion] argsort

2013-01-15 Thread Robert Kern
On Tue, Jan 15, 2013 at 3:44 PM, Charles R Harris wrote: > Fancy indexing is a funny creature and not easy to understand in more than > one dimension. What is happening is that each index is replaced by the > corresponding row of a and the result is of shape (5,2,2). To do what you > want to do: >

Re: [Numpy-discussion] argsort

2013-01-15 Thread Charles R Harris
On Tue, Jan 15, 2013 at 4:50 AM, Mads Ipsen wrote: > Hi, > > I simply can't understand this. I'm trying to use argsort to produce > indices that can be used to sort an array: > > from numpy import * > > indices = array([[4,3],[1,12],[23,7],[11,6],[8,9]]) > args = argsort(indices, axis=0) >

[Numpy-discussion] argsort

2013-01-15 Thread Mads Ipsen
Hi, I simply can't understand this. I'm trying to use argsort to produce indices that can be used to sort an array: from numpy import * indices = array([[4,3],[1,12],[23,7],[11,6],[8,9]]) args = argsort(indices, axis=0) print indices[args] gives: [[[ 1 12] [ 4 3]] [[ 4 3] [1