DSPRelated.com
Forums

nlms algorithm

Started by abhi5491 February 22, 2016
can any one tell me which type of nlms code is this?
It is in book " C Algorithms for Real-Time DSP by Paul Embree"
/*
function lms(x,d,b,l,mu,alpha)

Implements NLMS Algorithm b(k+1)=b(k)+2*mu*e*x(k)/((l+1)*sig)

x      = input data
d      = desired signal
b[0:l] = Adaptive coefficients of lth order fir filter
l      = order of filter (> 1)
mu     = Convergence parameter (0.0 to 1.0)
alpha  = Forgetting factor   sig(k)=alpha*(x(k)**2)+(1-alpha)*sig(k-1)
         (>= 0.0 and < 1.0)

returns the filter output
*/

float lms(float x,float d,float *b,int l,
                  float mu,float alpha)
{
    int ll;
    float e,mu_e,/*lms_const,*/y; /* JG */
    static float px[51];      /* max L = 50 */
    static float sigma = 2.0; /* start at 2 and update internally */

    px[0]=x;

/* calculate filter output */
    y=b[0]*px[0];
#ifdef DEBUG
    printf("l=%dn",l);
#endif
    for(ll = 1 ; ll <= l ; ll++)
        y=y+b[ll]*px[ll];

/* error signal */
    e=d-y;

/* update sigma */
    sigma=alpha*(px[0]*px[0])+(1-alpha)*sigma;
    mu_e=mu*e/sigma;

/* update coefficients */
    for(ll = 0 ; ll <= l ; ll++)
        b[ll]=b[ll]+mu_e*px[ll];
/* update history */
    for(ll = l ; ll >= 1 ; ll--)
        px[ll]=px[ll-1];

    return(y);
}



Is it a different type of nlms algorithm? It is different from book Simon
Haykin.Can any one please help me out.And does the forgetting factor in
this program mean the leakage factor in NLMS algorithm???
---------------------------------------
Posted through http://www.DSPRelated.com
The leakage factor here is applied to the power estimation not the coefficient update. So it's equivalent to applying a 1st-order IIR low pass filter to the square of the signal. This is the lowest-mips approach. The more standard textbook approach is to compute the sum of squares of the signal that is stored in the filter history buffer, divided by the filter length. 

Bob
One more point; most DSP programmers would use a circular buffer rather than shift the entire signal buffer. This assumes your hardware supports circular buffers (modulo addressing mode). Often you can create your own circular buffer by coding, but it represents an overhead which may or may not be worth the trouble depending on your filter length. 

Bob
On Monday, February 22, 2016 at 12:18:03 AM UTC-6, abhi5491 wrote:
> can any one tell me which type of nlms code is this? > It is in book " C Algorithms for Real-Time DSP by Paul Embree" > /* > function lms(x,d,b,l,mu,alpha) > > Implements NLMS Algorithm b(k+1)=b(k)+2*mu*e*x(k)/((l+1)*sig) > > x = input data > d = desired signal > b[0:l] = Adaptive coefficients of lth order fir filter > l = order of filter (> 1) > mu = Convergence parameter (0.0 to 1.0) > alpha = Forgetting factor sig(k)=alpha*(x(k)**2)+(1-alpha)*sig(k-1) > (>= 0.0 and < 1.0) > > returns the filter output > */ > > float lms(float x,float d,float *b,int l, > float mu,float alpha) > { > int ll; > float e,mu_e,/*lms_const,*/y; /* JG */ > static float px[51]; /* max L = 50 */ > static float sigma = 2.0; /* start at 2 and update internally */ > > px[0]=x; > > /* calculate filter output */ > y=b[0]*px[0]; > #ifdef DEBUG > printf("l=%dn",l); > #endif > for(ll = 1 ; ll <= l ; ll++) > y=y+b[ll]*px[ll]; > > /* error signal */ > e=d-y; > > /* update sigma */ > sigma=alpha*(px[0]*px[0])+(1-alpha)*sigma; > mu_e=mu*e/sigma; > > /* update coefficients */ > for(ll = 0 ; ll <= l ; ll++) > b[ll]=b[ll]+mu_e*px[ll]; > /* update history */ > for(ll = l ; ll >= 1 ; ll--) > px[ll]=px[ll-1]; > > return(y); > } > > > > Is it a different type of nlms algorithm? It is different from book Simon > Haykin.Can any one please help me out.And does the forgetting factor in > this program mean the leakage factor in NLMS algorithm??? > --------------------------------------- > Posted through http://www.DSPRelated.com
Where can I get detailed explanation of this type of algorithm.Is this variable step size NLMS algorithm.Can anyone suggest me a book /link for all types of NLMS Algorithm.I want to know Variable Step size nlms algo.Thanks in advance