# Power Spectral Density as a single number confusion

I'm trying to recreate the results of a machine learning applied to the DSP classification in the article: link.

I have a signal (activity measurements from a smartwatch) per patient, so about 30 signals in total, quite long. For machine learning algorithm authors take traditional approach: extract statistical values about the signal, create columns (1 column per feature, 1 row per patient/signal) and plug this into a classifier. I'm confused about the spectral density used as feature.

Questions:

1. If I take PSD of a signal, I get another signal (time series) with values, not a single value, am I right? Therefore I would get not 1 column with spectral density feature per patient, but a full signal.

2. Suppose the article is imprecise (it is in other places) and authors made some "mental shortcut" while writing this. What else could they mean by "spectral density" feature? It should be 1 column, so 1 number extracted from each signal from patient. They mention it is in frequency domain, so PSD would be right, but it would not produce a single number.

• If you take the PSD of a signal I would expect that you would get a frequency series, unless you're talking about the PSD varying over time. May 12 at 22:14

## 2 Answers

Question 1: Yes you are correct, the power spectral density is the power distribution per unit frequency so is a continuous function of frequency.

Question 2: The single number as given can be an estimate of total power.

What they gave is completely incorrect starting with the formula as given:

$$P = lim_{T \rightarrow \infty}\frac{1}{T}\int_0^T|x(k)|^2dt$$

This is an attempt to provide a formula for the total power in the signal, as the time average of the energy of the signal (but where is t in the function for x?). I assume $$k$$ is a typo, but if it refers to an FFT bin, then as $$T \rightarrow \infty$$ discrete $$x(k)$$ would become a continuous function of time as $$x(t)$$ so that the above would properly represent the total power as:

$$P = lim_{T \rightarrow \infty}\frac{1}{T}\int_0^T|x(t)|^2dt$$

Note that the absolute value squared of the FFT bins, $$|x(k)|^2$$ can be used as an estimate of the power spectral density (see links below for conditions on this), with proper scaling to any units desired as the the relative power in each bin.

For further details on estimating PSD from the DFT, see:

Power spectral density vs. FFT bin magnitude

What is the difference between PSD and squared magnitude of frequency spectrum?

• So basically I have to calculate the total power from the signal, is that right? Do you have an idea how to do this / what functions to use programatically (I'm using Python, but it's pretty much identical to other standard software anyway)? Should I just sum the PSD results? May 13 at 6:15
• @qalis The total power is the variance plus the mean squared (which together is simply the sum of $x[n]^2/N$). If your units of the time domain signal are volts, and the implied resistance is normalized to 1 ohm, then the power will be in units of Watts. May 13 at 12:02
• Ok, I think I understand, thank you for all the help May 13 at 12:59

If someone is quoting one number for power spectral density, then the underlying assumption is most often that the noise is white, with a constant density across the entire spectrum (or at least across the entire spectrum that we care about -- do a web search on "the ultraviolet catastrophe" for the underlying physical reason that true white noise can't exist.)

• If I understand your answer correctly, then why does white noise assumption reduce the PSD to the single number? May 13 at 6:05
• White noise has a constant spectral density. That's the definition of white noise -- it's called "white" as an analogy to white light, which contains all colors of the spectrum, equally. May 13 at 15:05
• Right, that makes sense. How can I extract that single number then? Just sum squares of numbers and divide by their number, like Dan Boschen suggested? Also I'm not quite sure whether to sum the regular signal or in the frequency domain (after FFT). May 14 at 6:40
• There's different good ways to do this, but which is best for your application depends on the details. Easiest is if you have sampled-time data and you know that has only white noise -- then you can just measure the total power and divide by the sampling rate. This really is another StackExchange question of its own. I suggest you ask it, with a link to that article, and maybe a plot of one representative set of data. May 14 at 17:15