0
$\begingroup$

I am trying to solve exercises from the book Understanding digital signal processing 3 Ed - Richard Lyons. I will repeat the question as it is in the book:

3.3 We want to calculate an N-point DFT from a one-second compact disc (CD) audio signal of duration $x(n)$, whose sample rate is $f_s = 44.1 \text{kHz}$, with a sample spacing of $1 \text{Hz}$.

(a) What is the number of time samples $x(n)$ required, N?

(b) How long is the sequence time $x(n)$ measured in seconds? Tip: This part (b) of the problem is more complicated than it looks at first. Think carefully.

My answer to question (a) is $N = 44100$, since the DFT frequency resolution is $\frac{f_s}{N}$. So, for $1 \text{Hz}$ resolution, I think it's quite obvious. But, in question (b), I'm little insecure. As the hint suggests, looks like a trickier question, but I don't know exactly why. My first guess is that the duration of the sequence is 1 second. Would anyone know why it wouldn't be? Thanks!

$\endgroup$
  • $\begingroup$ Yes. I understand that the question is about the duration of the sequence $ x(n) $ $\endgroup$ – Henrique Luna Jul 17 at 19:20
  • 1
    $\begingroup$ $x(n)$ is a very unusual use of a symbol denoting duration. Are you sure that the duration is not $N$? $\endgroup$ – Dilip Sarwate Jul 17 at 19:54
3
$\begingroup$

@Henrique Luna. Please forgive me. In Part (b) of the problem the words "sequence time" should "time sequence". Sorry for the confusion!

Years ago when I created that Part (b) question I was thinking about the answer to the question; "What is the time duration of an N-sample time-domain sequence?" Back then I believed the time duration under consideration to be the time difference between the sequence's first and last samples, rather than N times the time interval (1/fs) between the samples. Thinking this way leads to the conclusion that Part (b)'s answer is (N-1)*1/fs = 0.999977 seconds.

But subsequent discussion, years ago, with Dilip Sarwate convinced me that my concluded answer to 3.3 Part (b) may be somewhat valid when thinking about the time-domain but my concluded answer leads to confusion when thinking about signal durations in the context of spectrum analysis.

I now believe the 3.3 Part (b) question leads to more confusion than enlightenment. That Part (b) question was not my most well thought-out homework problem.

By the way Henrique, if you have not done so already, please have a look at the following web page: https://www.dsprelated.com/showarticle/1094.php

| improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ I am flattered that you remember that discussion. But here, perhaps you could shed some iight on your choice of $x(n)$ to denote the duration of the sequence? Or is that a copying error by the OP? $\endgroup$ – Dilip Sarwate Jul 18 at 0:47
  • $\begingroup$ @Dilip Sarwate. (I hope you are doing well.) I remember that discussion very well because you taught me something quite useful. The wording of Part (b) of the homework problem should have been "How long is the time sequence x(n) measured in seconds?" Today I would write it as: "How long, measured in seconds, is the x(n) time-domain sequence?" $\endgroup$ – Richard Lyons Jul 18 at 8:13
3
$\begingroup$

There is a very important point that is being glossed over in this question (which follows how this topic is conventinally taught) which is:

The DFT does not care what your sampling rate is.

Ultimately, every DFT calculation boils down to these parameters using conventional naming:

$$ \begin{aligned} N &= SamplesPerFrame = \frac{Samples}{Frame}\\ k &= Bin = CyclesPerFrame = \frac{Cycles}{Frame} \\ n &= Sample \\ \omega &= Frequency = RadiansPerSample = \frac{Radians}{Sample} \\ 2\pi &= RadiansPerCycle = \frac{Radians}{Cycle} \\ \end{aligned} $$

The sampling rate is the conversion factor that relates the DFT values to the application.

$$ \begin{aligned} f_s &= SamplesPerSecond = \frac{Samples}{Second} \\ Hz &= CyclesPerSecond = \frac{Cycles}{Second} \\ \end{aligned} $$

So, my first irk is when people use "Hz" as a unit for the sampling rate and call it the "sampling frequency" (even the conventional symbol itself does this). This is incorrect units-wise and requires an implicit assumption of "one cycle per sample". This is more than a pedantic preference. The consequences are apparent with the number of times questions like this one surrounding these simple conversion come up and why, for many people, it seems to be the stumbling block that prevents further progress. Reserve the unit of Hz for referring to the signals, not the sampling, and much of this confusion can be avoided.

The two sets of definitions lets you unit check your formulas:

