def logsum(lst):
    """Sums a list of log values, ensuring accuracy."""
    
    if not isinstance(lst, N.ndarray):
        lst = N.array(lst)
    
    maxval = lst.max()
    lst = maxval - lst
    return reduce(logadd, lst) + maxval


## from webpy (webpy.org)
dataset/ETHPy150Open abhik/pebl/src/pebl/util.py/logsum/swapped operands of `-`