Analysis frequencies
Contents
5.3. Analysis frequencies#
In the previous section, we saw how to setup comparisons between an input signal \(\blue{x[n]}\) and a collection of reference signals \(\red{y_m}\) defined to be sinusoids (cosine waves) with analysis frequencies determined by the length \(\blue{N}\) of the signal (and the sampling rate \(f_s\)).
In this section, we’ll dig a little deeper, and see how this kind of comparison behaves for specific choices of \(\blue{x}\). This will both solidify our understanding of the process, and also illustrate some short-comings of the method that we’ll need to improve.
5.3.1. Comparing analysis frequencies#
Let’s see what happens when \(\blue{x[n]}\) is also a sinusoid at one of our chosen analysis frequencies.
For this example, we’ll take \(f_s = 20\), \(N = 40\) (2 seconds), and take \(\blue{x}\) to be the analysis frequency for \(\red{m=3}\) [cycles / signal-duration]
.
Since the signal duration is 2 seconds, this corresponds to a frequency of \(3/2\) [Hz]
.
Our sampled wave will be given by
Fig. 5.9 shows the similarity comparisons and resulting scores for the first five reference signals. In this case, all scores are 0 except for \(\red{m=3}\), which corresponds exactly to the frequency of our test signal \(\blue{x[n]}\).
Why does this happen?
5.3.1.1. Understanding analysis frequencies#
Our definitions of similarity (5.1) and reference signal (5.5) lead to the following equation when \(\blue{x[n]}\) is the cosine wave given above in (5.6):
We can simplify (5.7) with a bit of trigonometry. The product-to-sum rule for cosines gives us for any angles \(\theta\) and \(\phi\):
If for each sample index \(n\), we let
be the angle of the first factor in the summation (the \(x\) part), and let
be the angle of the second factor (the \(y\) part), we would get
and each term of the summation in (5.7) can be rewritten as:
This tells us that in this case, \(\purple{S}\) can be computed by averaging the samples of reference signals \(\red{y_{3+m}}\) and \(\red{y_{3-m}}\).
Plugging this back into Equation (5.7), we get
where the second step follows by breaking the summation into pieces only concerned with \(\red{y_{3+m}}\) or \(\red{y_{3-m}}\).
Now, let’s consider two cases. If \(\red{m \neq 3}\), then both of these signals will have non-zero frequency. Because they are both analysis frequencies, they will complete a whole number of cycles in the duration of the signal. Though we haven’t proven it yet, this means that the sample values will sum to zero. (We’ll prove this fact and a slightly more powerful theorem a few sections from now.)
Since both summations will sum to zero, the full similarity score \(\purple{S(x, y_m) = 0}\).
On the other hand, if \(\red{m = 3}\), then our two signals will be \(\red{y_{3+3}=y_{6}}\) and \(\red{y_{3-3} = y_0}\). The first signal \(\red{y_6}\) will total to zero by the argument above. The second signal, \(\red{y_0}\) however will not total to zero, because \(\red{y_0[n] = 1}\) for all \(n\). As a result,
There is a third case that can happen (but not in the example above), where \(\blue{x}\) is generated by either the highest analysis frequency \(\blue{k=N/2}\) (the Nyquist frequency) or if \(\blue{k=0}\) (constant signal). If this happens, and \(\red{m=k}\), then
In either event, both terms in the summation become \(N/2\) and the total score is \(N\).
This explains the observation above: similarity between analysis frequencies is either \(0\), \(\frac{N}{2}\), or \(N\), and the latter cases only occur when the reference signal \(\red{y_m}\) has the same frequency as the input \(\blue{x}\).
Warning
This cancellation only happens if \(\blue{x}\) is a wave at an analysis frequency.
Waves at non-analysis frequencies will not generally share this property.
5.3.2. Non-analysis frequencies#
If instead of an analysis frequency, we had chosen \(x\) to be a sinusoid at a frequency that does not complete a whole number of cycles over the signal duration, we could still try to apply the reasoning above, but it’s not going to work out.
For example, if we take \(m = 1.5\) [cycles / signal-duration]
— which is not an analysis frequency because 1.5 is not an integer — we would have a wave \(x[n]\) at \(1.5/2 = 3/4\) [Hz]
:
Like before, Fig. 5.10 shows the similarity comparisons and resulting scores for the first five reference signals. In this case, the scores are all non-zero because the wave doesn’t precisely line up with itself at \(N\) samples.
This phenomenon is known as spectral leakage: a wave at a non-analysis frequency will leak across the entire frequency range, and appear to be a little similar to each analysis frequency.
We’ll have more to say about this in subsequent chapters, but for now, it’s important to understand that waves of different frequencies can still produce a non-zero similarity score.