CRS
CRS

Reputation: 109

Correlation coefficients and SNR

I am interested in the correlation between a reference signal and a series of other signals. For this I use the the Spearman's coeff. Furthermore, I want to explain myself why is the correlation stronger for some data and weaker for others. Well the obvious answer is clearly: "Well the signals are similar/not similar". The idea is that I expect all of them to be similar and that's why I'm interested why they are not.

Let's say I have these 3 signals:

ref = [0.153698000000000    0.159227000000000   0.153578000000000   0.135617000000000   0.106725000000000   0.0720750000000000  0.0383580000000000  0.00419000000000000 -0.0406150000000000 -0.104511000000000  -0.178757000000000  -0.237172000000000  -0.248983000000000  -0.201136000000000  -0.112051000000000  -0.0171030000000000 0.0556220000000000  0.100198000000000   0.127225000000000   0.146429000000000   0.156469000000000   0.148586000000000   0.120207000000000   0.0822790000000000  0.0465630000000000  0.0127520000000000  -0.0302530000000000 -0.0892330000000000 -0.151656000000000  -0.187429000000000  -0.171909000000000  -0.106635000000000  -0.0207050000000000 0.0504730000000000  0.0890630000000000  0.101382000000000   0.102716000000000   0.103612000000000   0.101693000000000   0.0877250000000000  0.0557510000000000  0.00836400000000000 -0.0466150000000000 -0.101411000000000  -0.149962000000000  -0.184511000000000  -0.192687000000000  -0.163118000000000  -0.0969680000000000 -0.0117410000000000 0.0659480000000000  0.116307000000000   0.136674000000000   0.136510000000000   0.127171000000000   0.112167000000000   0.0907370000000000  0.0624430000000000  0.0266490000000000  -0.0188730000000000 -0.0752460000000000 -0.139144000000000  -0.194234000000000  -0.216676000000000  -0.188924000000000  -0.114953000000000  -0.0216350000000000 0.0608270000000000  0.116310000000000   0.147004000000000   0.166052000000000   0.179028000000000   0.180012000000000   0.161279000000000   0.121606000000000   0.0727670000000000  0.0258380000000000  -0.0186780000000000 -0.0675800000000000 -0.127120000000000  -0.188126000000000  -0.225266000000000  -0.212062000000000  -0.145823000000000  -0.0534320000000000 0.0279870000000000  0.0772470000000000  0.0977090000000000  0.108232000000000   0.121362000000000   0.131944000000000   0.126989000000000   0.100732000000000   0.0629320000000000  0.0262270000000000  -0.00548300000000000    -0.0427550000000000 -0.0963450000000000 -0.158377000000000  -0.203218000000000  -0.203878000000000  -0.149980000000000  -0.0592800000000000 0.0337540000000000  0.0997230000000000  0.128674000000000   0.133482000000000   0.128745000000000   0.122315000000000   0.112027000000000   0.0905840000000000  0.0587200000000000  0.0247430000000000  -0.00688800000000000    -0.0431370000000000 -0.0940400000000000 -0.156244000000000  -0.207234000000000  -0.217930000000000  -0.171546000000000  -0.0821420000000000 0.0148240000000000  0.0863420000000000  0.119430000000000   0.125936000000000   0.125051000000000   0.127984000000000   0.128781000000000   0.115835000000000   0.0852330000000000  0.0443400000000000  0.00490900000000000 -0.0255570000000000 -0.0544690000000000 -0.0948830000000000 -0.148332000000000  -0.197016000000000  -0.212808000000000  -0.179499000000000  -0.103302000000000  -0.0123390000000000 0.0617030000000000  0.104228000000000   0.119877000000000   0.122972000000000   0.125183000000000   0.125265000000000   0.114951000000000   0.0870480000000000  0.0447450000000000  -0.000855000000000000   -0.0396970000000000 -0.0696810000000000]

