def drawGibbs(vals, temperature=1.):
    """ Return the index of the sample drawn by a softmax (Gibbs). """
    if temperature == 0:
        # randomly pick one of the values with the max value.
        m = max(vals)
        best = []
        for i, v in enumerate(vals):
            if v == m:
                best.append(i)
        return choice(best)
    else:
        temp = temperature / vals

        # make sure we keep the exponential bounded (between +20 and -20)
        temp += 20 - max(temp)
        if min(temp) < -20:
            for i, v in enumerate(temp):
                if v < -20:
                    temp[i] = -20
        temp = exp(temp)
        temp /= sum(temp)
        return drawIndex(temp)
dataset/ETHPy150Open pybrain/pybrain/pybrain/utilities.py/drawGibbs/swapped operands of `/`