Skip to contents

Represent atoms as rows of a numeric matrix and keep within-measure masses separate from weights across distributions. Nonnegative masses are normalized with overflow protection; zero masses and duplicate rows retain their indices.

Usage

ot_measure(
  support,
  mass = NULL,
  representation = "empirical",
  metadata = list()
)

as_ot_measure(x, ...)

ot_collection(measures, weights = NULL, labels = names(measures))

Arguments

support

A finite numeric vector or matrix; rows are atoms.

mass

Nonnegative masses, or NULL for uniform masses.

representation

A descriptive representation label.

metadata

A named list describing units and conversion choices.

x

An object to convert, or an object to print/subset.

...

Further arguments passed to the finite-measure constructor.

measures

A nonempty list of finite measures or convertible inputs.

weights

Weights across measures; NULL means equal importance per measure.

labels

Optional unique labels for the measures.

Value

`ot_measure()` and `as_ot_measure()` return a `t4transport_measure`; `ot_collection()` returns a `t4transport_collection` with separately stored measures and outer weights.

Examples

mu <- ot_measure(c(0, 2), c(1, 3))
nu <- as_ot_measure(stats::ecdf(c(0, 0, 4)))
ot_collection(list(mu, nu), weights = c(2, 1))
#> Collection of 2 probability measures in 1 dimension(s)
#>     label outer_weight atoms
#>  measure1    0.6666667     2
#>  measure2    0.3333333     2