Chebyshev: Chebyshev Numeric Comparator

View source: R/Chebyshev.R

ChebyshevR Documentation

Chebyshev Numeric Comparator

Description

The Chebyshev distance (a.k.a. L-Inf distance or ) between two vectors x and y is the greatest of the absolute differences between each coordinate:

Chebyshev(x, y) = max_i |x_i - y_i|.

Usage

Chebyshev()

Value

A Chebyshev instance is returned, which is an S4 class inheriting from NumericComparator.

Note

The Chebyshev distance is a limiting case of the Minkowski distance where p -> Inf.

See Also

Other numeric comparators include Manhattan, Euclidean and Minkowski.

Examples

## Distance between two vectors
x <- c(0, 1, 0, 1, 0)
y <- seq_len(5)
Chebyshev()(x, y)

## Distance between rows (elementwise) of two matrices
comparator <- Chebyshev()
x <- matrix(rnorm(25), nrow = 5)
y <- matrix(rnorm(5), nrow = 1)
elementwise(comparator, x, y)

## Distance between rows (pairwise) of two matrices
pairwise(comparator, x, y)


comparator documentation built on March 18, 2022, 6:15 p.m.