Power Spectral Density of Finite Signals

I have a basic confusion which I hope someone can help clear.

Say I have two signals:

1. $$S_1=\sin(2\pi t) \forall t\in[0,+\infty]$$
2. $$S_2=\sin(2\pi t) \forall t\in[2,5]$$, $$S_2=0$$ otherwise

Now let's say the signals are sampled from t=0 to t=10. What would be the correct power spectral density (PSD) at 1Hz, in discrete time?

How would the answer change if I modify the sampling time interval, assuming the sampled interval always encompasses at least a portion of t=2 to t=5?

This, hopefully, will help me understand how to get the correct PSD out of STFT.

Edited to remove the word window and replaced with interval to avoid confusion.

• Strictly speaking, the PSD is zero in both cases, because the PSD is averaged over all time, and your signals have finite energy. – MBaz Sep 4 '19 at 22:50
• @MBaz I agree, from a strict definition perspective. For all intent and purpose, however, we still work with PSD for finite signals. – JZYL Sep 4 '19 at 22:56
• In terms of a discrete power spectral density and getting an exact answer will depend on your sampling rate as that will effect the power per bin in your FFT, and depending on if your sampling rate is an integer multiple of 1 Hz or not will dictate the amount of spectral leakage in all the other bins. If you choose an integer multiple sampling rate, the signal will be centered on the 1 Hz bin and zero elsewhere, so the entire power of the signal will be in that bin at which point it is just a matter of properly scaling by the FFT length. – Dan Boschen Sep 4 '19 at 23:13
• @DanBoschen What should be the value of PSD, then, assuming the sampling rate is higher than the nyquist frequency? I'm looking for an absolute answer. – JZYL Sep 4 '19 at 23:17
• Hi Jimmy- It is important that it be an integer multiple otherwise you will see spectral leakage of that 1 Hz bin in every other bin of the FFT. Parseval's theorem dictates the power in time will be equal to the power in frequency-- that power will either reside completely in the 1 Hz bin IF you use a rectangular window (as I believe you suggest you are doing) AND you choose a sampling rate that is an integer multiple. Otherwise that power is smeared across all the other bins and will depend on the sampling rate you choose – Dan Boschen Sep 4 '19 at 23:24

Assuming the systems are sampled and we are looking for the discrete power spectral density, meaning a relative indication of the power level of signal versus frequency, and as suggested in the comments, the sampling rate is an integer multiple of the 1 Hz period, then each case can be described as follows:

For case 1, the Discrete Fourier Transform, if scaled by N, would result in the coefficients of Euler's Identity for a sine wave (this is explained simply by realizing that the Fourier Transform is the correlation to each exponential frequency term $$e^{j\omega t}$$ and as Euler's identity illuminates, the sine wave consists of positive and negative exponential frequency components.

$$sin(2\pi t) = -0.5j e^{2\pi t} + 0.5j e^{2\pi t}$$

The each of the two bins that have a non-zero magnitude ($$\pm 1$$ Hz) would have a complex value of +/-0.5j.

The power for each bin is found by complex conjugate multiplication or 0.25 in each case.

If the sampling rate is NOT an integer multiple of the frequency present (1 Hz in this case), spectral leakage would result such that the power would be distributed across all the other bins. The nature of this distribution is dependent on the actual sampling rate used.

For case 2 We are now multiplying our original signal in time by a smaller rectangular window. If you take the DFT of that window (all zeros from 0 to <2, ones from 2 to 5 and all zeros from >5 to 10, with the samples dictated by the sampling rate used) the result will be an aliased Sinc function; the specific result will depend on the actual sampling rate used. However since multiplication in time is equivalent to convolution in frequency, this specific aliased Sinc function result would convolve in frequency with the result from case 1 (as a circular convolution) to the provide the modified power spectral density.

• If $S_2$ is a real signal, where some harmonics will appear for some finite duration, does that mean PSD is not a very well defined concept for such signals? – JZYL Sep 5 '19 at 2:09
• $S_2$ is indeed a real signal (no if). Harmonics is a frequency domain term while duration is a time domain term and the DFT result is frequency not time. (However you can do a sliding DFT over time (STFFT) to mix the two (used to show the change of frequency with time at the expense of frequency resolution). For the former case of the DFT, the PSD is very well defined for $S_2$; each tone represents the average power for each frequency over the 0 to 10 second duration of your time domain signal, and each frequency tone is a single complex result (no sense of time, not changing). – Dan Boschen Sep 5 '19 at 2:20
• If you happen to be familiar with Double-Sideband Supressed Carrier (DSBSC) Amplitude Modulation and what the spectrum would look like when modulated by a sine wave, then we would have a great explanation that I believe would clear up a lot of this for you; but it would only be helpful if you were familiar with that first. – Dan Boschen Sep 5 '19 at 2:25
• Well that's the problem. Imagine if I sampled $S_2$ for 5 sec, instead of 10 sec. The resulting PSD peak value would be completely different. For a signal where I don't really know the duration of each harmonic, or how many and how far they are apart, how can I reliably use STFT to extract the absolute PSD at each time window? – JZYL Sep 5 '19 at 4:54
• I am not really sure what you are trying to say when you say the "duration of each harmonic"--- Do you mean your actual signal (not the cosine wave you are using as an example) has different harmonic frequencies, and for each of these frequency components they are changing with time in amplitude and each changing with a different duration? The actual PSD can only be determined for stationary signals (or cyclo-stationary) and when integrated over an infinite duration. – Dan Boschen Sep 5 '19 at 11:46