Skip to content

Instantly share code, notes, and snippets.

@gufodotto
Created July 8, 2012 00:57
Show Gist options
  • Save gufodotto/3068827 to your computer and use it in GitHub Desktop.
Save gufodotto/3068827 to your computer and use it in GitHub Desktop.
Lorentz_short
library(deSolve) # require this library
solveLorenz <- function(pars, times=seq(0,100,by=0.1)) {
derivs <- function(t, state, pars) { # returns rate of change
with(as.list(c(state, pars)), {
dX <- a*X + Y*Z
dY <- b * (Y-Z)
dZ <- -X*Y + c*Y - Z
return(list(c(dX, dY, dZ)))
}
)
}
state <- c(X = 1, Y = 1, Z = 1)
## ode solves the model by integration...
return(ode(y = state, times = times, func = derivs, parms = pars))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment