Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #6959
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail |
|---|---|
| From | Billy Mays <noway@nohow.com> |
| Newsgroups | comp.lang.python |
| Subject | Standard Deviation One-liner |
| Date | Fri, 03 Jun 2011 13:55:02 -0400 |
| Organization | Aioe.org NNTP Server |
| Lines | 16 |
| Message-ID | <isb75r$80h$1@speranza.aioe.org> (permalink) |
| NNTP-Posting-Host | 1EWTV5ij8IWwF9xB3mPhgA.user.speranza.aioe.org |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Complaints-To | abuse@aioe.org |
| User-Agent | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110424 Thunderbird/3.1.10 |
| X-Notice | Filtered by postfilter v. 0.8.2 |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:6959 |
Show key headers only | View raw
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