Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #6959
| From | Billy Mays <noway@nohow.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Standard Deviation One-liner |
| Date | 2011-06-03 13:55 -0400 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <isb75r$80h$1@speranza.aioe.org> (permalink) |
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)/len(d))**2 for x in d)/(1.*(len(d)-1)))**.5 The functions is invoked as follows: >>> a([1,2,3,4]) 1.2909944487358056
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Standard Deviation One-liner Billy Mays <noway@nohow.com> - 2011-06-03 13:55 -0400
Re: Standard Deviation One-liner Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2011-06-03 20:50 +0200
Re: Standard Deviation One-liner Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2011-06-03 21:10 +0200
Re: Standard Deviation One-liner Raymond Hettinger <python@rcn.com> - 2011-06-03 13:09 -0700
Re: Standard Deviation One-liner Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-05 17:26 +0000
Re: Standard Deviation One-liner Ethan Furman <ethan@stoneleaf.us> - 2011-06-05 12:17 -0700
csiph-web