calculate_dispersal_kernel {metaRange}R Documentation

Calculate 2D dispersal kernel.

Description

Use a user defined function to create a 2D dispersal kernel.

Usage

calculate_dispersal_kernel(max_dispersal_dist, kfun, normalize = TRUE, ...)

Arguments

max_dispersal_dist

⁠<numeric>⁠ maximum dispersal distance.

kfun

⁠<function>⁠ the kernel function to use. Can be user-defined, in which case it needs to vectorized and accept (at least) the parameter "x" representing the distance from the source as its input and return a vector of the same size as max_dispersal_dist.

normalize

⁠<boolean>⁠ whether to normalize the kernel.

...

additional parameters to be passed to the kernel function.

Value

Dispersal kernel with probabilities.

Examples

# a very simple uniform kernel
uniform_kernel <- calculate_dispersal_kernel(
    max_dispersal_dist = 3,
    kfun = function(x) {
        x * 0 + 1
    }
)
# same as
stopifnot(
    uniform_kernel == matrix(1 / 49, nrow = 7, ncol = 7)
)

# now a negative exponential kernel
# not that `mean_dispersal_dist`
# is passed to the kernel function.
calculate_dispersal_kernel(
    max_dispersal_dist = 3,
    kfun = negative_exponential_function,
    mean_dispersal_dist = 1
)

[Package metaRange version 1.1.4 Index]