sp <- 10
msk <- make.mask(nx = 51, ny = 51, type = 'rect', spacing = sp,
buffer = 0)
k <- make.kernel('BVN', 20, spacing = sp, move.a = 50, clip = TRUE,
sparse = TRUE)
# initial distribution a central point
X <- apply(msk, 2, mean)
par(mfrow = c(1,4), mar = c(1,1,2,1))
for (step in 0:2) {
X <- cumMove(X, msk, k, nstep = min(step,1))
plot(X, cov = 'pm', dots = FALSE, legend = FALSE, breaks =
seq(0,0.006,0.0001))
mtext(side = 3, line = 0, paste('Step', step), cex = 0.9)
contour(
x = unique(X$x),
y = unique(X$y),
z = matrix(covariates(X)$pm, nrow = length(unique(X$x))),
levels = c(0.0002),
drawlabels = FALSE,
add = TRUE)
}
if (FALSE) {
# initial distribution across a polygon
X0 <- matrix(c(200,200,300,300,200,200,300,300,200,200), ncol = 2)
X <- X0
par(mfrow = c(1,4), mar = c(1,1,2,1))
for (step in 0:3) {
X <- cumMove(X, msk, k, nstep = min(step,1))
plot(X, cov = 'pm', dots = FALSE, legend = FALSE, breaks =
seq(0,0.006,0.0001))
mtext(side = 3, line = 0, paste('Step', step), cex = 0.9)
contour(
x = unique(X$x),
y = unique(X$y),
z = matrix(covariates(X)$pm, nrow = length(unique(X$x))),
levels = c(0.0002),
drawlabels = FALSE,
add = TRUE)
}
polygon(X0)
proportionInPolygon(X, X0)
}
Run the code above in your browser using DataLab