[R-sig-dyn-mod] Modeling dampened oscillator with random resets
Felix Schönbrodt
gmx at nicebread.de
Wed Jan 9 15:33:20 CET 2013
Dear list,
using deSolve (or another package): is it possible to model a dampened oscillator that is reset to new states at specific points?
Background: I want to model a system that tries to approach equilibrium, but is disturbed at single events. It would roughly look like following screenshot:
https://dl.dropbox.com/u/4472780/WP/oscReset.PNG
In this screen shot, events at t=70 and t=120 disturb the oscillator. In this screen shot I simply pasted together 3 independent plots; but if the disturbance is directly modeled it should somehow be reflected in the dx etc. (e.g., at the second event I would expect that the curve first continues going up before it is regulated down again).
Here's my function for the dampened oscillator:
library("deSolve")
osci <- function (t, states, parms) {
with(as.list(c(states, parms)), {
dx <- y
dy <- eta * x + zeta * y
list(c(dx, dy))
})
}
states <- c(x=1, y=0)
out <- data.frame(ode(states, osci, times = 1:100, parms = c(eta = -0.05, zeta = -0.02)))
plot(out)
Best,
Felix
More information about the R-sig-dynamic-models
mailing list