Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Compute Randomly Drawn Negative Binomial Density in R Programming – rnbinom() Function

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

rnbinom() function in R Language is used to compute random density for negative binomial distribution.
 

Syntax: rnbinom(N, size, prob)
Parameters: 
N: Sample Size 
size: Number of trials 
prob: Probability 
 

Example 1: 
 

Python3




# R program to compute random
# Negative Binomial Density
 
# Setting seed for
# random number generation
set.seed(1000)
 
# Set sample size
N <- 20
 
# Calling rnbinom() Function
y <- rnbinom(N, size = 10, prob = 0.5)
y

Output: 
 

 [1]  9 12  8  4 10  3  9 19  3 14 11 11  6 15 14 12  6  5  5  4

Example 2: 
 

Python3




# R program to compute random
# Negative Binomial Density
 
# Setting seed for
# random number generation
set.seed(1000)
 
# Set sample size
N <- 100
 
# Calling rnbinom() Function
y <- rnbinom(N, size = 50, prob = 0.5)
 
# Plot a graph
plot(y)

Output: 
 

 

My Personal Notes arrow_drop_up
Last Updated : 15 Mar, 2021
Like Article
Save Article
Similar Reads