The Wayback Machine - https://web.archive.org/web/20240905225141/https://www.geeksforgeeks.org/compute-the-negative-binomial-density-in-r-programming-dnbinom-function/
Open In App

Compute the Negative Binomial Density in R Programming – dnbinom() Function

Last Updated : 25 Jun, 2020
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

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-values
x <- seq(0, 10, by = 1)
  
# Calling dnbinom() Function
y <- dnbinom(x, size = 10, prob = 0.5)
y


Output:

 [1] 0.0009765625 0.0048828125 0.0134277344 0.0268554688 0.0436401367
 [6] 0.0610961914 0.0763702393 0.0872802734 0.0927352905 0.0927352905
[11] 0.0880985260

Example 2:




# R program to compute
# Negative Binomial Density
  
# Vector of x-values
x <- seq(0, 100, by = 1)
  
# Calling dnbinom() Function
y <- dnbinom(x, size = 10, prob = 0.5)
  
# Plot a graph
plot(y)


Output:



Similar Reads

Compute the Negative Binomial Cumulative Density in R Programming - pnbinom() Function
pnbinom() function in R Language is used to compute the value of negative binomial cumulative density. It also creates a density plot of the negative binomial cumulative distribution. Syntax: pnbinom(vec, size, prob) Parameters: vec: x-values for binomial density size: Number of trials prob: Probability Example 1: # R program to compute # Negative
1 min read
Compute Randomly Drawn Negative Binomial Density in R Programming - rnbinom() Function
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: C/C++ Code # R program to compute random # Negative Binomial Density # Setting seed for # random number generation set.seed(1000) # Set sa
1 min read
Compute the Value of Negative Binomial Quantile Function in R Programming - qnbinom() Function
qnbinom() function in R Language is used to compute the value of negative binomial quantile function. It also creates a density plot of the negative binomial quantile function. Syntax: qnbinom(vec, size, prob) Parameters: vec: x-values for binomial density size: Number of trials prob: Probability Example 1: # R program to compute value of # Negativ
1 min read
Getting Kernel Density Estimates in R Programming - density() Function
density() function in R Language is used to compute kernel density estimates. Syntax: density(x) Parameters: x: number vector Example 1: # R program to illustrate # density function # Generating 10 numbers randomly x &lt;- stats::rnorm(10) # Getting 10 random number x # Calling density() function d &lt;- density(x) # Getting kernel density estimate
1 min read
Compute Density of the Distribution Function in R Programming - dunif() Function
dunif() function in R Language is used to provide the density of the distribution function. Syntax: dunif(x, min = 0, max = 1, log = FALSE) Parameters: x: represents vector min, max: represents lower and upper limits of the distribution log: represents logical value for probabilities Example 1: # Create vector of random deviation u &lt;- runif(20)
1 min read
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 Chi Square Density in R Programming - dchisq() Function
dchisq() function in R Language is used to compute chi square density for a vector of elements. It also creates a density plot for chi square distribution. Syntax: dchisq(vec, df) Parameters: vec: Vector of x-values df: Degree of Freedom Example 1: # R program to compute # Chi Square Density # Create a vector of x-values x &lt;- seq(0, 10, by = 1)
1 min read
Compute Cumulative Chi Square Density in R Programming - pchisq() Function
pchisq() function in R Language is used to compute cumulative chi square density for a vector of elements. It also creates a density plot for chi square cumulative distribution. Syntax: pchisq(vec, df) Parameters: vec: Vector of x-values df: Degree of Freedom Example 1: # R program to compute # Cumulative Chi Square Density # Create a vector of x-v
1 min read
Compute Cauchy Density in R Programming - dcauchy() Function
dcauchy() function in R Language is used to calculate the cauchy density. It also creates a density plot of cauchy distribution. Syntax: dcauchy(vec, scale) Parameters: vec: x-values for cauchy function scale: Scale for plotting Example 1: # R Program to compute cauchy density # Creating vector for x-values x &lt;- seq(1, 10, by = 1) # Apply dcauch
1 min read
Compute Cumulative Cauchy Density in R Programming - pcauchy() Function
pcauchy() function in R Language is used to calculate the cumulative cauchy density. It also creates a density plot of cauchy cumulative distribution. Syntax: pcauchy(vec, scale) Parameters: vec: x-values for cauchy function scale: Scale for plotting Example 1: # R Program to compute cumulative cauchy density # Creating vector for x-values x &lt;-
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 Cumulative Logistic Density in R Programming - plogis() Function
plogis() function in R Language is used to compute logistic cumulative density of the distribution. It also creates a plot of the density of the logistic cumulative distribution. Syntax: plogis(vec) Parameters: vec: Vector of x-values for density Example 1: # R program to calculate # cumulative logistic density # Create a vector of x-values x &lt;-
1 min read
Compute the Logistic Density in R Programming - dlogis() Function
dlogis() function in R Language is used to compute logistic density of the distribution. It also creates a plot of the density of the logistic distribution. Syntax: dlogis(vec) Parameters: vec: Vector of x-values for density Example 1: # R program to calculate # logistic density # Create a vector of x-values x &lt;- seq(-1, 1, by = 0.1) # Calling t
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 Cumulative Log Normal Probability Density in R Programming - plnorm() Function
plnorm() function in R Language is used to compute the log normal value of the cumulative probability density function. It also creates a plot of the cumulative distribution of log normal density. Syntax: plnorm(vec) Parameters: vec: x-values for normal density Example 1: # R program to compute cumulative # log normal probability density # Creating
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 value of Quantile Chi Square Density in R Programming - qchisq() Function
qchisq() function in R Language is used to compute value of chi square quantile function. It creates a quantile function plot for chi square distribution. Syntax: qchisq(vec, df) Parameters: vec: Vector of x-values df: Degree of Freedom Example 1: # R program to compute # Quantile Chi Square density # Create a vector of x-values x &lt;- seq(0, 1, b
1 min read
Compute Log Normal Probability Density in R Programming - dlnorm() Function
dlnorm() function in R Language is used to compute the log normal value of the probability density function. It also creates a plot of the log normal density. Syntax: dlnorm(vec) Parameters: vec: x-values for normal density Example 1: # R program to compute # log normal probability density # Creating x-values for density x &lt;- seq(1, 10, by = 1)
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 the Value of Poisson Density in R Programming - dpois() Function
dpois() function in R Language is used to compute the Poisson Density for a set of Integer values. It also creates a density plot of poisson distribution. Syntax: dpois(vec, lambda)Parameters: vec: Sequence of integer values lambda: Average number of events per interval Example 1: C/C++ Code # R program to compute # Poisson Density # Sequence of x-
1 min read
Compute the Cumulative Poisson Density in R Programming - ppois() Function
ppois() function in R Language is used to compute the cumulative density function for Poisson distribution. Syntax: ppois(vec, lambda) Parameters: vec: Sequence of integer values lambda: Average number of events per interval Example 1: # R program to compute # Cumulative Poisson Density # Sequence of x-values x &lt;- seq(-10, 10, by = 1) # Calling
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 the Value of F Density in R Programming - df() Function
df() function in R Language is used to compute the density of F Distribution over a sequence of numeric values. It also plots a density graph for F Distribution. Syntax: df(x, df1, df2) Parameters: x: Numeric Vector df: Degree of Freedom Example 1: # R Program to compute # F Density # Creating a sequence of x-values x &lt;- seq(1, 30, by = 2) # Cal
1 min read
Compute the Value of Weibull Density in R Programming - dweibull() Function
dweibull() function in R Language is used to compute the value of Weibull Density over different numeric values for Weibull Distribution. Syntax: dweibull(x, shape) Parameters: x: Numeric Vector shape: Shape Parameter Example 1: # R Program to compute # Weibull Density # Creating a sequence of x-values x &lt;- seq(-10, 10, by = 1) # Calling dweibul
1 min read
Compute the Value of Cumulative Weibull Density in R Programming - pweibull() Function
pweibull() function in R Language is used to compute the value of Cumulative Distribution Function for Weibull Distribution. It also plots a density graph for Cumulative Weibull Function. Syntax: pweibull(x, shape) Parameters: x: Numeric Vector shape: Shape Parameter Example 1: # R Program to compute # Cumulative Weibull Density # Creating a sequen
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 gamma value of a Non-negative Numeric Vector in R Programming - gamma() Function
gamma() function in R Language is used to compute the gamma value of a numeric vector using the gamma function. Gamma function is basically, gamma(x) = factorial(x - 1) Syntax: gamma(x) Parameters: x: Non-negative Numeric Vector Example 1: # R program to calculate the gamma value # Calling gamma Function gamma(2) gamma(3) gamma(5) Output: [1] 1 [1]
1 min read
Compute the beta value of Non-Negative Numeric Vectors in R Programming - beta() Function
beta() function in R Language is used to return the beta value computed using the beta function. The beta function is also known as Euler's integral of the first kind. Syntax: beta(a, b) Parameters: a, b: non-negative numeric vectors Example 1: # R program to illustrate # beta function # Calling the beta() function beta(1, 2) beta(2, 2) beta(3, 5)
1 min read
Article Tags :