# Auto Correlation for Time Frequency Analysis

Given a signal $x(t)$, how do I implement a form of autocorrelation function defined as $a(t,T) = x(t-T)x(t+T)$, where $T$ is an arbitrary constant?

(a fast implementation would be ideal)

Edit: This kind of signal I came across from seeing a "Parametric Symmetric Autocorrelation function", defined as above.

It is used in time-frequency analysis methods like WVD,...etc. $R(t,\tau) = x(t + \frac{\tau}{2})x^{*}(t-\frac{\tau}{2})$

Thus far, I have implemented the steps as below for an example chirp: but the output of the fft2 at the end is wrong. (not a correct frequency)

At the output of the autocorrelation function (the PSIAF variant): The final output of the LVD is wrong (should be point like):

Solved: Will look at using some of the already published C codes as per answer below to compute the $R(t,\tau)$

• continuous time ? your autocorrelation definition is also wrong. – Fat32 Jun 25 '16 at 15:36
• for discrete time, actually instead of the autocorrelation of $x(t)x(t-T)$, wanted a variant – matthew Jun 25 '16 at 16:28
• what @Fat32 means, is that there is something missing from your autocorrelation definition. matthew, it seems to me that there is some things still a bit outa your game. – robert bristow-johnson Jun 25 '16 at 18:20
• Can I please ask what do you mean by "variant"? Also, it would help in getting more useful answers if the question was edited to become clearer. What are you trying to achieve? What have you tried so far? What is the exact problem you are requiring help with? – A_A Jun 30 '16 at 8:09
• thanks for the comments, I have added more details about the problem and what i am trying to achieve – matthew Jul 1 '16 at 8:03

This line seems wrong:

X = signal(X1_signal_indices).*conj(X1conj_signal_indices);


shouldn't it be

X = signal(X1_signal_indices).*conj(signal(X1conj_signal_indices));


??

Note that there is some C code for implementing the WVD and other distributions here. That code calculates your $R(t,\tau)$ first before convolving various 2D functions with it and then taking the FFT in order to generate the different distributions.

The definition of autocorrelation (for a real-valued signal $x$) is

$$R_{xx}(T) = \sum_{n=1}^N{x(n)x(n-T)}$$

where $T$ is the time lag and $N$ is the number of data in $x$.

You only have to calculate $R_{xx}$ for positive $T$ since it is an even function. If you want to optimize further you may approximite by using

$$\hat{R}_{xx}(T) = \sum_{n=1}^N{x(n)\mathrm{sgn}[x(n-T)]}$$

where $\mathrm{sgn}$ is the sign function, this will remove all the float/double multiplications and gives a pure summation.

• @Clas Rolen I believe taking FFT, reversing, and then multiplying the reversed signal with the original is a more efficient solution especially for long auto-correlation functions. – Dole Jun 29 '16 at 1:08
• In the context of TF analysis, the OP's definition of autocorrelation is appropriate: en.wikipedia.org/wiki/… – Robert L. Jun 22 '18 at 23:02