Learn R Programming

gor (version 2.0)

compute_p_distance: Distance-p between two-dimensional points

Description

It computes the distance-\(p\) between two-dimensional points.

Usage

compute_p_distance(x, y, p = 2)

Value

The distance-\(p\) between points \(x\) and \(y\).

Arguments

x

A two-dimensional point

y

A two-dimensional point

p

The \(p\)-parameter of the distance-\(p\)

Author

Cesar Asensio

Details

The distance-\(p\) is defined by $$d_p(x,y) = \left(\sum_i (x_i-y_i)^p\right)^{\frac{1}{p}}$$.

See Also

compute_distance_matrix computes the distance matrix of a set of two-dimensional points, compute_tour_distance computes tour distances.

Examples

Run this code
compute_p_distance(c(1,2),c(3,4))      # 2.8284
compute_p_distance(c(1,2),c(3,4),p=1)  # 4

Run the code above in your browser using DataLab