def get_median(values, kdd):
if not values:<EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>sorted_values = deepcopy(values)<EOL>sorted_values.sort() <EOL>if kdd:<EOL><INDENT>return sorted_values[len(values)/<NUM_LIT:2>]<EOL><DEDENT>else:<EOL><INDENT>if len(values) % <NUM_LIT:2> == <NUM_LIT:0>:<EOL><INDENT>return sorted_values[len(values)/<NUM_LIT:2>-<NUM_LIT:1>]<EOL><DEDENT>else:<EOL><INDENT>return sorted_values[len(values)/<NUM_LIT:2>]<EOL><DEDENT><DEDENT>
Given an unsorted list of numeric values, return median value (as a float).
Note that in the case of even-length lists of values, we apply the value to
the left of the center to be the median (such that the median can only be
a value from the list of values).
Eg: get_median([1,2,3,4]) == 2, not 2.5.