x= [0.271434000000000   0.288274000000000   0.209192000000000   0.0655440000000000  -0.0820200000000000 -0.148026000000000  -0.108114000000000  0.00370200000000000 0.0903880000000000  0.0670870000000000  -0.0543520000000000 -0.198260000000000  -0.266923000000000  -0.210663000000000  -0.0721470000000000 0.0476940000000000  0.0976820000000000  0.0815330000000000  0.0550950000000000  0.0509430000000000  0.0654310000000000  0.0761700000000000  0.0716700000000000  0.0496400000000000  0.0296730000000000  0.00932700000000000 -0.0220210000000000 -0.0918530000000000 -0.191917000000000  -0.273027000000000  -0.278303000000000  -0.193660000000000  -0.0558200000000000 0.0496270000000000  0.0822850000000000  0.0492800000000000  0.00158300000000000 -0.0250730000000000 -0.000159000000000000   0.0643930000000000  0.133856000000000   0.165200000000000   0.124040000000000   0.0217580000000000  -0.0914600000000000 -0.162790000000000  -0.156950000000000  -0.0734400000000000 0.0277270000000000  0.0829160000000000  0.0694490000000000  0.0286590000000000  0.0242190000000000  0.0770240000000000  0.144502000000000   0.164170000000000   0.111881000000000   0.0246120000000000  -0.0525930000000000 -0.0932270000000000 -0.117220000000000  -0.162008000000000  -0.231990000000000  -0.283092000000000  -0.257563000000000  -0.140892000000000  -0.0109250000000000 0.0575570000000000  0.0398860000000000  -0.0119950000000000 -0.0311610000000000 0.00895200000000000 0.0767310000000000  0.111818000000000   0.0770950000000000  -0.00480400000000000    -0.0648260000000000 -0.0590600000000000 -0.0239010000000000 -0.0113260000000000 -0.0503820000000000 -0.119773000000000  -0.166668000000000  -0.153385000000000  -0.0951590000000000 -0.0134120000000000 0.0758570000000000  0.169250000000000   0.265192000000000   0.320269000000000   0.312399000000000   0.248779000000000   0.170381000000000   0.116544000000000   0.0825490000000000  0.0229900000000000  -0.112957000000000  -0.311565000000000  -0.477718000000000  -0.528972000000000  -0.441705000000000  -0.277521000000000  -0.132652000000000  -0.0641130000000000 -0.0469650000000000 0.00307500000000000 0.145157000000000   0.348731000000000   0.493012000000000   0.479475000000000   0.325143000000000   0.114432000000000   -0.0427650000000000 -0.100921000000000  -0.0959820000000000 -0.103768000000000  -0.157386000000000  -0.232400000000000  -0.260288000000000  -0.205974000000000  -0.107415000000000  0.00374900000000000 0.0959960000000000  0.175779000000000   0.259562000000000   0.343460000000000   0.392091000000000   0.364989000000000   0.262129000000000   0.115872000000000   -0.0238940000000000 -0.112717000000000  -0.167219000000000  -0.228616000000000  -0.308254000000000  -0.357301000000000  -0.323026000000000  -0.200829000000000  -0.0399150000000000 0.0773370000000000  0.106666000000000   0.0934510000000000  0.134411000000000   0.283691000000000   0.484582000000000   0.615659000000000   0.578599000000000   0.376662000000000   0.121242000000000   -0.0499920000000000 -0.0908270000000000 -0.0512570000000000 -0.0251360000000000]

y=[0.0805620000000000   0.0193840000000000  0.0317950000000000  0.0923790000000000  0.157971000000000   0.196456000000000   0.213476000000000   0.217857000000000   0.199800000000000   0.132178000000000   0.00511700000000000 -0.129106000000000  -0.200164000000000  -0.161512000000000  -0.0533460000000000 0.0447720000000000  0.0777510000000000  0.0457860000000000  -0.000266000000000000   -0.00166500000000000    0.0469650000000000  0.100767000000000   0.105057000000000   0.0487410000000000  -0.0139600000000000 -0.0339380000000000 -0.0268990000000000 -0.0467280000000000 -0.117983000000000  -0.191721000000000  -0.206983000000000  -0.126591000000000  0.0368150000000000  0.187842000000000   0.245185000000000   0.207442000000000   0.113449000000000   0.0277730000000000  -0.0201070000000000 -0.0340330000000000 -0.0418780000000000 -0.0577930000000000 -0.0687330000000000 -0.0774580000000000 -0.112039000000000  -0.203065000000000  -0.325518000000000  -0.408340000000000  -0.384561000000000  -0.233895000000000  -0.000200000000000000   0.206361000000000   0.301673000000000   0.258327000000000   0.158405000000000   0.0850420000000000  0.0638960000000000  0.0601920000000000  0.0267320000000000  -0.0495640000000000 -0.140141000000000  -0.216581000000000  -0.246500000000000  -0.220618000000000  -0.159008000000000  -0.0645680000000000 0.0638910000000000  0.195499000000000   0.292969000000000   0.314935000000000   0.253050000000000   0.141489000000000   0.0485870000000000  0.0141340000000000  0.00904500000000000 -0.0209880000000000 -0.102024000000000  -0.191704000000000  -0.229835000000000  -0.193077000000000  -0.117835000000000  -0.0788180000000000 -0.132543000000000  -0.227262000000000  -0.261066000000000  -0.146183000000000  0.0732720000000000  0.288526000000000   0.393861000000000   0.375488000000000   0.312956000000000   0.280953000000000   0.293536000000000   0.294787000000000   0.228394000000000   0.0812080000000000  -0.0979610000000000 -0.219818000000000  -0.247000000000000  -0.203883000000000  -0.152293000000000  -0.128943000000000  -0.114403000000000  -0.0782120000000000 -0.0208240000000000 0.0301690000000000  0.0414160000000000  0.00930500000000000 -0.0224010000000000 -0.0127020000000000 0.0374780000000000  0.0839880000000000  0.0805340000000000  0.0179880000000000  -0.0578820000000000 -0.103678000000000  -0.0949510000000000 -0.0417700000000000 0.0216980000000000  0.0582560000000000  0.0632220000000000  0.0520980000000000  0.0350020000000000  0.0327130000000000  0.0430200000000000  0.0648000000000000  0.0662060000000000  0.0380750000000000  0.00131200000000000 -0.0341550000000000 -0.0591350000000000 -0.0705680000000000 -0.0688930000000000 -0.0640920000000000 -0.0680670000000000 -0.0878340000000000 -0.112712000000000  -0.137633000000000  -0.136924000000000  -0.0989540000000000 -0.0408820000000000 0.0148740000000000  0.0569500000000000  0.0903410000000000  0.119637000000000   0.161266000000000   0.213775000000000   0.254719000000000   0.255163000000000   0.198274000000000   0.106108000000000   0.0180750000000000  -0.0376770000000000]

