In this challenge, we learn about geometric distributions. Check out the Tutorial tab for learning materials!
The probability that a machine produces a defective product is . What is the probability that the defect is found during the inspection?
The first line contains the respective space-separated numerator and denominator for the probability of a defect, and the second line contains the inspection we want the probability of being the first defect for:
1 3
5
If you do not wish to read this information from stdin, you can hard-code it into your program.
Print a single line denoting the answer, rounded to a scale of decimal places (i.e., format).
In [1]:
def neg_bernoulli(n, p):
return p * (1-p)**(n-1)
In [12]:
defective_prob = 1 / 3.0
inspection = 5
In [14]:
round(neg_bernoulli(inspection, defective_prob), 3)
Out[14]:
In [16]:
neg_bernoulli(12/100.0, 100)
Out[16]:
In [ ]: