Re: [Numpy-discussion] sample without replacement

2010-12-20 Thread josef . pktd
On Mon, Dec 20, 2010 at 10:19 PM, Alan G Isaac wrote: > On 12/20/2010 9:41 PM, josef.p...@gmail.com wrote: >> python has it in random >> >> sample( population, k) > > > Yes, I mentioned this in my original post: > http://www.mail-archive.com/numpy-discussion@scipy.org/msg29324.html > > But good si

Re: [Numpy-discussion] sample without replacement

2010-12-20 Thread Alan G Isaac
On 12/20/2010 9:41 PM, josef.p...@gmail.com wrote: > python has it in random > > sample( population, k) Yes, I mentioned this in my original post: http://www.mail-archive.com/numpy-discussion@scipy.org/msg29324.html But good simulation practice is perhaps to seed a simulation specific random num

Re: [Numpy-discussion] sample without replacement

2010-12-20 Thread josef . pktd
On Mon, Dec 20, 2010 at 11:28 AM, Alan G Isaac wrote: > I want to sample *without* replacement from a vector > (as with Python's random.sample).  I don't see a direct > replacement for this, and I don't want to carry two > PRNG's around.  Is the best way something like  this? > >        permutatio

Re: [Numpy-discussion] Links to doc guidelines broken

2010-12-20 Thread Ralf Gommers
On Fri, Dec 17, 2010 at 10:16 PM, Fernando Perez wrote: > Howdy, > > In the ipython doc guide (and many other places) we point to the numpy > coding guidelines (especially for documentation), but today while > conducting a sprint at the Scipy India conference, I noticed this > link is now dead: >

Re: [Numpy-discussion] Short circuiting the all() and any() methods/functions

2010-12-20 Thread Pauli Virtanen
ma, 2010-12-20 kello 15:32 -0700, Justin Peel kirjoitti: > I'm using version 2.0.0.dev8716, which should be new enough I would > think. Let me show you what makes me think that there isn't > short-circuiting going on. > > I'll do two timeit's from the command line: > > $ python -m timeit -s 'imp

Re: [Numpy-discussion] Reversing an array in-place

2010-12-20 Thread Justin Peel
Oh, you're quite right. I should have looked more closely into this. Thanks for the reply. On Mon, Dec 20, 2010 at 2:15 PM, Charles R Harris wrote: > > > On Mon, Dec 20, 2010 at 1:25 PM, Justin Peel wrote: >> >> I noticed that there is currently no way to reverse a numpy array >> in-place. The c

Re: [Numpy-discussion] Short circuiting the all() and any() methods/functions

2010-12-20 Thread Justin Peel
I'm using version 2.0.0.dev8716, which should be new enough I would think. Let me show you what makes me think that there isn't short-circuiting going on. I'll do two timeit's from the command line: $ python -m timeit -s 'import numpy as np; x = np.ones(20)' 'x.all()' 100 loops, best of 3: 3

[Numpy-discussion] Giving numpy the ability to multi-iterate excluding an axis

2010-12-20 Thread John Salvatier
A while ago, I asked a whether it was possible to multi-iterate over several ndarrays but exclude a certain axis( http://www.mail-archive.com/numpy-discussion@scipy.org/msg29204.html), sort of a combination of PyArray_IterAllButAxis and PyArray_MultiIterNew. My goal was to allow creation of relativ

Re: [Numpy-discussion] Reversing an array in-place

2010-12-20 Thread Charles R Harris
On Mon, Dec 20, 2010 at 1:25 PM, Justin Peel wrote: > I noticed that there is currently no way to reverse a numpy array > in-place. The current way to reverse a numpy array is using slicing, > ala arr[::-1]. This is okay for small matrices, but for really large > ones, this can be prohibitive. No

Re: [Numpy-discussion] Short circuiting the all() and any() methods/functions

2010-12-20 Thread Charles R Harris
On Mon, Dec 20, 2010 at 1:25 PM, Justin Peel wrote: > It has come to my attention that the all() and any() methods/functions > do not short circuit. It takes nearly as much time to call any() on an > array which has 1 as the first entry as it does to call it on an array > of the same size full of

Re: [Numpy-discussion] creating zonal statistics from two arrays

2010-12-20 Thread Matt Gregory
On 12/8/2010 9:48 AM, josef.p...@gmail.com wrote: > Just a thought since I'm not doing spatial statistics. > > If you can create (integer) labels that assigns each point to a zone, > then you can treat it essentially as a 1d grouped data, and you could > use np.bincount to calculate some statistics

[Numpy-discussion] Short circuiting the all() and any() methods/functions

2010-12-20 Thread Justin Peel
It has come to my attention that the all() and any() methods/functions do not short circuit. It takes nearly as much time to call any() on an array which has 1 as the first entry as it does to call it on an array of the same size full of zeros. The cause of the problem is that all() and any() just

[Numpy-discussion] Reversing an array in-place

2010-12-20 Thread Justin Peel
I noticed that there is currently no way to reverse a numpy array in-place. The current way to reverse a numpy array is using slicing, ala arr[::-1]. This is okay for small matrices, but for really large ones, this can be prohibitive. Not only that, but an in-place reverse is much faster than slici

Re: [Numpy-discussion] sample without replacement

2010-12-20 Thread John Salvatier
I think this is not possible to do efficiently with just numpy. If you want to do this efficiently, I wrote a no-replacement sampler in Cython some time ago (below). I hearby release it to the public domain. ''' Created on Oct 24, 2009 http://stackoverflow.com/questions/311703/algorithm-for-sampl

[Numpy-discussion] Links to doc guidelines broken

2010-12-20 Thread Fernando Perez
Howdy, In the ipython doc guide (and many other places) we point to the numpy coding guidelines (especially for documentation), but today while conducting a sprint at the Scipy India conference, I noticed this link is now dead: http://projects.scipy.org/numpy/wiki/CodingStyleGuidelines It seems

[Numpy-discussion] Efficient Matrix-matrix product of hermitian matrices, zhemm (blas) and numpy

2010-12-20 Thread qubax
I need to calculate several products of matrices where at least one of them is always hermitian. The function zhemm (in blas, level 3) seems to directly do that in an efficient manner. However ... how can i access that function and dirctly apply it on numpy arrays? If you know alternatives that a

[Numpy-discussion] sample without replacement

2010-12-20 Thread Alan G Isaac
I want to sample *without* replacement from a vector (as with Python's random.sample). I don't see a direct replacement for this, and I don't want to carry two PRNG's around. Is the best way something like this? permutation(myvector)[:samplesize] Thanks, Alan Isaac

Re: [Numpy-discussion] same name and title in structured arrays

2010-12-20 Thread Pauli Virtanen
On Mon, 13 Dec 2010 16:39:20 -0500, Kathleen M Tacina wrote: > I've been finding numpy/scipy/matplotlib a very useful tool for data > analysis. However, a recent change has caused me some problems. > > Numpy used to allow the name and title of a column of a structured array > or recarray to be th