5. Is It a Valid Distribution?

Easy

The probabilities assigned to all outcomes of a sample space must each lie in [0,1][0, 1] and together sum to one:

ωΩP(ω)=1\sum_{\omega \in \Omega} P(\omega) = 1

Return True if the list is a valid distribution, else False. Allow a tiny floating-point tolerance on the sum.

solve([0.5, 0.25, 0.25])  ->  True
solve([0.5, 0.6])         ->  False

Sign in to write and run your own code.

Implement solve(...)