MCPcopy Index your code
hub / github.com/clips/pattern / median

Function median

pattern/metrics.py:545–554  ·  view source on GitHub ↗

Returns the value that separates the lower half from the higher half of values in the list.

(list)

Source from the content-addressed store, hash-verified

543avg = mean
544
545def median(list):
546 """ Returns the value that separates the lower half from the higher half of values in the list.
547 """
548 s = sorted(list)
549 n = len(list)
550 if n == 0:
551 raise ValueError, "median() arg is an empty sequence"
552 if n % 2 == 0:
553 return float(s[(n/2)-1] + s[n/2]) / 2
554 return s[n/2]
555
556def variance(list, sample=True):
557 """ Returns the variance of the given list of values.

Callers

nothing calls this directly

Calls 1

lenFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…