We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Day 4: Binomial Distribution II
Day 4: Binomial Distribution II
Sort by
recency
|
159 Discussions
|
Please Login in order to post a comment
Why this does not work? import math
def binomial_prob(n, k, p): return math.comb(n, k) * (p ** k) * ((1 - p) ** (n - k))
n = 10 p = 0.12
no_more_than_2 = sum(binomial_prob(n,k,p) for k in range(0, 3)) atleast_2 = sum(binomial_prob(n,k,p) for k in range(2, 11)) print(f"{no_more_than_2}:.3f") print(f"{atleast_2}:.3f")