Cosine Correlation
Calculates the correlation between an input signal and some cosine signal (of known frequency).
\[ S_p = \sum^{N-1}{S_n \times \cos(\frac{2 \pi n p}{N})}, p = 0\ldots{N-1} \] Where:
- \(S_n\) is some arbitrary signal \(s\).
- \(\cos(\frac{2 \pi n p}{N})\)
Note: This is just the correlation function with the second signal parameterised as a cosine.
Basis for Correlation
For two sinusoids, \(s, t\) where:
- The period of one is a multiple of the number of periods in the other
- The sample range N is defined such that it occurs over a whole number of cycles for both signals.
it can be [see page 18, shown] that the correlation for these sinusoids is 0 at all points except where the angle between them is equivalent (they have the same frequency at maybe a different phase).
The correlation between \(s\) \\& \(t\) is [see page 2, proportional] to the amplitude A of the target signal \(t\) when:
When the angle between them is equivalent the 2 cosinuses constructively superimpose. At every point \(cos(\theta)\) is squared (cancelling out the negatives) and causing a net positive sum. You can visualise the affect [see page 18, here].
Applications in Frequency Analysis
Because any signal can be decomposed into the sum of multiple sine waves and
cosine-correlation can determine whether an arbitrary signal \(s\) has a correlation
with a cosine of known [see page 19, varying] frequency \(t\), we can use cosine correlation in
frequency-analysis.
Essentially we vary the frequency of a cosine wave and keep calculating its correlation with the signal, recording any frequency values that have a none zero correlation.
Phase Consequence
We can only use cosine-correlation when the target signals (sinuses) are in-phase. The [see page 1, correlation] between two cosines varies according to the phase difference between them, with:
Phase | Correlation |
---|---|
In phase | Maximum correlation |
\(90^\textdegree\) | Zero correlation |
\(180^\textdegree\) | Maximum -ve correlation |
We know that the multiplication of two cosines is:
\[ \cos(a) . \cos(b) = \frac{1}{2} \times (\cos(a-b) + \cos(a+b)) \]
When the two cosines have the same phase (and thus the same angle) we get:
\[ \cos(\omega t) . \cos(\omega t) = \cos^2(\omega t) = \frac{1}{2} \times (\cos(0) + \cos(2\omega t)) \]
When this isn't the case there's a constant difference ($\phi$) between the two
angles at each point $t$ and our equation becomes.
\[ \cos(\omega t) . \cos(\omega t - \phi) = \frac{1}{2} \times (\cos(\phi) + \cos(2 \omega t - \phi)) \]
It can be shown that the correlation of two [see page 2, cosines] differing in a phase-difference \(\phi\) is proportional to the cosine of \(\phi\). That is to say we can write the [see page 4, cosine-correlation]
\[ q = \alpha \cos(\phi) \]
Note: [see page 3, how] the the phase-difference of two sinuses varies as a cosinus,