Apply kmatdist
to every pair of kanjimat
objects to compute
the unbalanced or balanced Wasserstein distance.
Usage
kmatdistmat(
klist,
klist2 = NULL,
p = 1,
C = 0.2,
type = c("unbalanced", "balanced")
)
Value
A matrix of dimension length(klist)
x length(klist2)
having
as its \((i,j)\)-th entry the distance between klist[[i]]
and
klist2[[j]]
. If klist2
is not provided it is assumed to be equal to
klist
, but the computation is more efficient as only the upper triangular part
is computed and then symmetrized with diagonal zero.
Examples
kmatdistmat(fivetrees1)
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 0.00000 84.16072 57.59337 44.14622 44.49426
#> [2,] 84.16072 0.00000 69.80940 75.60980 86.55121
#> [3,] 57.59337 69.80940 0.00000 39.16901 66.16746
#> [4,] 44.14622 75.60980 39.16901 0.00000 44.66810
#> [5,] 44.49426 86.55121 66.16746 44.66810 0.00000
kmatdistmat(fivetrees1, fivetrees1) # same result but slower
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 0.00000 84.16072 57.59337 44.14622 44.49426
#> [2,] 84.16072 0.00000 69.80940 75.60980 86.55121
#> [3,] 57.59337 69.80940 0.00000 39.16901 66.16746
#> [4,] 44.14622 75.60980 39.16901 0.00000 44.66810
#> [5,] 44.49426 86.55121 66.16746 44.66810 0.00000
kmatdistmat(fivetrees1, fivetrees2) # note the smaller values on the diagonal
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 59.79662 84.09319 72.24528 76.97499 75.05534
#> [2,] 106.92515 58.29519 82.81458 93.28782 107.15642
#> [3,] 90.64552 90.41827 65.10304 82.02497 92.14198
#> [4,] 78.74045 88.73563 76.48978 67.54018 74.64072
#> [5,] 73.54473 88.44780 76.12515 72.28624 57.70252