Re: Standard Deviation One-liner

2011-06-05 Thread Ethan Furman
Steven D'Aprano wrote: On Fri, 03 Jun 2011 13:09:43 -0700, Raymond Hettinger wrote: On Jun 3, 10:55 am, Billy Mays wrote: I'm trying to shorten a one-liner I have for calculating the standard deviation of a list of numbers. I have something so far, but I was wondering if it could be made any

Re: Standard Deviation One-liner

2011-06-05 Thread Steven D'Aprano
On Fri, 03 Jun 2011 13:09:43 -0700, Raymond Hettinger wrote: > On Jun 3, 10:55 am, Billy Mays wrote: >> I'm trying to shorten a one-liner I have for calculating the standard >> deviation of a list of numbers.  I have something so far, but I was >> wondering if it could be made any shorter (withou

Re: Standard Deviation One-liner

2011-06-03 Thread Raymond Hettinger
On Jun 3, 10:55 am, Billy Mays wrote: > I'm trying to shorten a one-liner I have for calculating the standard > deviation of a list of numbers.  I have something so far, but I was > wondering if it could be made any shorter (without imports). > > Here's my function: > > a=lambda d:(sum((x-1.*sum(d

Re: Standard Deviation One-liner

2011-06-03 Thread Alain Ketterlin
Alain Ketterlin writes: > aux = lambda s1,s2,n: (s2 - s1*s1/n)/(n-1) > sv = lambda d: aux(sum(d),sum(x*x for x in d),len(d)) Err, sorry, the final square root is missing. -- Alain. -- http://mail.python.org/mailman/listinfo/python-list

Re: Standard Deviation One-liner

2011-06-03 Thread Alain Ketterlin
Billy Mays writes: > I'm trying to shorten a one-liner I have for calculating the standard > deviation of a list of numbers. I have something so far, but I was > wondering if it could be made any shorter (without imports). > a=lambda d:(sum((x-1.*sum(d)/len(d))**2 for x in d)/(1.*(len(d)-1)))**