Wave Walker DSP

DSP Algorithms for RF Systems

Trending

Buy the Book!

DSP for Beginners: Simple Explanations for Complex Numbers! The second edition includes a new chapter on complex sinusoids.

What is Power Spectral Density (PSD)?
February 1, 2024

Table of Contents

Introduction

This blog describes the power spectral density (PSD) mathematically, algorithms for estimating the PSD, and real world challenges in PSD estimation. The analysis in this blog ignores the use of a windowing function for mathematical simplicity, but a windowing function should almost always be used in spectral analysis.

Check out these blogs:

Power Spectral Density (PSD) Mathematically

The instantaneous power of a signal x[n] is defined as

(1)   \begin{equation*}P_{x}[n] = |x[n]|^2 = x_{R}^2 + x_{I}^2\end{equation*}

where

(2)   \begin{equation*}x_{R} = \text{RE}\left( x[n] \right),\end{equation*}

(3)   \begin{equation*}x_{I} = \text{IM}\left( x[n] \right).\end{equation*}

The DFT of x[n] is defined by

(4)   \begin{equation*}X[k] = \sum_{n=0}^{N-1} x[n]^{-j2\pi kn/N}\end{equation*}

where N is the length of x[n] and the size of the DFT. The average power in the frequency domain, or power spectral density (PSD), is represented similarly to (1) [Lyons2011, p.63, p.140],

(5)   \begin{equation*}P_{X}[k] = |X[k]|^2 = X_{R}^2 + X_{I}^2.\end{equation*}

The PSD represents the average power at each frequency bin k. Often the PSD is represented in dB,

(6)   \begin{equation*}\begin{split}P_{X,dB}[k] & = 10\text{log}_{10} \left( |X[k]|^2 \right) \\& = 20\text{log}_{10} \left( |X[k]| \right).\end{split}\end{equation*}

When x[n] is known the PSD can be derived mathematically by finding X[k] followed by P_{X}[k], however it is a challenge when receiving unknown signals in a real world environment when a solution cannot be found analytically. In this case the PSD has to be estimated from the received signal.

Algorithms for PSD Estimation

A common problem in spectral analysis is being able to estimate the power spectral density P_{X}[k] using a received signal. The two foundational tools for spectral estimation are:

Both the Bartlett and Daniell methods produce estimates of the PSD which may be referred to as periodograms [Oppenheim1999, p. 730]. Welch’s method is commonly used in spectral estimation but is a variation on the Bartlett method.

The objective is to produce the best PSD estimate with a finite data set. The following examples consider an input data length of 24 samples.

Bartlett's Method

Bartlett’s method computes several discrete Fourier transforms (DFT) over time with a smaller DFT size than the total data length and averages the results. For an example input sequence of 24 samples, consider the case in which an 8-point DFT is computed over each time segment and 3 DFTs are averaged together. The first DFT X_{0}[k] would be computed over time segment x[0], x[1], x[2], ~\dots, x[6], x[7] such that

(7)   \begin{equation*}X_{0}[k] = \mathcal{F} \{ x[0], x[1], x[2], ~\dots, x[6], x[7] \},\end{equation*}

followed by the DFT over non-overlapping time series

(8)   \begin{equation*}X_{1}[k] = \mathcal{F} \{ x[8], x[9], x[10], ~\dots, x[14], x[15] \},\end{equation*}

(9)   \begin{equation*}X_{2}[k] = \mathcal{F} \{ x[16], x[17], x[18], ~\dots, x[22], x[23] \}.\end{equation*}

The power for each DFT would be computed according to (5),

(10)   \begin{equation*}P_{X_{0}}[k] = \left|X_{0}[k]\right|^2,\end{equation*}

(11)   \begin{equation*}P_{X_{1}}[k] = \left|X_{1}[k] \right|^2,\end{equation*}

(12)   \begin{equation*}P_{X_{2}}[k] = \left| X_{2}[k] \right|^2,\end{equation*}

and averaged such that Bartlett’s PSD estimate is

(13)   \begin{equation*}\hat{S}_{X_{0,1,2}}[k] = \frac{1}{3} \left( P_{X_{0}}[k] + P_{X_{1}}[k]  + P_{X_{2}}[k]  \right).\end{equation*}

Equation (13) can be generalized for M DFTs according to [Gardner1988, p.193],

(14)   \begin{equation*}\hat{S}_{X_{0,M-1}}}[k] = \frac{1}{M} \sum_{m=0}^{M-1} P_{X_{m}}[k] \\\end{equation*}

or equivalently,

(15)   \begin{equation*}\hat{S}_{X_{0,M-1}}}[k] = \frac{1}{M} \sum_{m}^{M-1} |X_{m}[k]|^2.\end{equation*}

Note that many textbook and online references average the magnitude squared as in (15). Averaging the power in dB is given by

(16)   \begin{equation*}\hat{S}_{X_{0,M-1},dB}}[k] = \frac{1}{M} \sum_{m=0}^{M-1} 20\text{log}_{10}\left( |X_{m}[k] \right).\end{equation*}

Experimentally it would seem that averaging in dB (16) produces a smoother spectral response due to the compression in dB as the averages are not distorted by outliers as they would be in the linear domain. If you would be interested in this explanation please comment below and I will write a blog post about it.

Welch's Method

Welch’s method is a specific implementation of Bartlett’s method which uses 50% overlapping time series. Continuing with the example in (7) the DFTs are:

(17)   \begin{equation*}X_{0}[k] = \mathcal{F} \{ x[0], x[1], x[2], ~\dots, x[6], x[7] \},\end{equation*}

