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

Respuestas (1)

Ameer Hamza
Ameer Hamza el 20 de Sept. de 2020

1 voto

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 comentarios

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
khalida basheer el 20 de Sept. de 2020
Sir, thanks for the answer
Can you help me
I used the correlation coefficient for the purpose of matching in a system for identifying people
And I used the moments as features for the images
When I extract the person’s features and compare them by corr2 with the stored database, the result is completely identical to all people, or at least 99% identical, which is incorrect.
So in theory and without calculation, the features are different from one person to another
But I could not find a solution to this problem ???
Walter Roberson
Walter Roberson el 20 de Sept. de 2020
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
khalida basheer el 20 de Sept. de 2020
Sir, when we look at the features they look similar to the pictures of the same person and at the same time different to everyone else
But when the correlation coefficient is found, the result is one, ( similarity of 100%).
For example in above example, aa it is the first two features of a person aa
And bb is the first two features of a person bb
In theory, they are different, but their correlation coefficient is 1
Walter Roberson
Walter Roberson el 20 de Sept. de 2020
You need more than two features to use corr2()
khalida basheer
khalida basheer el 20 de Sept. de 2020
Sir, I used 7 features and you can see this example
These two feature vectors belong to two different people. You can see the result
Can you suggest me another method of matching that gives better results please?
K>> aa
aa = 2.4609 141.3396 3.7583 1.1016 0.3980 1.0616 0.1026
K>> bb
bb = 2.8913 165.9664 2.2820 2.2066 0.9156 0.4908 0.8817
K>> corr2(aa,bb)
ans =
0.9997
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
khalida basheer el 21 de Sept. de 2020
Sir Walter Roberson, actually the problem is the second feature, after deleting it and relying on other features, I got the acceptable result
thank you very much

Iniciar sesión para comentar.

Etiquetas

Preguntada:

el 20 de Sept. de 2020

Comentada:

el 21 de Sept. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by