The corrcoef(ref,x) = 0.7448 ( I don't know why i get 4 values as a result of correcoef). The corrcoef(ref,y) = 0.6860.

Now, I can not tell just by looking in time the reason or slightly weaker correlation, so I try to look at the frequencies: enter image description here

Now, my guess is that it is because of the signal to noise ration of each signal. I want to compute SNR for each individual signal, but here is where I got stuck. All the formulas I found related to SNR know in advance which one is the signal and which one is the noise, but I don't. The way I want to compute the SNR is by taking the Energy in the highest peak and divide it by the energy in the rest of the peaks, but I don't know exactly how to do this in matlab. I guess for the highest peak I can have a cursor pointing, but how do I compute the sum energy of the rest of the peaks?

PS: I've tried Matlab's a = snr(x) ; and I get

Undefined function 'snr' for input arguments of type 'double'.

even though when I list the toolbox >>ver , Signal Processing Toolbox Version 6.19 it's one the list. Thank you!

LATER EDIT: What if I try this:

Energy = abs(fft(ref, NbOfPoints))  //get the magnitudes for FFT in NbOfPoint
Energy = Energy(1:NbOfPoints/2)     // keep the first half, the others are mirrored
[HP index] = max(Energy)            // get the magnitude of the highest peak and it's position
Energy(index)=0                     // set the Highest Peak to 0
SNR = HP / sum(Energy)              // compute magnitude of highest peak / sum of others

Is this relevant? the results are quite low obviously ( 0.02 ~ 0.03 ) and I don't know if this an accepted way of comparing signal and noise. Maybe instead of the highest peak should I choose a number of beans around highest peak? Like (HP-2:HP+2) ?

Upvotes: 1

Views: 1944

Answers (1)

Martin Héroux
Martin Héroux

Reputation: 220

You have to be careful reading too much into the spectral-domain of signals when trying to explain why they are more or less correlated in the time-domain. While I understand your approach to trying to quantify the SNR of each signal, you also state that you don't know what is signal and what is noise. The plot of the ref signal shows that there are harmonics to the main spectral peak, and these are part of the signal as well (and not noise).

If you plot the x-y plot of both signals with regards to the ref signal, this is what the correlation is being performed on.

plot (ref,x,'.')
hold on
plot (ref,y,'.r')

So on a point by point basis (or sample by sample basis), is an increase in the ref signal associated with a linear increase in x or y. The more thighly the signals change together in a linear fashion, the more correlated they will be.

Sometimes it is useful to look at the cross-correlation to see if there is any lag in the signals. If so, you may find that the peak correlation happens not at lag 0 (which is equivalent to running a simple correlation), but with a certain amount of lag between the signals.

[LAGS,C] = xcorr ([ref',x'])
plot(LAGS,C)

You might also want to run a coherence analysis to see what frequency content is similar between the two signals. This would help you decide whether the signal that is not located at the spectral peak is all noise or if there is other spectral content (including harmonics) that is actual 'signal'.

Upvotes: 0

Related Questions