dispersal {metaRange} | R Documentation |
Dispersal process
Description
Disperse a (abundance) matrix using a dispersal kernel and optional weights.
Usage
dispersal(dispersal_kernel, abundance, weights)
Arguments
dispersal_kernel |
|
abundance |
|
weights |
|
Details
The abundance matrix is dispersed using the dispersal kernel. If a matrix of weights is supplied, the individuals will redistribute within the dispersal kernel according to the weights. I.e. individuals will more likely move towards areas with a higher weight, if they are within their dispersal distance. Note:
the abundance is modified in place, to optimize performance.
Any
NA
orNaN
in abundance or weights will be (in-place) replaced by0
.
Value
<numeric matrix>
Dispersed abundance matrix.
Examples
n <- 10
n2 <- n^2
abu <- matrix(1:n2, nrow = n, ncol = n)
suitab <- matrix(1, nrow = n, ncol = n)
kernel <- calculate_dispersal_kernel(
max_dispersal_dist = 4,
kfun = negative_exponential_function,
mean_dispersal_dist = 1.2
)
res1 <- dispersal(
dispersal_kernel = kernel,
abundance = abu
)
res2 <- dispersal(
dispersal_kernel = kernel,
abundance = abu,
weights = suitab
)
stopifnot(sum(res1) - sum(res2) < 0.01)
# Note that the abundance is modified in place, i.e:
stopifnot(sum(abu - res2) < 0.01)