# Modified Periodogram function in MATLAB

Given below is a function written in MATLAB for computing the modified periodogram, taken from Hayes, Statistical Digital Signal Processing and Modeling

function Px = mper(x, win, n1, n2)

x = x(:);
if nargin == 2
n1 = 1; n2 = length(x);
end

N = n2 - n1 + 1;

switch win
case 1
w = rectwin(N);
case 2
w = hamming(N);
case 3
w = hanning(N);
case 4
w = bartlett(N);
case 5
w = blackman(N);
end;

xw = x(n1:n2).*w/norm(w);
Px = N*mypdg(xw);


Can anyone explain what is going on in second last line of the code xw = x(n1:n2).*w/norm(w)

Is dividing by norm necessary to compute xw?

Yes it's explicitly necessary to normalize the periodogram for non-rectangular windows. However I cannnot see the mypdg script in the book ?

From Monson Hayes's book Statistical Digital Signal Processing and Modeling , chapter 8 (spectrum estimation), Section 8.2.3 (modified periodogram), equations 8.49

$$\boxed{ \hat{P}_M(e^{j\omega}) = \frac{1}{NU} \left| \sum_{n=-\infty}^{\infty} x(n)~ w(n) ~ e^{-j\omega n} \right|^2 }$$

and 8.50

$$\boxed{ U = \frac{1}{N} \sum_{n=0}^{N-1} |w(n)|^2 }$$

define the scaling to correct the biasing of the periodogram estimate due to using nonrectangular windows.

Note that in the program norm is used during windowing stage before the FFT, so that after FFT and squaring, you will get norm square which is identical to $$U$$ above.

• I forgot to mention, mypdg is the periodogram function given in the book. I changed the name to mypdg – MaxFrost Oct 27 '18 at 8:36
• It would be great if you could provide the equation involving the use of norm or cite the explanation from the book? – MaxFrost Oct 27 '18 at 8:39