Reagrding autocorrelation
1 Attachment(s)
To have a proper understanding I started with a short dataframe where the 2nd column represensts velocity at different time-step collected from a probe (for example). And I m trying to plot the correlation function with time lag.
PHP Code:
r(s)=⟨U(t)U(t+S)⟩/⟨⋃(t)^2 ⟩ And the above formula is my auto-correlation function where τ is my time lag. Now as far my my knowledge it is calculated as follows (explaining with this example). 1. The denominator is just when τ =0. So Quote:
2. The τ = 0 to 10 Quote:
Now my questions are:- 1. Does this procedure really happen like this? 2. If so then I tried it in MATLAB and it gave results with negative( whereas my U are all positive). How is that possible? I ve attached a word doc for better understanding of my doubt. Will be really helpful if someone helps. |
Not sure which matlab function you used here. Or what the default behavior of matlab is with that function.
But there is some degree of ambiguity when it comes to evaluating autocorrelation. Just look at all the options gnu octave provides: https://octave.sourceforge.io/signal...ion/xcorr.html On top of those, one could also remove the mean value before computing an autocorrelation. Maybe that's what your matlab call was doing, and why it gave negative values. Among all those options (including your normalization with the value for tau=0), there is no definitive "right" or "wrong" way of computing an autocorrelation. Each of the options just highlights different properties of the signal. Which one is right for you mostly depends on what you want to do with the autocorrelation values. |
for calculating the correlation u need to subtract out the mean. so negative values are possible and sane. negative correlation means that for certain separation in time/space, the product of values above (or below) the average with those below (or above) the average are outsumming the other combination.
-- |
Quote:
Quote:
|
Not like that. You are dividing by the sum of squares. Removing the mean in this context: calculate the mean value of your signal, subtract that from each value of your signal, then go on to calculate autocorrelations with the result.
|
Quote:
Lets say Quote:
But I just plotted the thing in python just now both gave the same autocorr plot.:) |
that was fast.
1) find the mean of the u values. 2) from every u value subtract out the above mean. you will find negative values appearing. 3) calculate the autocorrelation which should be the same as the matlab one. warning: i have not used matlab. it is very likely that matlab assumes periodicity in the data so that its calculation is 'wrapped' round. -- |
Quote:
|
Quote:
If you plugged both your original series and the series with zero mean into your matlab call, then we have confirmation that whatever you used in matlab to get autocorrelations, does indeed remove mean values first. Maybe it's time to read the documentation now. Or share which call you used in matlab. |
Quote:
This one is my original series : Quote:
This one is after deducting the mean value which is 10.445 Quote:
I m using both MATLAB and Python. When I plot both in Python I got the same result. For Python Quote:
Thanks again for your patience and eagerness.:) |
So mystery solved I guess? Your matlab call with default settings removes the mean values before calculating autocorrelations. That's why you get the same result with the original series, and the series where you manually removed the mean value before plugging it into the autocorrelation function.
|
All times are GMT -4. The time now is 22:36. |