CensusMapper's wasserstein(): the p-Wasserstein distance between two
samples of the same size for each region, using
transport::wasserstein1d(). Needs the transport package.
Arguments
- a, b
The samples: matrices with one row per region, e.g.
cbind(v1, v2, v3)insidedplyr::mutate(), or vectors that are the same for every region.- p
The order of the distance, the same for every region or one per region.
Examples
if (requireNamespace("transport", quietly = TRUE)) {
cm_wasserstein(cbind(c(1, 2), c(3, 4)), c(2, 2))
}
#> [1] 1 1
