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.
If submitting R code, use something like
cat(round(answer1 ,3),round(answer2,3),sep = "\n").
Using two cat() calls like:
cat(round(answer1 ,3))
cat(round(answer2 ,3))
will cause submission to fail.
from math import factorial as fact
Permutation
def permutation(n, r): return fact(n)/(fact(n-r))
Combinations
def combination(n, r): return permutation(n,r)/fact(r)
BINOMIAL DISTRIBUTION
def binomial_dist(n, x, p):
q = 1-p
return combination(n, x)*(p**x)(q*(n-x))
you do the rest. :)
p = 0.12 n = 10 q1 = sum([binomial_dist(n, x, p) for x in range(0, 3)]) q2 = sum([binomial_dist(n, x, p) for x in range(2, 11)])
print(round(q1, 3)) print(round(q2, 3))
If submitting R code, use something like
cat(round(answer1 ,3),round(answer2,3),sep = "\n").
Using two cat() calls like:cat(round(answer1 ,3)) cat(round(answer2 ,3))
will cause submission to fail.My ans is perfectly right!Why is it giving error? I found the same ques on this website http://www.intmath.com/counting-probability/12-binomial-probability-distributions.php
read the question more carefully. You're supposed to round it off to 3 decimal places. Answer is:
0.891
0.342
Ohh..I see Thanxx a lot! :-)