Description Usage Arguments Details Examples
Function generates random walk (demographic noise) based on a normal distribution (ND) or uniform distribution (UD).
1 2 |
par |
numeric vector or R object. |
hs |
numeric, half saturation parameter, Default: 0.1 |
mv |
numeric, mean when op = "ND", Default: 0 |
sd |
numeric, standard deviation when op = "ND", Default: 0.1 |
min |
numeric, minimum value when op = "UD", Default: -0.2 |
max |
numeric, maximum value when op = "UD", Default: 0.2 |
op |
character, either 'ND' (normal distribution) or 'UD' (uniform distribution), Default: 'ND' |
Is used to add demograhic noise (random walk) to e.g. the population's vertical distribution. Further details in rnorm() and runif().
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ## Not run:
#Example shows difference between options (op)
#Variables (hs, mv, sd, min, max) are set to default (see description above)
rw <- data.frame()
set.seed(123)
for(i in 1:100){
rw[i,1] <- RWalk(0)
rw[i,2] <- RWalk(0, op = "UD")
if(i == 100){colnames(rw) <- c("Normally distributed random walk", "Uniformly distributed random walk")
par(mfrow = c(2, 2))
plot(rw[,1], type = "l", main = colnames(rw)[1], ylab = "Random walk", xlab = "", ylim = c(-0.4, 0.4))
plot(rw[,2], type = "l", main = colnames(rw)[2], ylab = "", xlab = "", ylim = c(-0.4, 0.4))
hist(rw[,1], breaks = 100, main = "", xlab = "", xlim = c(-0.4, 0.4), ylim = c(0, 14))
lines(density(rw[,1], adjust=2), lwd = 2)
hist(rw[,2], breaks = 100, main = "", ylab = "", xlab = "", xlim = c(-0.4, 0.4), ylim = c(0, 14))
lines(density(rw[,2], adjust=2), lwd = 2)
}
}
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.