Express the sum of squares as a percentage of how well two signals match?
6 views (last 30 days)
Show older comments
So I am using matlab to compare two signals using the sum of squares. So I assume the best possible match will be zero. eg ∑(y2−y1)^2 where y2=y1 would be 0. The larger the sum of squared value the worse the match. So I d like to see how good one signal compares to the other in terms of percentage. So I figured that if i define a baseline value as the worst match this can act as a reference. eg if the best sum of squared value was 0 and the worst was 10 then 5 would be matched 50%. So what i m doing here is subtracting the worst value from the actual value and express this as a fraction. eg a sum of squared value of 1 is good because its closer to 0 so 10−1=9⋯(9/10)×100=90%. So, where the sum of square value is defined as ∑(y2−y1)^2, the baseline (worst case) would be ∑(y2−0)^2. Is this a correct way of doing this. Are the better ways?
2 Comments
Walter Roberson
on 6 Aug 2015
The worst case is not (y2-0), it is (y2-infinity).
If y1 is limited range, then the worst case is the end of the range "opposite" the side that y2 is on. For example if the range is 0 to 255, and y2 is 83, then the worst case is not y1 = 0 but rather y1 = 255.
The worst worst case is y1 maximum and y2 minimum or y1 minimum and y2 maximum, either one of which have an absolute difference of (maximum - minimum)
Answers (1)
Adam
on 6 Aug 2015
The two methods I have tended to use are:
absDiff = abs( y1 - y2 );
absDiffEnergy = sum( absDiff.^2 );
y1Energy = sum( y1.^2 );
diffEnergyPercent = absDiffEnergy / y1Energy * 100;
To give a percentage representing the energy in the difference between signals vs the energy in the first signal (usually I am comparing a signal to its approximation so in that case the first signal provides my baseline)
OR
Use use some measure of signal correlation - e.g.
dot( y1, y2 ) / ( norm(y1) * norm(y2) )
though the latter will give a perfect (1) match for a signal that is a linear multiple of another which would obviously be considered significantly different by other measures.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!