Advertisement
jmbm

Fig_04

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