as.transport.plan {approxOT}R Documentation

Transform transportation matrix to transportation plan

Description

Transform transportation matrix to transportation plan

Usage

as.transport.plan(transport_matrix, ...)

Arguments

transport_matrix

A matrix that is a transportation matrix, i.e. the minimal joint distribution for two samples.

...

Unused arguments

Value

An object of class 'transport.plan'. See output of (transport_plan)[transport_plan]

Examples

set.seed(203987)
n <- 5
d <- 2
x <- matrix(stats::rnorm(d*n), nrow=d, ncol=n)
y <- matrix(stats::rnorm(d*n), nrow=d, ncol=n)
#get hilbert sort orders for x in backwards way
trans_plan <- transport_plan(X=x, Y=x, ground_p = 2, p = 2, 
                         observation.orientation =  "colwise", 
                         method = "hilbert")
trans_matrix <- as.matrix(trans_plan$tplan)
tplan2 <- as.transport.plan(trans_matrix)
all.equal(tplan2, trans_plan$tplan)

[Package approxOT version 1.1.1 Index]