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:


Instead of me reverse-engineering and guessing, can anyone explain what these variables are called and what they do?
Can you explain what these windows are useful for or where they are used?


&nbsp;

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 &lt; 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 &gt; 27.38):
        raise ValueError("Cannot reliably obtain slepian sequences for"
              " M*width &gt; 27.38.")
    if M &lt; 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.
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.