# A few questions about Slepian and generalized gaussian windows

I'm trying to add documentation for all the window functions in scipy.signal, and I'm stuck on the Slepian (same as DPSS?) and Generalized Gaussian windows, which I'd never heard of before.

There are two variables that are shape parameters of some type, p in the generalized Gaussian, and width in the Slepian. (sig appears to be sigma, the standard deviation.)

2 questions:

1. Instead of me reverse-engineering and guessing, can anyone explain what these variables are called and what they do?

2. Can you explain what these windows are useful for or where they are used?

def general_gaussian(M, p, sig, sym=True):
"""Return a window with a generalized Gaussian shape.

The Gaussian shape is defined as exp(-0.5*(x/sig)**(2*p)), the
half-power point is at (2*log(2)))**(1/(2*p)) * sig.

"""
if M < 1:
return np.array([])
if M == 1:
return np.ones(1, 'd')
odd = M % 2
if not sym and not odd:
M = M + 1
n = np.arange(0, M) - (M - 1.0) / 2.0
w = np.exp(-0.5 * (n / sig) ** (2 * p))
if not sym and not odd:
w = w[:-1]
return w

def slepian(M, width, sym=True):
"""Return the M-point slepian window.

"""
if (M * width > 27.38):
raise ValueError("Cannot reliably obtain slepian sequences for"
" M*width > 27.38.")
if M < 1:
return np.array([])
if M == 1:
return np.ones(1, 'd')
odd = M % 2
if not sym and not odd:
M = M + 1

twoF = width / 2.0
alpha = (M - 1) / 2.0
m = np.arange(0, M) - alpha
n = m[:, np.newaxis]
k = m[np.newaxis, :]
AF = twoF * special.sinc(twoF * (n - k))
[lam, vec] = linalg.eig(AF)
ind = np.argmax(abs(lam), axis=-1)
w = np.abs(vec[:, ind])
w = w / max(w)

if not sym and not odd:
w = w[:-1]
return w


Possible matches:

nipy's dpss_windows function uses NW, the "standardized half bandwidth corresponding to 2NW = BW*f0 = BW*N/dt but with dt taken as 1"

Matlab's dpss uses time_halfbandwidth Is this the same window? Is time_halfbandwidth the same thing as width?

This DPSS definition has $\omega_c$ "the desired main-lobe cut-off frequency in radians per second".

Generalized normal distribution has β (equal to twice p?) which is just called a shape parameter, with normal distribution for β = 1 and Laplace distribution for β = 2.

• FWIW I seem to remember that the DPSS is the same (or extremely similar to) a Kaiser window. Sorry thats all I got. :-) – Spacey Jun 5 '12 at 21:56
• @Mohammad: Kaiser window is an approximation of the DPSS, I think because the true DPSS is computationally expensive? en.wikipedia.org/wiki/Window_function#Kaiser_windows – endolith Jun 5 '12 at 22:55
• The DPSS is a window designed with constrained optimization, the constraint being the tolerable width of the main lobe. In effect it minimizes the energy outside of the main lobe (sidelobes) relative to a fixed main lobe energy. I have a a good book at home (out of town on business), so I can formulate a better answer worthy of posting when I review but that's the jist of it. – Bryan Jun 5 '12 at 23:46

The Slepian sequences are a family of functions. Most algorithms calculate 2*NW - 1 sequences at once for a given NW. N is the number of points in the sequence and W decides half the width of the mainlobe in the frequency domain for the Fourier transform of a given Slepian sequence. Typically you would use an NW of 3 or 4 for your signal processing.

In scipy, they are asking for the $N$ (m in the Python code) and the $W$ (width in the Python code) parameter separately while in matlab you input the time-bandwidth product $NW$ as a single parameter. This makes sense because you're typically calculating the Slepian sequences for a fixed window size, $N$.

If you are estimating the power spectrum of a stationary time series the DPSS are the set of windows you should use.

The generalized Gaussian function returns a Gaussian-like function raised to successively higher powers depending on the p parameter. As p is raised to successively higher powers the generalized Gaussian becomes narrower in the time domain. The nice property of a Gaussian is that it is it's own Fourier transform and it is the function that achieves the limit concerning the uncertainty principle. A Gaussian function may be useful if you would like to compute a short-time Fourier transform or spectrogram as an estimator for a time-varying power spectrum of a non-stationary time series.

• "The nice property of a Gaussian is that it is it's own Fourier transform" That's only true for p = 1, though, right? – endolith Oct 25 '12 at 15:47
• I'm not sure if the symmetry only holds for p=1. Maybe someone can work out the FT of a Generalized Gaussian (GG). Looking at the derivation of the FT of a Gaussian on Wolfram Mathworld mathworld.wolfram.com/FourierTransformGaussian.html . We can get rid of the imaginary part of the integral for the GG by the same argument. Though, I'm not sure how to evaluate $\int_{-\infty}^{\infty}e^{-ax^{2p}}cos(2\pi kx)dx$ – ncRubert Oct 25 '12 at 17:43

A single example to refute GG is its own transform. p = 0.5 gives an ordinary back-to-back exponential which has a transform of 2a/(s^2 + a^2).

As for DC block, it is. in the frequency domain Fdcx(w) = 1 - F(w). This will put the reject around DC with the near-DC in w becoming non-optimized in the now passband. So I would only use Dolph for this to make the wideband passband become equal ripple.

This is am impulse minus the original window function back in the time domain. How big for the impulse? it must force the sum of the sequence to zero.

Warning, the even length sequence forces a zero at the Nyquist frequency, so you will want to avoid that.

Fourier transform of GG is also a Gaussian. Using the convolution theorem, the FT(Gaussian \times Gaussian) = FT(Gaussian) \conv FT(Gaussian) = Gaussian \conv Gaussian = Gaussian. Hope that helped!