Advertisement
jmbm

Fig_05

Jul 13th, 2023
538
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.90 KB | None | 0 0
  1. #---- Nicholson & Bailey
  2.  
  3. # variables
  4. N <- numeric()
  5. P <- numeric()
  6.  
  7. # coeficientes
  8. lambda <- 2.8
  9. c <- 1.5
  10. a <- 0.009
  11.  
  12. # condiciones simulación
  13. ngen <- 300      # generaciones
  14. N[1] <- 150     # N inicial
  15. P[1] <- 150     # P inicial
  16.  
  17. # simulación
  18. for (t in 1:ngen) {
  19.   f <- exp(-a * P[t])
  20.   N[t + 1] <- lambda * N[t] * f
  21.   P[t + 1] <- lambda * c * N[t] * a * P[t] * f
  22. }
  23.  
  24. # equilibrio
  25. Peq <- log(lambda) / a
  26. Neq <- 1 / (a *c)
  27.  
  28. # gráfico
  29. pdf("fig_05.pdf", width = 7.5, height = 6)
  30. par(pty = "s",
  31.     bty = "n",
  32.     mar = c(5, 2, 1, 1),
  33.     xaxs = "i",
  34.     yaxs = "i",
  35.     las = 1)
  36. plot(N, P,
  37.     type = "l",
  38.     lty = 2,
  39.     col = "lightblue",
  40.     xlim = c(0, 200),
  41.     ylim = c(0, 300))
  42. points(N, P,
  43.     cex = 0.8,
  44.     pch = 16,
  45.     col = "royalblue")
  46. abline(h = Peq,
  47.     col = "orange",
  48.     lwd = 0.5)
  49. abline(v = Neq,
  50.     col = "orange",
  51.     lwd = 0.5)
  52. dev.off()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement