distance {neighbr} | R Documentation |
Calculate the distance between two vectors.
Description
Calculate the distance between two vectors.
Usage
distance(x, y, measure)
Arguments
x , y |
Numeric vectors. |
measure |
Distance measure ("euclidean" or "squared_euclidean"). |
Details
Distance measures in this package are based on those defined
in the PMML specification.
Distances are calculated using the following equations:
Euclidean: (\sum((x_i - y_i)^2))^0.5
Squared euclidean: \sum((x_i - y_i)^2)
The input vectors must be of the same length.
Value
The distance between x
and y
.
See Also
similarity
,
PMML comparison measures
Examples
distance(c(-0.5,1),c(0.4,1.6),"euclidean")
distance(c(-0.5,1),c(0.4,1.6),"squared_euclidean")
[Package neighbr version 1.0.3 Index]