Created
December 10, 2012 17:55
-
-
Save aaronberdanier/4252132 to your computer and use it in GitHub Desktop.
Simulation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
time <- 100 | |
N <- Nhat <- dN <- K <- rep(NA,time) | |
P <- rlnorm(100,7,0.7) | |
r <- 0.05 | |
Kmax <- 500 | |
alpha <- mean(P) | |
N[1] <- 100 | |
Nhat[1] <- rpois(1,N[1]) | |
K[1] <- NA | |
for(t in 2:100){ | |
K[t] <- Kmax*P[t]/(alpha+P[t]) | |
dN[t] <- N[t-1]*r*(1-(N[t-1]/K[t])) | |
N[t] <- N[t-1]+dN[t] | |
Nhat[t] <- rpois(1,N[t]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment