Learn R Programming

gridOT (version 1.0.2)

transport_costmat: Cost Matrix for two-dimensional Optimal Transport

Description

Calculate the cost matrix for the optimal transport between two-dimensional grids with respect to the cost function $$c(x, y) = | x_1 - y_1 |^{p_1} + | x_2 - y_2 |^{p_2}.$$

Usage

transport_costmat(x, ...)

# S3 method for otgrid transport_costmat(x, y, p.1 = 2, p.2 = p.1, ...)

# S3 method for otgridtransport transport_costmat(x, ...)

Value

a matrix giving the pairwise costs in column-mayor format.

Arguments

x

an object of class "otgridtransport" or "otgrid", in the latter case it gives the object the mass is to be transported from.

...

further arguments (currently unused).

y

an object of class "otgrid" the mass is to be transported from.

p.1

the first power \(\geq 1\) of the cost.

p.2

the second power \(\geq 1\) of the cost.

Examples

Run this code
x <- otgrid(cbind(0:1, 1:0))
y <- otgrid(cbind(1:0, 0:1))

transport_costmat(x, y, p.1 = 1, p.2 = 3)

Run the code above in your browser using DataLab