中位数定义及示例

def Median(t):
    """中位数"""
    arr = sorted(t)
    idx = (len(arr) - 1) / 2
    if type(idx) is int:
        return arr[idx]
    if type(idx) is float:
        return Mean(arr[int(math.floor(idx)):int(math.ceil(idx)) + 1])

 

posted @ 2014-07-14 10:43  data80386  阅读(616)  评论(0编辑  收藏  举报