def periodogram(x, window=None, window_len=7):
    """
    Computes the periodogram

    .. math::

        I(w) = (1 / n) | sum_{t=0}^{n-1} x_t e^{itw} |^2

    at the Fourier frequences w_j := 2 pi j / n, j = 0, ..., n - 1,
    using the fast Fourier transform.  Only the frequences w_j in [0,
    pi] and corresponding values I(w_j) are returned.  If a window type
    is given then smoothing is performed.

    Parameters
    ----------
    x : array_like(float)
        A flat NumPy array containing the data to smooth
    window_len : scalar(int), optional(default=7)
        An odd integer giving the length of the window.  Defaults to 7.
    window : string
        A string giving the window type. Possible values are 'flat',
        'hanning', 'hamming', 'bartlett' or 'blackman'

    Returns
    -------
    w : array_like(float)
        Fourier frequences at which periodogram is evaluated
    I_w : array_like(float)
        Values of periodogram at the Fourier frequences

    """
    n = len(x)
    I_w = np.abs(fft(x))**2 / n
    w = 2 * np.pi * np.arange(n) / n  # Fourier frequencies
    w, I_w = w[:int(n/2)+1], I_w[:int(n/2)+1]  # Take only values on [0, pi]
    if window:
        I_w = smooth(I_w, window_len=window_len, window=window)
    return w, I_w
dataset/ETHPy150Open QuantEcon/QuantEcon.py/quantecon/estspec.py/periodogram/original