[Numpy-discussion] indexing question

2010-11-21 Thread Ernest Adrogué
Hi, Suppose an array of shape (N,2,2), that is N arrays of shape (2,2). I want to select an element (x,y) from each one of the subarrays, so I get a 1-dimensional array of length N. For instance: In [228]: t=np.arange(8).reshape(2,2,2) In [229]: t Out[229]: array([[[0, 1], [2, 3]],

Re: [Numpy-discussion] indexing question

2010-11-21 Thread John Salvatier
read about basic slicing : http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html On Sun, Nov 21, 2010 at 11:28 AM, John Salvatier jsalv...@u.washington.edu wrote: yes use the symbol ':' so you want t[:,x,y] 2010/11/21 Ernest Adrogué eadro...@gmx.net: Hi, Suppose an array of

Re: [Numpy-discussion] indexing question

2010-11-21 Thread John Salvatier
yes use the symbol ':' so you want t[:,x,y] 2010/11/21 Ernest Adrogué eadro...@gmx.net: Hi, Suppose an array of shape (N,2,2), that is N arrays of shape (2,2). I want to select an element (x,y) from each one of the subarrays, so I get a 1-dimensional array of length N. For instance: In

Re: [Numpy-discussion] [ANN] Nanny, faster NaN functions

2010-11-21 Thread Keith Goodman
On Sun, Nov 21, 2010 at 10:25 AM, Wes McKinney wesmck...@gmail.com wrote: On Sat, Nov 20, 2010 at 7:24 PM, Keith Goodman kwgood...@gmail.com wrote: On Sat, Nov 20, 2010 at 3:54 PM, Wes McKinney wesmck...@gmail.com wrote: Keith (and others), What would you think about creating a library of

Re: [Numpy-discussion] [ANN] Nanny, faster NaN functions

2010-11-21 Thread josef . pktd
On Sun, Nov 21, 2010 at 2:48 PM, Keith Goodman kwgood...@gmail.com wrote: On Sun, Nov 21, 2010 at 10:25 AM, Wes McKinney wesmck...@gmail.com wrote: On Sat, Nov 20, 2010 at 7:24 PM, Keith Goodman kwgood...@gmail.com wrote: On Sat, Nov 20, 2010 at 3:54 PM, Wes McKinney wesmck...@gmail.com wrote:

Re: [Numpy-discussion] Where did the github numpy repository go?

2010-11-21 Thread Friedrich Romstedt
2010/11/14 Charles R Harris charlesr.har...@gmail.com: I keep getting page does not exist. The comments on the event, https://github.com/blog/744-today-s-outage, are simply great and stunning. Friedrich ___ NumPy-Discussion mailing list

Re: [Numpy-discussion] [ANN] Nanny, faster NaN functions

2010-11-21 Thread Wes McKinney
On Sat, Nov 20, 2010 at 7:24 PM, Keith Goodman kwgood...@gmail.com wrote: On Sat, Nov 20, 2010 at 3:54 PM, Wes McKinney wesmck...@gmail.com wrote: Keith (and others), What would you think about creating a library of mostly Cython-based domain specific functions? So stuff like rolling

Re: [Numpy-discussion] indexing question

2010-11-21 Thread Ernest Adrogué
Hi, 21/11/10 @ 11:28 (-0800), thus spake John Salvatier: yes use the symbol ':' so you want t[:,x,y] I tried that, but it's not the same: In [307]: t[[0,1],x,y] Out[307]: array([1, 7]) In [308]: t[:,x,y] Out[308]: array([[1, 3], [5, 7]]) No? -- Ernest

Re: [Numpy-discussion] [ANN] Nanny, faster NaN functions

2010-11-21 Thread Keith Goodman
On Sun, Nov 21, 2010 at 12:30 PM, josef.p...@gmail.com wrote: On Sun, Nov 21, 2010 at 2:48 PM, Keith Goodman kwgood...@gmail.com wrote: On Sun, Nov 21, 2010 at 10:25 AM, Wes McKinney wesmck...@gmail.com wrote: On Sat, Nov 20, 2010 at 7:24 PM, Keith Goodman kwgood...@gmail.com wrote: On Sat,

Re: [Numpy-discussion] [ANN] Nanny, faster NaN functions

2010-11-21 Thread josef . pktd
On Sun, Nov 21, 2010 at 5:09 PM, Keith Goodman kwgood...@gmail.com wrote: On Sun, Nov 21, 2010 at 12:30 PM,  josef.p...@gmail.com wrote: On Sun, Nov 21, 2010 at 2:48 PM, Keith Goodman kwgood...@gmail.com wrote: On Sun, Nov 21, 2010 at 10:25 AM, Wes McKinney wesmck...@gmail.com wrote: On Sat,

Re: [Numpy-discussion] [ANN] Nanny, faster NaN functions

2010-11-21 Thread Wes McKinney
On Sun, Nov 21, 2010 at 6:02 PM, josef.p...@gmail.com wrote: On Sun, Nov 21, 2010 at 5:09 PM, Keith Goodman kwgood...@gmail.com wrote: On Sun, Nov 21, 2010 at 12:30 PM,  josef.p...@gmail.com wrote: On Sun, Nov 21, 2010 at 2:48 PM, Keith Goodman kwgood...@gmail.com wrote: On Sun, Nov 21, 2010

[Numpy-discussion] Does np.std() make two passes through the data?

2010-11-21 Thread Keith Goodman
Does np.std() make two passes through the data? Numpy: arr = np.random.rand(10) arr.std() 0.3008736260967052 Looks like an algorithm that makes one pass through the data (one for loop) wouldn't match arr.std(): np.sqrt((arr*arr).mean() - arr.mean()**2) 0.30087362609670526 But a

Re: [Numpy-discussion] Does np.std() make two passes through the data?

2010-11-21 Thread josef . pktd
On Sun, Nov 21, 2010 at 6:43 PM, Keith Goodman kwgood...@gmail.com wrote: Does np.std() make two passes through the data? Numpy: arr = np.random.rand(10) arr.std()   0.3008736260967052 Looks like an algorithm that makes one pass through the data (one for loop) wouldn't match arr.std():

Re: [Numpy-discussion] Does np.std() make two passes through the data?

2010-11-21 Thread Robert Kern
On Sun, Nov 21, 2010 at 17:43, Keith Goodman kwgood...@gmail.com wrote: Does np.std() make two passes through the data? Yes. See PyArray_Std() in numpy/core/src/calculation.c -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by

Re: [Numpy-discussion] Does np.std() make two passes through the data?

2010-11-21 Thread Keith Goodman
On Sun, Nov 21, 2010 at 4:18 PM, josef.p...@gmail.com wrote: On Sun, Nov 21, 2010 at 6:43 PM, Keith Goodman kwgood...@gmail.com wrote: Does np.std() make two passes through the data? Numpy: arr = np.random.rand(10) arr.std()   0.3008736260967052 Looks like an algorithm that makes one

Re: [Numpy-discussion] [ANN] Nanny, faster NaN functions

2010-11-21 Thread Wes McKinney
On Sun, Nov 21, 2010 at 6:37 PM, Keith Goodman kwgood...@gmail.com wrote: On Sun, Nov 21, 2010 at 3:16 PM, Wes McKinney wesmck...@gmail.com wrote: What would you say to a single package that contains: - NaN-aware NumPy and SciPy functions (nanmean, nanmin, etc.) I'd say yes. - moving

Re: [Numpy-discussion] Does np.std() make two passes through the data?

2010-11-21 Thread Keith Goodman
On Sun, Nov 21, 2010 at 5:56 PM, Robert Kern robert.k...@gmail.com wrote: On Sun, Nov 21, 2010 at 19:49, Keith Goodman kwgood...@gmail.com wrote: But this sample gives a difference: a = np.random.rand(100) a.var()   0.080232196646619805 var(a)   0.080232196646619791 As you know, I'm

[Numpy-discussion] Slow element-by-element access?

2010-11-21 Thread Bruce Sherwood
A colleague showed me a program using Numeric with Python 2.5 which ran much faster than the same program using numpy with Python 2.7. I distilled this down to a simple test case, characterized by a for loop in which he does an element-by-element calculation involving arrays: from numpy import

Re: [Numpy-discussion] Slow element-by-element access?

2010-11-21 Thread Charles R Harris
On Sun, Nov 21, 2010 at 11:17 PM, Bruce Sherwood bashe...@ncsu.edu wrote: A colleague showed me a program using Numeric with Python 2.5 which ran much faster than the same program using numpy with Python 2.7. I distilled this down to a simple test case, characterized by a for loop in which he

[Numpy-discussion] categorical distributions

2010-11-21 Thread Hagen Fürstenau
Hi, numpy doesn't seem to have a function for sampling from simple categorical distributions. The easiest solution I could come up with was something like from numpy.random import multinomial multinomial(1, [.5, .3, .2]).nonzero()[0][0] 1 but this is bound to be inefficient as soon as the