What's an easy way to find the Euclidean distance between two n-dimensional vectors in Julia?
The Euclidean distance between 2 cells would be the simple arithmetic difference: xcell1 - xcell2 (eg. APHWcell1 = 1.11603 ms and APHWcell10 = 0.97034 ms; they are (1.11603 - 0.97034) = 0.14569 ms apart).
Euclidean distance is calculated as the square root of the sum of the squared differences between the two vectors.
The Euclidean distance between two points in either the plane or 3-dimensional space measures the length of a segment connecting the two points. It is the most obvious way of representing distance between two points.
Here is a simple way
n = 10
x = rand(n)
y = rand(n)
d = norm(x-y) # The euclidean (L2) distance
For Manhattan/taxicab/L1 distance, use norm(x-y,1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With