transport_costmat {gridOT}R Documentation

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 class 'otgrid'
transport_costmat(x, y, p.1 = 2, p.2 = p.1, ...)

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

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.

Value

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

Examples

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

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

[Package gridOT version 1.0.1 Index]