Open In App

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

Last Updated : 15 Mar, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

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: 
 

 


Similar Reads

Compute Randomly Drawn F Density in R Programming - rf() Function
rf() function in R Language is used to compute random density for F Distribution. Syntax: rf(N, df1, df2) Parameters: N: Sample Size df: Degree of Freedom Example 1: # R Program to compute random values # of F Density # Setting seed for # random number generation set.seed(1000) # Set sample size N &lt;- 20 # Calling rf() Function y &lt;- rf(N, df1
1 min read
Compute Randomly Drawn Chi Square Density in R Programming - rchisq() Function
rchisq() function in R Language is used to compute random chi square density for a set of values. Syntax: rchisq(N, df) Parameters: N: Sample Size df: Degree of Freedom Example 1: # R program to generate # random chi square density points # Setting seed for # random number generation set.seed(1000) # Set sample size N &lt;- 20 # Calling rchisq() Fu
1 min read
Compute Randomly Drawn Log Normal Density in R Programming - rlnorm() Function
rlnorm() function in R Language is used to compute random log normal density among a range of inputs. Syntax: rlnorm(N) Parameters: N: Sample Size Example 1: # R program to generate # random log normal density points # Setting seed for # random number generation set.seed(1000) # Set sample size N &lt;- 20 # Calling rlnorm() Function y &lt;- rlnorm(
1 min read
Compute Randomly Drawn Cauchy Density in R Programming - rcauchy() Function
rcauchy() function in R Language is used to compute random cauchy density among a range of inputs. Syntax: rcauchy(N, scale) Parameters: N: Sample Size scale: Scale to plot graph Example 1: # R program to generate # random cauchy density points # Setting seed for # random number generation set.seed(1000) # Set sample size N &lt;- 20 # Calling rcauc
1 min read
Compute Randomly Drawn Logistic Density in R Programming - rlogis() Function
rlogis() function in R Language is used to compute random logistic density among a range of inputs. Syntax: rlogis(N) Parameters: N: Sample Size Example 1: # R program to generate # random logistic density points # Setting seed for # random number generation set.seed(1000) # Set sample size N &lt;- 20 # Calling rlogis() Function y &lt;- rlogis(N) y
1 min read
Compute Randomly Drawn Poisson Density in R Programming - rpois() Function
rpois() function in R Language is used to compute random density for poisson distribution. Syntax: rpois(N, lambda) Parameters: N: Sample Size lambda: Average number of events per interval Example 1: # R program to compute random # Poisson Density # Setting seed for # random number generation set.seed(1000) # Set sample size N &lt;- 20 # Calling rp
1 min read
Compute Randomly Drawn Weibull Density in R Programming - rweibull() Function
rweibull() function in R Language is used to compute random density for Weibull distribution. Syntax: rweibull(N, shape) Parameters: N: Sample Size shape: Shape Parameter Example 1: # R program to compute random # Weibull Density # Setting seed for # random number generation set.seed(1000) # Set sample size N &lt;- 20 # Calling rweibull() Function
1 min read
Compute Randomly Drawn Wilcoxon Signedrank Density in R Programming - rsignrank() Function
rsignrank() function in R Language is used to compute random density for Wilcoxon Signedrank Statistic Distribution over a sequence of random Numeric values. Syntax: rsignrank(N, n) Parameters: N: Size of Random Vector n: Sample Size Example 1: # R Program to compute random # Wilcoxon Signedrank Density # Setting seed for # random number generation
1 min read
Compute Randomly Drawn Wilcoxon Rank Sum Density in R Programming - rwilcox() Function
rwilcox() function in R Language is used to compute random density for Wilcoxon Rank Sum Statistic Distribution over a sequence of random Numeric values. Syntax: rwilcox(N, m, n) Parameters: N: Size of Random Vector m: Larger sample size n: Smaller sample size Example 1: # R Program to compute random # Wilcoxonrank Sum Density # Setting seed for #
1 min read
Compute the Negative Binomial Density in R Programming - dnbinom() Function
dnbinom() function in R Language is used to compute the value of negative binomial density. It also creates a plot of the negative binomial density. Syntax: dnbinom(vec, size, prob) Parameters: vec: x-values for binomial density size: Number of trials prob: Probability Example 1: # R program to compute # Negative Binomial Density # Vector of x-valu
1 min read
Article Tags :