(18)   \begin{equation*}X_{1}[k] = \mathcal{F} \{ x[4], x[5], x[6], ~\dots, x[10], x[11] \},\end{equation*}

(19)   \begin{equation*}X_{2}[k] = \mathcal{F} \{ x[8], x[9], x[10], ~\dots, x[14], x[15] \},\end{equation*}

(20)   \begin{equation*}X_{3}[k] = \mathcal{F} \{ x[12], x[13], x[14], ~\dots, x[18], x[19] \},\end{equation*}

(21)   \begin{equation*}X_{4}[k] = \mathcal{F} \{ x[16], x[17], x[18], ~\dots, x[22], x[23] \}.\end{equation*}

Due to the overlapping time-windows in (17) – (21) there are more DFTs to average which will require more computation but will also produce a smoother spectral response. Welch’s method is completed by averaging the power of the DFTs according to (16).

Welch’s method refers to exactly 50% overlap between successive time segments, however the amount of overlap can be varied based on the trade-offs between computation and desire for smoothness in the PSD estimate.

Daniell's Method

Where Bartlett’s method computes a smaller DFT and averages them over time, Daniell’s method takes a larger DFT and averages the frequency bins. For the same data length of N=24 samples, consider a 24-point DFT,

(22)   \begin{equation*}X[k] = \mathcal{F}\{ x[0], x[1], x[2], ~\dots, x[22], x[23] \}\end{equation*}

whose power is

(23)   \begin{equation*}P_{X[k]} = |X[k]|^2.\end{equation*}

Daniell’s method averages the frequency bins in (23) using a convolution according to [Gardner1988, p.195]

(24)   \begin{equation*}\hat{S}_{X[k]} = P_{X[k]} * g[k]\end{equation*}

where g[k] is a smoothing filter. The averaging can also be computed in dB according to

(25)   \begin{equation*}\hat{S}_{X[k],dB} = P_{X,dB}[k]} * g[k].\end{equation*}

An example of g[k] is a moving average filter with length L,

(26)   \begin{equation*}g[k] =\begin{cases}1/L, & 0 \le k \le L-1, \\0, & \text{otherwise}.\end{cases}\end{equation*}

PSD estimates (24) and (25) are computed through the convolution of an N-point DFT and smoothing filter g[k] with length L, producing an output of length N+L-1. The additional L-1 samples are invalid because they are outside the valid bounds of the PSD estimate only exist as a byproduct of the convolution. One method to handle the additional samples is to:

  • discard L-1 samples from the left side of the convolution (to remove all transients from the filtering)
  • extend the left most sample (L-1)/2 times
  • discard L-1 samples from the right side of the convolution
  • extend the right most sample (L-1)/2 times

If you have a better way to handle the transition areas with Daniell’s method please drop a comment below!

Conclusion

The Bartlett and Daniell methods are the two algorithms for estimating the power spectral density (PSD) of a given set of samples. Bartlett’s method computes a larger number of DFTs and averages them over time, whereas Daniell’s method computes a larger DFT but applies a smoothing filter over the frequency bins. Welch’s algorithm is a specific implementation of Bartlett’s method which includes the averaging of DFTs coming from 50% overlapping time segments. The analysis in this blog ignores the use of a windowing function for mathematical simplicity, but a windowing function should almost always be used in spectral analysis.

Check out these blogs:

Leave a Reply

God, the Lord, is my strength; He makes my feet like the deer's; He makes me tread on my high places. Habakkuk 3:19
For everything there is a season, and a time for every matter under heaven. A time to cast away stones, and a time to gather stones together. A time to embrace, and a time to refrain from embracing. Ecclesiastes 3:1,5
The earth was without form and void, and darkness was over the face of the deep. And the Spirit of God was hovering over the face of the waters. Genesis 1:2
Behold, I am toward God as you are; I too was pinched off from a piece of clay. Job 33:6
Enter His gates with thanksgiving, and His courts with praise! Give thanks to Him; bless His name! Psalm 100:4
Lift up your hands to the holy place and bless the Lord! Psalm 134:2
Blessed is the man who trusts in the Lord, whose trust is the Lord. He is like a tree planted by water, that sends out its roots by the stream, and does not fear when heat comes, for its leaves remain green, and is not anxious in the year of drought, for it does not cease to bear fruit. Jeremiah 17:7-8
He said to him, “You shall love the Lord your God with all your heart and with all your soul and with all your mind. This is the great and first commandment. And a second is like it: You shall love your neighbor as yourself. On these two commandments depend all the Law and the Prophets.” Matthew 22:37-39
Then He said to me, “Prophesy over these bones, and say to them, O dry bones, hear the word of the Lord. Thus says the Lord God to these bones: Behold, I will cause breath to enter you, and you shall live." Ezekiel 37:4-5
Riches do not profit in the day of wrath, but righteousness delivers from death. Proverbs 11:4
The angel of the Lord appeared to him in a flame of fire out of the midst of a bush. He looked, and behold, the bush was burning, yet it was not consumed. And Moses said, “I will turn aside to see this great sight, why the bush is not burned.” When the Lord saw that he turned aside to see, God called to him out of the bush, “Moses, Moses!” And he said, “Here I am.” Exodus 3:2-3
Daniel answered and said: “Blessed be the name of God forever and ever, to whom belong wisdom and might. He changes times and seasons; He removes kings and sets up kings; He gives wisdom to the wise and knowledge to those who have understanding." Daniel 2:20-21
Now the Lord is the Spirit, and where the Spirit of the Lord is, there is freedom. 2 Corinthians 3:17
Previous slide
Next slide

This website participates in the Amazon Associates program. As an Amazon Associate I earn from qualifying purchases.

© 2021-2024 Wave Walker DSP