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
f,Pxx=periodogram(x,100,nfft=300)
,
I obtain the graph of the power spectral density (PSD) shown below:
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:
- 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?
- 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?
- If I can "integrate" it, do I merely assume the integral of the dirac delta is just one?
- 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?