There are n runs and x is a probability of minimum one occurrence of a event in n runs
There is one problem to implement in a module at which i m stuck . There are n runs and x is a probability of minimum one occurrence of a event in n 开发者_运维问答runs. How do i implement it in a program. Can anyone help me out with it.
look at binomial distribution of parameter n qnd p :
http://en.wikipedia.org/wiki/Binomial_distribution
and you're looking for P(X>=1) = 1 - P(X=0)
each event is a Bernoulli trial .
i.e the probability of each event to occure is p, and you're doing n trials.
Therefore according to the wikipedia articles:
x=1-(1-p)^n
in python for example:
def B1(n,p):
return 1-(1-p)**n
where p is the proba of one event to happen and n the number of trials
hope it helps
精彩评论