Tuesday, April 23, 2019

Correlation : How is correlation analogous to dot product?


Till now I know correlation tells about similarity. I was watching a video lecture on image similarity in which I came to know that correlation is analogous to dot product. And hence correlation of two images is maximum when these images are similar as happens in dot product of two aligned(similar) vectors.


Dot product of two vectors $a=[a_1, a_2, a_3, .....]$ and $b=[b_1, b_2, b_3, .....]$ is given as $$a\cdot b=\sum_{i}a_ib_i$$ While cross correlation of two discrete real signals $x(n)$ and $y(n)$ is given as $$R_{xy}(n)=\sum_mx(m)y(n+m)$$
So now I want to know:




  • How correlation is analogous to dot product?

  • When is correlation maximum?

  • Why?



Answer



So using your formula for the cross-correlation:


$$R_{xy}(n)=\sum_m x(m)y(n+m)$$


we see that


$$\begin{align} R_{xy}[n]&=\sum_m x[m]y[n+m]\\ &= \sum_m x[m] \tilde y_n[m]\\ &= x \cdot \tilde y_n\\ \text{for}\\ \tilde y_n[k] &= y[n+k]\text{ ,}\\ \end{align}$$ which is a dot product.



So for any "shift" in the cross-correlation, you have the dot product of the first operand with the $n$-shifted second operand.


Note, by the way, that your formulas are only correct for real-valued $x$, i.e. in general, the correct formula for dot product and cross correlation are:


$$\begin{align} x\cdot y &= \sum\limits_{i=0}^{N-1} x^*[i]y[i]\\ R_{xy}[n] &= \sum\limits_{i=0}^{N-1} x^*[i]y[n+i]\\ \text{with}\\ x,y &\in \mathbb C^N\\ {z}^*&= \Re\{z\} - \Im\{z\} \end{align}$$


No comments:

Post a Comment

digital communications - Understanding the Matched Filter

I have a question about matched filtering. Does the matched filter maximise the SNR at the moment of decision only? As far as I understand, ...