I have several browser tabs open indicating this question is "similar to" but I still don't get it. Suppose I sample a simple cosine function having frequency 40 Hz, i.e., $x(t)=a\cos(2\pi\cdot 40 t)$, for three seconds at a sampling rate of $f_s=100$ Hz. Then I have $N=300$ data points with sampling period $\Delta t=.01$. This yields the sequence $x(k)= a\cos(2\pi i \cdot 40 k \Delta t)$. Using the guidance I was provided here, the discrete Fourier transform is given by

\begin{align*} X(n) &= \sum_{k=0}^{N-1} \frac{a}{2} \left( e^{2\pi i \cdot 40 k \Delta t} + e^{-2\pi i \cdot 40 k \Delta t}\right) e^{-2\pi i \frac{n}{N}k} \\ &= \frac{a}{2} \sum_{k=0}^{299} \left( e^{2\pi i \cdot (.4-n/300)k}+e^{-2\pi i \cdot (.4 + n/300)k}\right). \end{align*}

The terms within the parentheses sum to zero unless $n=120$, in which case the sum is $\frac{aN}{2}$. Hence, for all practical purposes, since $n=120$ corresponds to a frequency of 40 Hz, I can express this as as \begin{equation*} X(f)=\frac{aN}{2}\delta (f-40). \end{equation*}

Now, the power spectrum, as I understand it is simply the squared magnitude of this quantity, $|X(f)|^2=\frac{a^2N^2}{4}\delta(f-40)$.

When I plot the periodogram using the periodogram function from scipy.signal by entering


I obtain the graph of the power spectral density (PSD) shown below:

enter image description here

Here I've set $a=5$. The magnitude at f[120]=40 is Pxx[120]=37.5, which in fact can be obtained by simplifying $$\frac{a^2}{4}\frac{2|X(f)|^2}{f_s/N}.$$ The extra 2 in the numerator I believe stems from the fact it's a one-sided plot and $f_s/N$ represents a frequency bin width, $1/3$ in this particular example.

My questions:

  1. What does this picture really tell me, for such a simple signal, which I don't already see from plotting the power spectrum and scaling by an appropriate factor?
  2. If my signal is measured in volts, then I understand the PSD has units of volts-squared per Hz. Can I "integrate" this to obtain "something" having units of volts-squared, and what does that "something" represent? Total power?
  3. If I can "integrate" it, do I merely assume the integral of the dirac delta is just one?
  4. Does the PSD even really make sense for such an example, or is its meaning more relevant for signals whose frequencies are spread out over bands and not concentrated at a discrete set of values, such as those I might observe in an EEG?

1 Answer 1


$X(f)=\frac{aN}{2}\delta (f-40).$

Nope. You have two frequencies: +120Hz and -120Hz so you would get

$$X[k]=\frac{aN}{2}\delta [k-120] + \frac{aN}{2}\delta [k+120]$$

The equation you wrote would be correct (sort of) for a complex exponential but not for a cosine. It's also good practice to clearly distinguish between discrete and continuous notations. Personally I use square brackets and indices (n,k, etc) for discrete and round brackets and time/frequency (t,f) for continuous variables. For example $\delta(t)$ means the dirac delta whereas the discrete version $\delta[n]$ just means "1 for $n=0$, 0 everywhere else".

Discrete signals in time and frequency are related by the Discrete Fourier Transform (DFT) NOT the continuous (or "normal") Fourier Transform. This is often defined as as

$$X[k] = \sum_{n=0}^{N-1}x[n]e^{-j2\pi\frac{kn}{N}}, \frac{1}{N}X[n] = \sum_{n=0}^{N-1}X[k]e^{j2\pi\frac{nk}{N}}$$

There are multiple scaling conventions which are used for different purpose. If you want to maintain Perceval's Theorem you need to use symmetric scaling

$$X[k] = \frac{1}{\sqrt{N}}\sum_{n=0}^{N-1}x[n]e^{-j2\pi\frac{kn}{N}}, \frac{1}{\sqrt{N}}X[n] = \sum_{n=0}^{N-1}X[k]e^{j2\pi\frac{nk}{N}}$$

In this case energy is maintained and you have

$$\sum_{n=0}^{N-1}|x[n]|^2 = \sum_{k=0}^{N-1}|X[k]|^2$$

The left side is the energy on the time domain and the right side is the energy in the frequency domain which is indeed the sum (not the integral) over the discrete PSD. If you divide both sides by $N$ you get the power.

Let's look at your specific case of

$$x[n] = 5\cos(2\pi n \frac{40}{100})$$

The energy in the time domain is $E = N\cdot x_{rms}^2 = 3750$ since $x_{rms}^2 = x_{max}^2/2$ for a sine wave. The energy in the frequency domain must be the same (provided we use symmetric DFT scaling$ but the entire energy is contained in only two frequency bins (120 and -120 or +180), so the PSD must in these bins must be 1875 each. The magnitude at this frequencies would be root of that or 43.3... which is exactly what you get if you take the FFT of your signal and compute the magnitude.

If my signal is measured in volts, then I understand the PSD has units of volts-squared per Hz

Not exactly. In contrast the the continuous Fourier Transform, the DFT does not change units. If your signal is volts, then the DFT will also be in Volts and the PSD will be in Volts squared. You can choose to normalize the PSD to the frequency bin width and the normalized PSD has indeed units of $V^2/Hz$.

You are getting 37.5 because periodogram by default normalizes to density using the sampling rate and because it appears to combine the energies at positive and negative frequencies in the same bin.

  • $\begingroup$ Thanks for your response. Are there then two ways to define the PSD depending upon one wishes to normalize the magnitude-squared DFT by bin width? $\endgroup$
    – fishbacp
    Nov 5, 2022 at 11:07
  • 1
    $\begingroup$ Yes. There are multiple scaling conventions for the DFT and the PSD. Which one to choose depends on the application. $\endgroup$
    – Hilmar
    Nov 5, 2022 at 13:14

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.