Dist_mat_latt: Lattice population distribution (with buddy).

Description Usage Arguments Value Examples

View source: R/Dist_mat_latt.R

Description

This function generates a distance matrix for individuals on a lattice, across a specified rectangular plane. There is also the option to generate a "buddy" for each individual.

Usage

1
Dist_mat_latt(N, nrow, xlim = 20, ylim = 20, buddy = TRUE)

Arguments

N

The total number of individuals in the population.

nrow

The number of rows of the lattice. N must be divisible by nrow.

xlim

The width of the plane on which individuals will be generated (defaults to 20 units wide).

ylim

The height of the place on which individuals will be generated (defaults to 20 units high).

buddy

Dicatates whether to generate a "buddy" for each point, generated from an isotropic distribution around each point with variance (xlim/200, ylim/200).

Value

The function returns a list. The first object in the list is a Nx2 matrix of the coordinates of the individuals. The second object is an NxN distance matrix.

Examples

1
2
3
xy.coords <- Dist_mat_latt(N = 200, nrow = 10, xlim = 20, ylim = 20, buddy = TRUE)[[1]]
distance_mat <- Dist_mat_latt(N = 200, nrow = 10, xlim = 20, ylim = 20, buddy = TRUE)[[2]]
plot(xy.coords[,1], xy.coords[,2], type  = "p")

BenjamenSimon/EpidemicR documentation built on March 23, 2020, 11:03 p.m.