def normalize(vectorOrCounter):
    normalizedCounter = Counter()
    if isinstance(vectorOrCounter, type(normalizedCounter)):
        counter = vectorOrCounter
        total = float(counter.totalCount())
        if total == 0:
            return counter
        for key in counter.keys():
            value = counter[key]
            normalizedCounter[key] = value / total
        return normalizedCounter
    else:
        vector = vectorOrCounter
        s = float(sum(vector))
        if s == 0:
            return vector
        return [el / s for el in vector]
normalize a vector or counter by dividing each value by the sum of all values
dataset/ETHPy150Open rlpy/rlpy/rlpy/Domains/PacmanPackage/util.py/normalize