import numpy as np

def welch(signal, window):
    '''
    Divide the signal into frames of length L, overlapping by L/2.
    Compute the periodogram of each, and average them.

    @param:
    signal (T,) - an array-like object containing the input signal
    window (L,) - the window to use on each frame

    @return:
    frames (int(2T/L-1),L) - frames of speech
    pgram (int(2T/L-1),L) - magnitude-squared FFT of each frame
    spectrum (L,) - average periodogram
    '''
    raise NotImplementedError("You need to write this!")

def lpc_roots(coefficients, sample_rate):
    '''
    Calculate the frequencies and bandwidths of the LPC poles, in Hertz.

    @param:
    coefficients (order+1,) - coefficients of denominator polynomial of autoregressive spectrum
    sample_rate (1,) - sampling rate of the signal, in samples/second

    @return:
    frequency (order,) - pole frequencies, in Hertz
    bandwidth (order,) - bandwidths, in Hertz
    '''
    raise NotImplementedError("You need to write this!")

def rls(signal, P_init, memory_weight):
    '''
    Calculate the RLS predictor coefficients for each sample of the signal,
    starting from sample n=order.

    @param:
    signal (T,) = signal to be predicted from its own past samples
    P_init (order,order) = initial precision matrix before recursion begins
    memory_weight (1,) = lambda: past autocorrelation is downweighted by this factor

    @return:
    predictor (T-order,order) = RLS predictor weights
      - signal[n+order] is predicted by predictor[n,:]@signal[n:n+order]
    '''
    raise NotImplementedError("You need to write this!")
