Re: [Numpy-discussion] summing over more than one axis

2010-08-19 Thread Bruce Southey
On 08/19/2010 04:20 PM, josef.p...@gmail.com wrote: On Thu, Aug 19, 2010 at 4:03 PM, John Salvatier wrote: Precise in what sense? Numerical accuracy? If so, why is that? I don't remember where I ran into this example, maybe integer underflow (?) with addition. NIST ANOVA test cases have some

Re: [Numpy-discussion] summing over more than one axis

2010-08-19 Thread josef . pktd
On Thu, Aug 19, 2010 at 4:03 PM, John Salvatier wrote: > Precise in what sense? Numerical accuracy? If so, why is that? I don't remember where I ran into this example, maybe integer underflow (?) with addition. NIST ANOVA test cases have some nasty badly scaled variables but I have problems crea

Re: [Numpy-discussion] summing over more than one axis

2010-08-19 Thread Jeremiah
Word size. imagine 2.123456789 vs 22.12345679 the more that can stored to the right of the decimal, the more precise. That larger the number is on the left, the less that can stored on the right. On Thu, Aug 19, 2010 at 4:03 PM, John Salvatier wrote: > Precise in what sense? Numerical accuracy

Re: [Numpy-discussion] summing over more than one axis

2010-08-19 Thread John Salvatier
Precise in what sense? Numerical accuracy? If so, why is that? On Thu, Aug 19, 2010 at 12:13 PM, wrote: > On Thu, Aug 19, 2010 at 11:29 AM, Joe Harrington > wrote: > > On Thu, 19 Aug 2010 09:06:32 -0500, G?khan Sever > wrote: > > > >>On Thu, Aug 19, 2010 at 9:01 AM, greg whittier wrote: > >>

Re: [Numpy-discussion] summing over more than one axis

2010-08-19 Thread josef . pktd
On Thu, Aug 19, 2010 at 11:29 AM, Joe Harrington wrote: > On Thu, 19 Aug 2010 09:06:32 -0500, G?khan Sever > wrote: > >>On Thu, Aug 19, 2010 at 9:01 AM, greg whittier wrote: >> >>> I frequently deal with 3D data and would like to sum (or find the >>> mean, etc.) over the last two axes.  I.e. su

Re: [Numpy-discussion] summing over more than one axis

2010-08-19 Thread Joe Harrington
On Thu, 19 Aug 2010 09:06:32 -0500, G?khan Sever wrote: >On Thu, Aug 19, 2010 at 9:01 AM, greg whittier wrote: > >> I frequently deal with 3D data and would like to sum (or find the >> mean, etc.) over the last two axes. I.e. sum a[i,j,k] over j and k. >> I find using .sum() really convenient f

Re: [Numpy-discussion] summing over more than one axis

2010-08-19 Thread Dave
greg whittier gmail.com> writes: > > a = np.arange(27).reshape(3,3,3) > > # sum over axis 1 and 2 > result = a.reshape((a.shape[0], a.shape[1]*a.shape[2])).sum(axis=1) > > Is there a cleaner way to do this? I'm sure I'm missing something obvious. > Only slightly more convenient is: a.reshape

Re: [Numpy-discussion] summing over more than one axis

2010-08-19 Thread greg whittier
On Thu, Aug 19, 2010 at 10:12 AM, Angus McMorland wrote: > Another rank-generic approach is to use apply_over_axes (you get a > different shape to the result this way): > > a = np.random.randint(20, size=(4,3,5)) > b = np.apply_over_axes(np.sum, a, [1,2]).flat > assert( np.all( b == a.sum(axis=2).

Re: [Numpy-discussion] summing over more than one axis

2010-08-19 Thread Angus McMorland
On 19 August 2010 10:01, greg whittier wrote: > I frequently deal with 3D data and would like to sum (or find the > mean, etc.) over the last two axes.  I.e. sum a[i,j,k] over j and k. > I find using .sum() really convenient for 2d arrays but end up > reshaping 2d arrays to do this.  I know there

Re: [Numpy-discussion] summing over more than one axis

2010-08-19 Thread Gökhan Sever
On Thu, Aug 19, 2010 at 9:01 AM, greg whittier wrote: > I frequently deal with 3D data and would like to sum (or find the > mean, etc.) over the last two axes. I.e. sum a[i,j,k] over j and k. > I find using .sum() really convenient for 2d arrays but end up > reshaping 2d arrays to do this. I kn

Re: [Numpy-discussion] summing over more than one axis

2010-08-19 Thread Ian Mallett
Hi, Couldn't you do it with several sum steps? E.g.: result = array.sum(axis=1).sum(axis=2) Ian ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

[Numpy-discussion] summing over more than one axis

2010-08-19 Thread greg whittier
I frequently deal with 3D data and would like to sum (or find the mean, etc.) over the last two axes. I.e. sum a[i,j,k] over j and k. I find using .sum() really convenient for 2d arrays but end up reshaping 2d arrays to do this. I know there has to be a more convenient way. Here's what I'm doing