Lotka-Volterra equations using R

可紊 提交于 2019-12-24 09:39:48

问题


How do I use ggplot to plot the predator species against the prey species?

These are the equations I'm using;

dX/dt = a1X - b1XY, X(0) = X0 #Prey  
dY/dt = a2XY - b2Y, Y(0) = Y0 #Predator

These are the values of my constants;

a1 = 1.247  
b1 = .384  
a2 = .123  
b2 = .699  
X0 = 5.415  
Y0 = 6.923  
K = 9.438

This piece of code below describes the right hand side of the equations, however I'm unsure if this is relevant to plotting the two species.

ydot.lv <- function(t,y,parms){
  ydot <- rep(NA,2)
  ydot[1] <- parms[1]*y[1] - parms[2]*y[1]*y[2]
  ydot[2] <- parms[3]*y[1]*y[2] - parms[4]*y[2]
  return(list(ydot))
}

来源:https://stackoverflow.com/questions/43861974/lotka-volterra-equations-using-r

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!