0

This plot shows multiple Poisson distributions for lambda = 1:10):

I tried running the code for Poisson and tried tweaking it to get plots for NB and generalized Poisson distributions but nothing worked.

zephryl
  • 14,633
  • 3
  • 11
  • 30

1 Answers1

0

You can consider the following approach :

x_val <- 1 : 10
y_val <- dnbinom(x = x_val, size = 4, prob = 0.99)
plot(x_val, y_val, type = "l")

for(i in 1 : 10)
{
  x_val <- 1 : 10
  y_val <- dnbinom(x = x_val, size = 4, prob = 0.99 ^ (i + 1))
  lines(x_val, y_val, type = "l", col = i)
}

Emmanuel Hamel
  • 1,769
  • 7
  • 19
  • the graph im trying to draw has to be something similar to the one for poisson distribution – Katlego Motsatsing Apr 11 '23 at 13:43
  • It is not clear for me what you are trying to achieve. Maybe you could give more information to help us. – Emmanuel Hamel Apr 11 '23 at 14:20
  • I was trying to show a graphical representation of a negative binomial distributions in one plot such as th one for poisson distribution shown in the picture when the PMF is defined as: P(Y = y) = Γ(y + 1/γ)/[Γ(y + 1)Γ(1/γ)]( 1/(1 + γμ))^1/γ ( γμ/(1 + γμ))^y and letting y = 1, 2, 3, ..., 30, 1/γ = 1, 2, .., 10 and ρ = 0.5 – Katlego Motsatsing Apr 11 '23 at 15:22