Cross- and auto-correlation

  • Thread starter balanto
  • Start date
  • Tags
In summary, the conversation discusses finding the cross correlation and time difference between two vectors with given values, as well as calculating the auto correlation and corresponding frequency. The time difference is determined by the lag (offset from zero) of the non-zero entry in the cross correlation, and the frequency is found by evaluating the discrete Fourier transform. Autocorrelation measures the relationship between points in a sequence and their nearest neighbors.
  • #1
Homework Statement

1. Given two vectors
x = [0 0 1 0 0 ] and y = [0 0 0 0 1] find the cross correlation and the time difference between the pulses if the sampling frequency is 1kHz?

2. Given this vector calculate the auto correlation and if the signals is sampled at a frequency of 1MHz what does the signal correspond to in frequency
  1. x = {0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1}
The attempt at a solution
Cross correlation for problem 1:
[0 0 1 0 0 0 0 0 0]

Auto correlation for problem 2:
[0 0 1 2 1 0 2 4 2 0 3 6 3 0 2 4 2 0 1 2 1 0 0]

The thing I'm having a hard time about is finding the time difference for problem 1 and the corresponding frequency in problem 2. How do I approach that?
Physics news on
  • #2
1. What is the lag (offset from zero) of the non-zero entry in the xcorr? (You can also easily see the same time difference directly in the raw signals x and y.)
2. What theorem relates the autocorrelation function to the power spectral density?
  • #3
marcusl said:
1. What is the lag (offset from zero) of the non-zero entry in the xcorr? (You can also easily see the same time difference directly in the raw signals x and y.)
2. What theorem relates the autocorrelation function to the power spectral density?

1. Okey, then the lag should be 2 in this case? Because there are two zero values before the first non-zero? And since the sampling time is 1ms then the time difference would be 2ms?
2. That would be integral of [f(t)*e^(-jwt) dt] where f(t) is the correlation function. Although I'm not sure what to do here. Since our autocorrelation have 15 values, from 0 - 14, then the limits of integrations would be 0 --> 14, but that would only result in 0. I am not quite sure I understand cross/autocorrelation and its applications

Thanks for the reply!
  • #4
Number one is correct.
For number two, why do you think it is zero? In general, there will be an infinite number of omega frequencies to evaluate. In practice, you can assume a discrete Fourier transform, and just evaluate integer values k such that omega runs from 0 to 14 * 2*pi.
As for the meaning of autocorrelation, it gives the extent to which each point in a sequence is related to its nearest neighbors, next nearest neighbors, and so on.
Last edited:
  • #5
I think my last post could have been clearer. The exponential for a discrete FT looks like [tex]exp\left(\frac{-j2\pi nk}{N}\right)[/tex] with the indices n and k running from 0 to N-1. Here n indexes time and k indexes frequency. Also I just counted the number of values in your cross correlation and there are 23, not 14.
Last edited:

1. What is cross-correlation and how is it different from auto-correlation?

Cross-correlation is a statistical method used to measure the similarity between two different signals or data sets. It involves shifting one of the signals and calculating the correlation coefficient at each shift. Auto-correlation, on the other hand, is used to measure the similarity between a signal and a time-delayed version of itself. Essentially, cross-correlation compares two different signals while auto-correlation compares a signal with itself.

2. How is cross-correlation used in data analysis and research?

Cross-correlation is commonly used in data analysis and research to identify patterns and relationships between different data sets. It can also be used to find similarities between signals or to align and compare time series data. It is often used in fields such as signal processing, time series analysis, and image recognition.

3. What is the difference between linear and non-linear cross-correlation?

Linear cross-correlation assumes that there is a linear relationship between the two signals being compared. This means that the signals can be compared using a simple linear equation. Non-linear cross-correlation, on the other hand, does not assume a linear relationship and can be used to identify non-linear patterns and relationships between signals.

4. How is cross-correlation calculated?

The calculation of cross-correlation involves multiplying the two signals together at each time shift and taking the sum of the products. This value is then divided by the product of the standard deviations of the two signals. This results in a correlation coefficient value between -1 and 1, with a value of 1 indicating a perfect match between the two signals.

5. What are the limitations of cross-correlation?

One limitation of cross-correlation is that it does not indicate causation between two signals. Just because two signals are highly correlated does not mean that one signal causes the other. Additionally, cross-correlation can be affected by outliers and noise in the data, which can lead to inaccurate results.

Suggested for: Cross- and auto-correlation