How to calculate normalized euclidean distance on two vectors?

조회 수: 8 (최근 30일)
Sepp
Sepp 2016년 7월 3일
댓글: Sepp 2016년 7월 3일
Hello
Let's say I have the following two vectors:
x = [(10-1).*rand(7,1) + 1; randi(10,1,1)]; y = [(10-1).*rand(7,1) + 1; randi(10,1,1)];
The first seven elements are continuous values in the range [1,10]. The last element is an integer in the range [1,10].
Now I would like to compute the euclidean distance between x and y. I think the integer element is a problem because all other elements can get very close but the integer element has always spacings of ones. So there is a bias towards the integer element.
How can I calculate something like a normalized euclidean distance on it?

채택된 답변

Andrei Bobrov
Andrei Bobrov 2016년 7월 3일
편집: Andrei Bobrov 2016년 7월 3일
out = sqrt(sum((x-y).^2)/numel(x))
or
out = norm(x-y)/sqrt(numel(x))
  댓글 수: 1
Sepp
Sepp 2016년 7월 3일
Thank you for your answer. Do you know if there is really a bias in my example if I would take just the normal Euclidean distance?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Statistics and Machine Learning Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by