$$ \frac{f_s}{N} = \frac{\frac{Samples}{Second}}{\frac{Samples}{Frame}} = \frac{Frames}{Second} $$

This quantity should not be designated "Hz". A conversion can be made though:

$$ \frac{\omega}{2\pi} = \frac{\frac{Radians}{Sample}}{\frac{Radians}{Cycle}} = \frac{Cycles}{Sample} $$

$$ \frac{f_s}{N} = \frac{\frac{\omega}{2\pi}}{\frac{\omega}{2\pi}} \cdot \frac{f_s}{N} = \frac{\frac{Cycles}{Sample}}{\frac{Cycles}{Sample}} \cdot \frac{\frac{Samples}{Second}}{\frac{Samples}{Frame}} = \frac{\frac{Cycles}{Second}}{\frac{Cycles}{Frame}} = \frac{Hz}{Bin} $$

Note that this equation is independent of $\omega$ which means it is a proportional relationship across all the frequencies, and thus bins. So the formula

$$ f = k \cdot BinWidth $$

is seen in units as

$$ Hz = Bin \cdot \frac{Hz}{Bin} $$

Which makes it a lot more understandable on why it works that way.

Another example is the exponent expression from the DFT and inverse DFT:

$$ \frac{2\pi}{N}nk = \frac{\frac{Radians}{Cycle}}{\frac{Samples}{Frame}}\cdot Sample \cdot \frac{Cycles}{Frame} = Radians $$

Get these straight (I'm talking to you, newbies) and your learning path will be smoother.

The OP will need this one for the actual question in the post:

$$ \frac{Seconds}{Frame} = \frac{\frac{Samples}{Frame}}{\frac{Samples}{Second}} = \frac{N}{f_s} $$

Unit analysis is a lot stronger than dimensional analysis. [Edit, emphasized for RB-J's benefit.] Also, the application is not always in seconds, or time for that matter.


Response to RB-J in the comments:

From https://en.wikipedia.org/wiki/Nyquist_frequency:

"The Nyquist frequency is half of the sampling rate of a discrete signal processing system. It is named after electronic engineer Harry Nyquist. When the function domain is time, sample rates are usually expressed in samples per second, and the unit of Nyquist frequency is cycles per second (hertz)."

To go from samples per second to cycles per second, you need either a conversion factor of samples per cycle or cycles per sample.

The Nyquist frequency occurs at two samples per cycle independent of the nature of the signal, independent of the sampling rate, and independent of the DFT frame size (sample count), or even if a DFT is taken.

It can also be converted into a value of $\pi$ radians per sample using a conversion factor:

$$ \frac{1 \text{ cycle}}{2 \text{ samples}} \cdot \frac{2\pi \text{ radians}}{1 \text{ cycle}} = \pi \frac{ \text{ radians}}{ \text{ sample}} $$

[Note: $2\pi$ is not unitless either.]

The implicit conversion factor above can be made explicit, as in the comments:

$$ f_s = \frac{f_s \frac{\text{samples}}{\text{second}}}{1 \frac{\text{sample}}{\text{cycle}} } = f_s \frac{\text{cycles}}{\text{second}} = f_s \text{ Hz} $$

The nature of the extension/extrapolation in either domain is tangential and irrelevant. The units of the discrete spectrum are cycles per frame. The continuous case is also irrelevant to this discussion.

| improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ +1 and especially for the statement in boldface at the top of the answer. $\endgroup$ – Dilip Sarwate Jul 18 at 15:28
  • $\begingroup$ May I correctly express the Nyquist frequency, $\frac{f_\mathrm{s}}{2}$ in units of Hz? $\endgroup$ – robert bristow-johnson Sep 7 at 18:26
  • $\begingroup$ @robertbristow-johnson Why not? $\endgroup$ – Cedron Dawg Sep 8 at 4:23
  • $\begingroup$ because of your "first irk" and because multiplying by the dimensionless $\frac12$ does not change the dimension or units of a quantity. $\endgroup$ – robert bristow-johnson Sep 8 at 12:01
  • $\begingroup$ @robertbristow-johnson Say what? If your application time unit is seconds: $$ \frac{f_s}{2} = \frac{f_s \frac{\text{samples}}{\text{second}}}{2 \frac{\text{samples}}{\text{cycle}} } = \frac{f_s}{2} \frac{\text{cycles}}{\text{second}} = \frac{f_s}{2} \text{ Hz} $$Changing the 2 to 1 is the "implicit one sample per cycle" I reference in the answer. $\endgroup$ – Cedron Dawg Sep 8 at 12:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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