How to calculate probability from Negative Binomial distribution in R

We provide effective and economically affordable online training courses for R and Python, click here for more details and course registration !

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

For getting more knowledge of R and a preview of our training course, you can watch R tutorial videos on our YouTube channel !

wilsonzhang746

Recent Posts

Download R Course source files

Click here to download R Course source files !

2 months ago

Download Python Course source files

Click here to download Python Course Source Files !

2 months ago

How to create a data frame from nested dictionary with Pandas in Python

For online Python training registration, click here ! Pandas provides flexible ways of generating data…

5 months ago

How to delete columns of a data frame in Python

For online Python training registration, click here ! Data frame is the tabular data object…

5 months ago

Using isin() to check membership of a data frame in Python

Click her for course registration ! When a data frame in Python is created via…

5 months ago

How to assign values to Pandas data frame in Python

We provide affordable online training course(via ZOOM meeting) for Python and R programming at fundamental…

5 months ago