def lpc_ref(signal, order):
if signal.ndim > <NUM_LIT:1>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if order > signal.size:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if order > <NUM_LIT:0>:<EOL><INDENT>p = order + <NUM_LIT:1><EOL>r = np.zeros(p, '<STR_LIT>')<EOL>nx = np.min([p, signal.size])<EOL>x = np.correlate(signal, signal, '<STR_LIT>')<EOL>r[:nx] = x[signal.size - <NUM_LIT:1>:signal.size + order]<EOL>phi = np.dot(sp.linalg.inv(sp.linalg.toeplitz(r[:-<NUM_LIT:1>])), -r[<NUM_LIT:1>:])<EOL>return np.concatenate(([<NUM_LIT:1.>], phi))<EOL><DEDENT>else:<EOL><INDENT>return np.ones(<NUM_LIT:1>, dtype='<STR_LIT>')<EOL><DEDENT>
Compute the Linear Prediction Coefficients.

    Return the order + 1 LPC coefficients for the signal. c = lpc(x, k) will
    find the k+1 coefficients of a k order linear filter:

      xp[n] = -c[1] * x[n-2] - ... - c[k-1] * x[n-k-1]

    Such as the sum of the squared-error e[i] = xp[i] - x[i] is minimized.

    Parameters
    ----------
    signal: array_like
        input signal
    order : int
        LPC order (the output will have order + 1 items)

    Notes
    ----
    This is just for reference, as it is using the direct inversion of the
    toeplitz matrix, which is really slow