Negative binomial distribution is used to model the particular probability of k-th success occurring at x-th Bernoulli trial, which is equivalent to say that it has experienced x-1 trial and the last trial is a success. A Bernoulli trial is a trial with binary result, success and failure, with a constant success rate in each trial. Function dnbinom(x = f, size = r, prob = p) in R can be used to calculate the probability of such circumstance, where
x here is for how many failure occurs, namely x-k;
size is for how many success occur, namely k;
and prob is for constant probability in each trial.
Next example shows the probability of shooting 10 times in which 3 times hitting the target, and the last shooting is a success too. And the long run of hitting rate is 0.1 for each shooting.
#3 times hitting and last shooting also hitting
r = 3
#probability of long run , hitting rate
p = 0.10
#times of not hitting target
n = 10 - r
# probability of negative binomial
dnbinom(x = n, size = r, prob = p)
#result
0.01721869
Click here to download Python Course Source Files !
For online Python training registration, click here ! Pandas provides flexible ways of generating data…
For online Python training registration, click here ! Data frame is the tabular data object…
Click her for course registration ! When a data frame in Python is created via…
We provide affordable online training course(via ZOOM meeting) for Python and R programming at fundamental…