Arith-distributionH: Arithmetic operators for histograms

Arith-distributionHR Documentation

Arithmetic operators for histograms

Description

Sum, difference and product of distributionH objects and numbers, consistent with the L2 Wasserstein metric: the operations are applied to the quantile functions of the distributions.

  • e1 + e2: the sum of the quantile functions. A number is treated as an impulse distribution, so x + a shifts x by a.

  • e1 - e2: the difference of the quantile functions. The difference of two distributions is a distribution only if e1 is more variable than e2 (the result must be a non-decreasing quantile function); otherwise it may not be valid. x - a shifts x by -a.

  • a * x or x * a: the product of a distribution and a number, i.e. a rescaling of x.

Usage

## S4 method for signature 'distributionH,distributionH'
e1 + e2

## S4 method for signature 'distributionH,distributionH'
e1 - e2

## S4 method for signature 'distributionH,distributionH'
e1 * e2

Arguments

e1, e2

Two distributionH objects, or a distributionH and a number.

Value

A distributionH object.

Examples

d1 <- distributionH(x = c(1, 2, 3), p = c(0, 0.4, 1))
d2 <- distributionH(x = c(7, 8, 10, 15), p = c(0, 0.2, 0.7, 1))
d1 + d2
d2 + 10
2 * d1
d2 - d1

HistDAWass documentation built on Oct. 19, 2026, 1:06 a.m.