corr2 return 1 for different value
古いコメントを表示
why when i use corr2 for different value in matlab return result=1 although the tow matrix not similar like this:-
aa
aa =
137.5093 1.9847
>> bb
bb =
141.2252 3.3757
>> corr2(aa,bb)
ans =
1
回答 (1 件)
Ameer Hamza
2020 年 9 月 20 日
1 投票
If you use only 2D vectors with corr2(), it is always possible to draw a line connecting two points, so the correction coefficient is always 1 or -1. You can verify this by simplifying the formula: https://www.mathworks.com/help/releases/R2020a/images/ref/corr2.html#f1-227958 for the case when x and y are 2D vectors.
8 件のコメント
Walter Roberson
2020 年 9 月 20 日
syms A [1 2]; syms B [1 2];
sum((A-mean(A)).*(B-mean(B)))
sqrt(sum((A-mean(A)).^2).*sum((B-mean(B)).^2))
This gives
2*(A1/2 - A2/2)*(B1/2 - B2/2)
2*((A1/2 - A2/2)^2*(B1/2 - B2/2)^2)^(1/2)
and by inspection you can see that these are the same value provided that the quantities are real-valued.
khalida basheer
2020 年 9 月 20 日
Walter Roberson
2020 年 9 月 20 日
The implication would be that either you have an error in extracting the features, or else that the features you are extracting are not useful for your purposes.
khalida basheer
2020 年 9 月 20 日
Walter Roberson
2020 年 9 月 20 日
You need more than two features to use corr2()
khalida basheer
2020 年 9 月 20 日
Walter Roberson
2020 年 9 月 21 日
If you try something like
[H,p] = ttest2(aa,bb)
you will get a p > 0.9 -- that is, if you treat the numbers as being a random distribution, there is more than a 90% chance that they come from the same random distribution.
The large value of the second feature dilutes the variation in the other features. If you take the correlation with the second feature removed, you will get a notably lower score. Perhaps you should rescale the second feature.
khalida basheer
2020 年 9 月 21 日
カテゴリ
ヘルプ センター および File Exchange で Image Arithmetic についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!