Related Articles

Related Articles

Compute the Negative Binomial Density in R Programming – dnbinom() Function
  • Last Updated : 25 Jun, 2020

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:

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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

chevron_right


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:

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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)

chevron_right


Output:

My Personal Notes arrow_drop_up
Recommended Articles
Page :