Normalize data before measuring the distance

5 ビュー (過去 30 日間)
KnowledgeSeeker
KnowledgeSeeker 2014 年 3 月 20 日
回答済み: Shashank Prasanna 2014 年 3 月 20 日
I am trying to measure the correlation between data (a row vector). I use euclidean distance to measure how correlated each feature to one another. I want to measure the distance of the first feature against the rest of the features. First I normalize my data:
normalizedData = x/sum(X)
second I use Euclidean distance to measure the distance of one feature to the rest of the features
mydata = {}
for Idx = 1:numel(normalizedData)
euclidean_distance = normalizedData(1) - normailizedData(Idx)
mydata{1,1} = euclidean_distance;
end
I am wondering if the above way is correct or incorrect? can someone suggest me or give me an opinion.
Thank you

回答 (1 件)

Shashank Prasanna
Shashank Prasanna 2014 年 3 月 20 日
You can use pdist2 to compute pairwise distances:
If you want to standardize the data before hand, you can use zscore:
But if you want to find correlation between to features you use corr
corr(X(:,1),X(:,2))

Community Treasure Hunt

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

Start Hunting!

Translated by