2

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!

AlexTP
  • 6,585
  • 2
  • 21
  • 38

2 Answers2

5

@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

Richard Lyons
  • 5,777
  • 13
  • 25
  • 1
    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? – Dilip Sarwate Jul 18 '20 at 00:47
  • @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?" – Richard Lyons Jul 18 '20 at 08:13
3

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.

Cedron Dawg
  • 7,560
  • 2
  • 9
  • 24
  • 1
    +1 and especially for the statement in boldface at the top of the answer. – Dilip Sarwate Jul 18 '20 at 15:28
  • May I correctly express the Nyquist frequency, $\frac{f_\mathrm{s}}{2}$ in units of Hz? – robert bristow-johnson Sep 07 '20 at 18:26
  • @robertbristow-johnson Why not? – Cedron Dawg Sep 08 '20 at 04:23
  • because of your "first irk" and because multiplying by the dimensionless $\frac12$ does not change the dimension or units of a quantity. – robert bristow-johnson Sep 08 '20 at 12:01
  • @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.

    – Cedron Dawg Sep 08 '20 at 12:12
  • where did the units "samples/cycle" get attached to "2"? – robert bristow-johnson Sep 08 '20 at 12:27
  • @robertbristow-johnson Is that not what defines the Nyquist frequency? What makes you think it should be dimensionless or unitless? – Cedron Dawg Sep 08 '20 at 12:32
  • no. 2 just means 2. what derives the Nyquist frequency is that real signals have symmetry about 0 and that any image of bandwidth, $B$, in positive frequency is mirrored in the negative frequency. then as a consequence of sampling (something i have been harping about for years) in order to guarantee perfect reconstruction, one must sample rapidly enough so that $$ k f_\mathrm{s} + B < (k+1) f_\mathrm{s} - B $$ that means $$ B < \frac{f_\mathrm{s}}{2} $$ in sampling, every two-sided image is translated (in frequency) by integer multiples of $f_\mathrm{s}$. – robert bristow-johnson Sep 08 '20 at 12:40
  • @robertbristow-johnson You may want to think this over some because you are wrong. The Nyquist frequency is independent of the nature of the signal. If you are talking about sampling every other point, your are still talking about a sampling rate and the proper units are (with time as the domain dimension, and seconds the unit) samples per second. When you are talking about a signal at the corresponding frequency, then the units are cycles per second, aka Hz. Consider the sweet spot at half Nyquist. This occurs at four samples per cycle. We got the chat prompt so I am done here. Sorry PK. – Cedron Dawg Sep 08 '20 at 13:04
  • nope. the Nyquist rate is a property of the signal (it is the bottom limit of the sample rate and is $2B$) and the Nyquist frequency is a property of the system (it is the top limit of frequency of any content of the signal being sampled and is $\frac{f_\mathrm{s}}{2}$). while there is some early lit (like the 1970s) that confuse and conflate the terms, but the terminology has been settled in the latter 20th century. – robert bristow-johnson Sep 08 '20 at 13:59
  • also, the spectrum, $X(f)$, of the continuous-time signal being sampled is shifted in frequency by integer multiples of $f_\mathrm{s}$ and then overlap-added. Is that amount of shifting on the $f$ axis measured in Hz or not? – robert bristow-johnson Sep 08 '20 at 14:02
  • @robertbristow-johnson Non-sequitor and irrelevant (see my followup for the other issues you need correction on.) $$ $$ Anyway... If the continuous FT, aka CTFT, is defined as: $$ X(f) = \int_{-\infty}^{+\infty} x(t) e^{-i 2 \pi f t} $$ And $t$ is measured in years, then the units of $f$ need to be Cycles Per Year.

    $$ 2 \pi \frac{\text{radians}}{\text{cycle}} \cdot f \frac{\text{cycles}}{\text{year}} \cdot t \text{ years} = 2 \pi f t \text{ radians} $$That's the main point of my answer. The application units are distinct from the FT units and you need to keep them straight.

    – Cedron Dawg Sep 08 '20 at 21:55
  • this is non sequitur?

    $$ x_\mathrm{s}(t) = \sum\limits_{n=-\infty}^{\infty} x(nT) \ T \delta(t-nT) $$

    $$ X_\mathrm{s}(f) = \sum\limits_{k=-\infty}^{\infty} X(f - k f_\mathrm{s}) $$

    where $f_\mathrm{s}=\frac1T$. ... so, may i add multiples of $f_\mathrm{s}$ to $f$?

    – robert bristow-johnson Sep 09 '20 at 01:27
  • @robertbristow-johnson Sure, but you should recognize in doing so your are employing an implicit conversion factor of 1 sample per cycle. I am truly done now. If you haven't understood this simple concept yet, or the importance of distinguishing inherent units of the FT from application units, you aren't likely going to. Sorry again Peter K. – Cedron Dawg Sep 09 '20 at 01:51
  • no. i am implying no conversion factor. $f_\mathrm{s}$ and $f$ are exactly the same dimensionally. the $2$ in $\frac{f_\mathrm{s}}{2}$ is dimensionless. – robert bristow-johnson Sep 09 '20 at 01:53
  • in fact, $\omega$ and $f$ are the same dimensionally, even if there is a conversion factor of $2 \pi$ between them. and $2 \pi$ is dimensionless, also. – robert bristow-johnson Sep 09 '20 at 01:55
  • both radians are dimensionless and cycles are dimensionless. – robert bristow-johnson Sep 09 '20 at 01:56