Explore Library
Code QuizIntermediate

Normalizing a Probability Distribution

Finding why weights fail to sum to one after 'normalization'.

Codepython
def normalize(weights):
    total = sum(weights)
    return [w * total for w in weights]

print(normalize([2, 2, 4]))

What is the bug in this normalization function?