0
$\begingroup$

I am having an input signal x[n]=[1 2 3 4 5 6] and another signal y[n]=[2 3 4].

In order to check whether y[n] is present in the signal x[n],I did cross correlation and the result obtained was [ 0 0 0 4 11 20 29 38 47 28 12].

If the signal y[n] is present in x[n], then the correlation value will be equal to the energy of y[n] which is 29. From the correlation output, it can be found out that signal y[n] is present in x[n].

Now consider another signal z[n]=[7 5 0] and I want to check y[n] is present in z[n]. The correlation result is given by [28 41 29 10 0]. Here also the autocorrelation of y[n] is there but y[n] is not present in z[n].

Correlation of input signal with another signal can result in a value equal to the autocorrelation of the signal to be found out. So in that case how to find out a signal is present in another signal or not from correlation result ]

$\endgroup$

1 Answer 1

3
$\begingroup$

If the signal y[n] is present in x[n], then the correlation value will be equal to the energy of y[n] which is 29. From the correlation output, it can be found out that signal y[n] is present in x[n].

and

Correlation of input signal with another signal can result in a value equal to the autocorrelation of the signal to be found out

No!

The sequence

$$\tilde x[n] = \ldots, 0, 0, 2000, \frac{29}{3}, -1000, 0,0,\ldots $$

correlated your way with $y[n]= (2,3,4)$ will yield 29 on the output, as will infinitely many others, but, as you can see, does not contain $(2,3,4)$, and nothing even resembling it.

You need to divide each correlation coefficient correctly with the root of the sum of squares of the samples taken into account if you want to sensibly work with correlation to detect things.

$$r_{xy}[k] = \frac {y[0] \cdot x[k-1] + y[1] \cdot x[k] + y[2] \cdot x[k+1]} { \sqrt{ y[0]^2+y[1]^2+y[2]^2 } \sqrt{ x[k-1]^2+x[k]^2+x[k+1]^2 } } $$

Then (and only then) the correlation becomes a measure of linear similarity of $x$ to $y$; so if you need the identical $y$ to be embedded in $x$, you would be looking for occurrences of $1$.

The question is why you would make things so complicated then. If you're looking for an exact "substring", then look for a substring in $x$.

$\endgroup$
4
  • $\begingroup$ If the data length is small, then we can look for substring. But if the length of data is large, then there should be a method to solve it $\endgroup$
    – Aami
    Commented Mar 14 at 11:58
  • 1
    $\begingroup$ correlation actually needs multiplications and additions, searching for a substring is easier and faster. So your point seems to be moot. Also, your CPU can look, with a single CPU core, for identical substrings in literal Gigabytes per second. I don't think you're solving an actual problem there! $\endgroup$ Commented Mar 14 at 12:00
  • $\begingroup$ what you calculate there in your first comment has nothing to do witht the formula in my answer. $\endgroup$ Commented Mar 14 at 12:01
  • $\begingroup$ (note that you can't just set y[i]^2 to 0 just because x[i]^2 is zero. That's not what the formula says. Also, it makes no sense to correlate with "assumed" zeros outside of your defined sequence when looking for a non-zero subsequence; that's just wasted computation) $\endgroup$ Commented Mar 14 at 14:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.