def lms_ic(r,M,mu,delta=<NUM_LIT:1>):
N = len(r)-<NUM_LIT:1>;<EOL>y = signal.lfilter(np.hstack((np.zeros(delta), np.array([<NUM_LIT:1>]))),<NUM_LIT:1>,r)<EOL>r_hat = np.zeros(N+<NUM_LIT:1>)<EOL>e = np.zeros(N+<NUM_LIT:1>)<EOL>ao = np.zeros(M+<NUM_LIT:1>)<EOL>z = np.zeros(M)<EOL>ym = np.zeros(M+<NUM_LIT:1>)<EOL>for k in range(N+<NUM_LIT:1>):<EOL><INDENT>r_hat[k],z = signal.lfilter(ao,np.array([<NUM_LIT:1>]),np.array([y[k]]),zi=z)<EOL>e[k] = r[k] - r_hat[k]<EOL>ao = ao + <NUM_LIT:2>*mu*e[k]*ym<EOL>ym = np.hstack((np.array([y[k]]), ym[:-<NUM_LIT:1>]))<EOL><DEDENT>F, Ao = signal.freqz(ao,<NUM_LIT:1>,<NUM_LIT>)<EOL>F/= (<NUM_LIT:2>*np.pi)<EOL>Ao = <NUM_LIT:20>*np.log10(abs(Ao))<EOL>return np.arange(<NUM_LIT:0>,N+<NUM_LIT:1>), r, r_hat, e, ao, F, Ao<EOL>
Least mean square (LMS) interference canceller adaptive filter.

A complete LMS adaptive filter simulation function for the case of
interference cancellation. Used in the digital filtering case study.

Parameters
----------
M : FIR Filter length (order M-1)
delta : Delay used to generate the reference signal
mu : LMS step-size
delta : decorrelation delay between input and FIR filter input

Returns
-------
n : ndarray Index vector
r : ndarray noisy (with interference) input signal
r_hat : ndarray filtered output (NB_hat[n])
e : ndarray error sequence (WB_hat[n])
ao : ndarray final value of weight vector
F : ndarray frequency response axis vector
Ao : ndarray frequency response of filter

Examples
----------
>>> # import a speech signal
>>> fs,s = from_wav('OSR_us_000_0030_8k.wav')
>>> # add interference at 1kHz and 1.5 kHz and
>>> # truncate to 5 seconds
>>> r = soi_snoi_gen(s,10,5*8000,[1000, 1500])
>>> # simulate with a 64 tap FIR and mu = 0.005
>>> n,r,r_hat,e,ao,F,Ao = lms_ic(r,64,0.005)