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 |
... |
further arguments (currently unused). |
y |
an object of class |
p.1 |
the first power |
p.2 |
the second power |
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]