Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > RE: Mean, median, and mode - third time's the charm!!!

Reply
Thread Tools

RE: Mean, median, and mode - third time's the charm!!!

 
 
Frohnhofer, James
Guest
Posts: n/a
 
      12-06-2004
>
> median = lambda x: x.sort() or ((len(x) % 2) and (x[(len(x)>>1)])) or
> (sum(x[((len(x)>>1)-1)len(x)>>1)+1])/2.0)
>
> >>> median( [2,3,4,5,6,7])

> 4.5
> >>> median( [2,3,4,5,6])

> 4


How about

>>> median = lambda x: x.sort() or (x[(len(x)-1)/2] + x[len(x)/2])/2.0
>>> median([2,3,4,5,6,7])

4.5
>>> median( [2,3,4,5,6])

4.0
>>>



================================================== ============================
This message is for the sole use of the intended recipient. If you received
this message in error please delete it and notify us. If this message was
misdirected, CSFB does not waive any confidentiality or privilege. CSFB
retains and monitors electronic communications sent through its network.
Instructions transmitted over this system are not binding on CSFB until they
are confirmed by us. Message transmission is not guaranteed to be secure.
================================================== ============================

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: mmm-mode, python-mode and doctest-mode? Neal Becker Python 0 08-09-2007 12:10 PM
mmm-mode, python-mode and doctest-mode? Edward Loper Python 0 08-09-2007 05:40 AM
re: mmm-mode, python-mode and doctest-mode? John J Lee Python 0 08-07-2007 07:49 PM
re: mmm-mode, python-mode and doctest-mode? Edward Loper Python 0 08-07-2007 08:58 AM
mmm-mode, python-mode and doctest-mode? John J Lee Python 3 12-01-2005 08:35 PM



Advertisments