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

Fine tuning a Hugging Face transformer model for multi-track music generation

To train a PyTorch Transformer for multi-track music generation, the standard paradigm is to convert…

3 weeks ago

what are Transformer, LLM , and GPT

In the field of AI and Natural Language Processing (NLP), The Transformer is the engine…

3 weeks ago

Main framework for PyTorch music generation model

If your goal is purely symbolic melody generation (e.g., generating MIDI files or notes rather…

4 weeks ago

affine_grid() in pytorch

According to PyTorch document, In PyTorch, torch.nn.functional.affine_grid generates a 2D or 3D flow field (sampling…

3 months ago

How to create an Android mobile app with a deep learning AI model ?

Creating an Android mobile app with a deep learning AI model involves several key steps:…

12 months ago

Download source files for R Machine learning

Click here to go to source files for R Machine Learning

1 year ago