def METHOD_NAME(vals, above_half=None):
    shift = (vals - 0.5).abs()
    if above_half is None:
        above_half = vals.median() > 0.5
    if above_half:
        return 0.5 + shift
    return 0.5 - shift