Modern Communication Principle A.3: Power Spectrum Estimation of Random Signal

Part of the content reference
[1] MATLAB analysis of classical power spectrum estimation based on Welch algorithm (http://www.doc88.com/p-3734310145747.html)

  Power spectrum estimation is to estimate the power spectrum of a signal using finite length data, which is divided into classical spectrum estimation and modern spectrum estimation. Below we start with the periodogram method in classical spectrum estimation, and further discuss its improved Welch algorithm.

1. Periodogram method

  The periodogram method is obtained by Fourier transform, so it is also called the direct method. If we have discrete NNN- point random sequencex N (n), n = 0, 1,…, N − 1 x_N(n),n=0,1,\ldots,N-1xN(n),n=0,1,,N1 , you can get itsNNN- point Discrete Fourier Transform (DFT)XN (f) X_N(f)XN( f ) , we can further obtain the pairx (n) x(n)x ( n ) true power spectral densityPX (f) P_X(f)PX(f)的估计:
(1) P ^ X ( f ) = 1 N ∣ X N ( f ) ∣ 2 = 1 N ∣ ∑ n = 0 N − 1 x ( n ) e − j 2 π f n ∣ 2 . \tag{1} \hat P_X(f)=\frac{1}{N}|X_N(f)|^2=\frac{1}{N}{\Large |}\sum_{n=0}^{N-1}x(n)e^{-j2\pi fn}{\Large |}^2. P^X(f)=N1XN(f)2=N1n=0N1x(n)ej2πfn2.( 1 ) Since the direct method has no statistical average, the accuracy is poor and the variance performance is not good. In addition, when the data lengthNNWhen N is large, the spectrum curve shows large fluctuations; the data length isNNWhen N is small, the resolution of the spectrum is not good.

In the program given below, first generate a rectangular pulse signal as shown in Figure 1 (a), and then use the periodogram method to observe its power spectral density. We use two methods of calling the fft function in MATLAB and calculating according to (1) programming to estimate the power spectrum. The results are shown in Figure 1 (b) and © respectively.

%------------------
%系统参数设置
%-----------------
T_start=0;%开始时间
T_stop=10;%截止时间
T=T_stop-T_start;%仿真持续时间
T_sample=1/10;%采样间隔
f_sample=1/T_sample; % 采样速率
N_sample=T/T_sample;% 采样点数

%-----------------
%产生矩形脉冲
%-----------------
A=1;
n=1:N_sample;
Tg=1;
N_Tg=floor(Tg/T_sample);
x=zeros(1,N_sample);
x(1:N_Tg+1)=A*ones(1,N_Tg+1);
subplot(2,2,[1 2])
plot(n*T_sample,x);

%-------------------------
%功率谱密度估计
%-------------------------
%periodogram
%调用MATLAB中的fft函数
PSD_X1=abs(fft(x)).^2/N_sample;
subplot(2,2,3)
plot(n/N_sample*f_sample,PSD_X1)
%按照公式(1)计算
temp1=[1:N_sample]'*[1:N_sample];
temp2=exp(-j*2*pi/N_sample*temp1);
x_matrix=repmat(x,[N_sample,1]);
PSD_X2=(abs(sum(x_matrix.*temp2,2)).^2/N_sample)';
subplot(2,2,4)
plot(n/N_sample*f_sample,PSD_X2)

Insert picture description here

figure 1

2. Improved algorithm of periodogram method

  In order to improve the periodogram method, an appropriate window function can be used to smooth the spectrum. The idea is that NNDiscrete sequence of N pointsx N (n), n = 0, 1,…, N x_N(n),n=0,1,\ldots,NxN(n),n=0,1,,N , divided intoLLL segment, the length of each segment isMMM , find the power spectral density of each segment separately, and then average them.
  If a rectangular window is added to the segmented data, thellthl段数据变为
x N l ( n ) = x N [ n + ( l − 1 ) M ] d 1 [ n + ( l − 1 ) M ] ,   n = 0 , 1 , … , M − 1 , l = 1 , 2 , … , L , x^l_N(n)=x_N[n+(l-1)M]d_1[n+(l-1)M],\ n=0,1,\ldots,M-1,l=1,2,\ldots,L, xNl(n)=xN[n+(l1)M]d1[n+(l1)M], n=0,1,,M1,l=1,2,,L , whered 1 (n) d_1(n)d1( n ) indicates that the rectangular window is innnThe coefficient of n points. Therefore, the corrected average periodogram can be obtained as
P ‾ (f) = 1 ML ∑ l = 1 L ∣ ∑ n = 0 M − 1 x N l (n) e − j 2 π nf ∣ 2. \Overline {P}(f)=\frac{1}{ML}\sum_{l=1}^{L}{\Large |}\sum_{n=0}^{M-1}x_N^l(n) e^{-j2\pi nf}{\Large |}^2.P(f)=ML1l=1Ln=0M1xNl( n ) ej2πnf2 .This method is called Bartlett's method, it is possible to improve the dispersion characteristic of the direct method. So how many segments should the signal be divided into? What is the length of each section? Obviously, the more points in each segment, the higher the frequency domain resolution. If the entire signal is not segmented, the frequency domain resolution is the highest. In addition, if a signal itself does not have too many points, if there is overlap between different segments, it is obviously higher than the time-frequency domain resolution without overlap. This leads to the Welch method.
  The Welch method is an improvement of the Bartlett method. The Welch method is forx N (n) x_N(n)xN( n ) When segmenting, each segment of data is allowed to have partial overlap (overlaping), and the data window of each segment may not use rectangular windows, that is,
P ‾ (f) = 1 MU ∑ l = 1 L ∣ ∑ n = 0 M − 1 x N l (n) d 2 (n) e − j 2 π nf ∣ 2. \Overline{P}(f)=\frac{1}{MU}\sum_{l=1}^{L }{\Large |}\sum_{n=0}^{M-1}x_N^l(n)d_2(n)e^{-j2\pi nf}{\Large |}^2.P(f)=M U1l=1Ln=0M1xNl(n)d2( n ) ej2πnf2 .Hered 2 (n) d_2 (nd2( n ) represents the data window. Since the Welch method allows the partitions to overlap, the number of segmentsLL isincreasedL , so the estimated variance characteristics can be better improved. However, overlapping data will reduce the irrelevance of each segment. In addition, choosing a suitable window function can reduce spectrum leakage and improve resolution.

3. Application of pwelch function in MATLAB to realize power spectrum estimation

  We use the function pwelch in MATLAB to observe the power spectral density of white noise. You can find related instructions and examples by entering pwelch in the help file. Here is a list of some usages as follows:

pxx=pwelch(x) 

[Explanation] Return the PSD estimate pxx of the input signal x. If x is a real value, then pxx is a unilateral PSD estimate; if x is a complex value, then pxx is a bilateral PSD estimate. The default number of points for each fft is 256, so a PSD result of 129 points can be obtained.

pxx = pwelch(x,window,noverlap,nfft) 

[Explanation] Here,'window' means the length of the segmented data processed each time;'noverlap' refers to the length of the overlap between two adjacent pieces of data; nfft is the number of discrete Fourier transform points used in PSD estimation. By default, nfft is the larger of the smallest power of 2 and 256 that is not less than the length of the segment data. (It's a bit confusing. For example, if the segment data length is 100, the smallest power of 2 that is not less than it is 128, and nfft is 256; if the segment data length is 500, nfft is 512). Obviously we will make nfft as large as possible, so that the frequency resolution will be higher. Obviously, the number of PSD points obtained at this time is nfft/2+1, and the frequency resolution is f_sample/nfft.

 pxx = pwelch(x,window,noverlap,nfft,'centered')

[Explanation] By adding the'centered' parameter, we can generate a positive-negative symmetrical PSD centered at zero frequency (DC), and the number of PSD points is equal to nfft.

Below we still take the above rectangular pulse signal as an example to see how to use the pwelch function to estimate its power spectral density. The system parameter setting and waveform generation code are shown in the above code segment, and will not be repeated here. The obtained power spectral density is shown in Figure 2.

%------------------------
%Welch方法
%------------------------
PSD_X3=pwelch(x,500,100,'centered')*N_sample;
figure(2)
N_fft=max(256,length(PSD_X3));
xx=[-N_fft/2+1:N_fft/2]*(f_sample/N_fft);
plot(xx,PSD_X3)

Insert picture description here

figure 2

Guess you like

Origin blog.csdn.net/tanghonghanhaoli/article/details/100825259