How to calculate normalized euclidean distance on two vectors?
9 ビュー (過去 30 日間)
古いコメントを表示
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?
0 件のコメント
採用された回答
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))
その他の回答 (0 件)
参考
カテゴリ
Help Center および File 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!