I'm running into difficulty implementing the NLMS algorithm, w.r.t. step size.. I'm using Matlab to model the algorithm, and here is the core of the calculation to update the tap weights: nlms_coeff = af_parms.mu/pwr(i) * en; af_parms.state.weights = af_parms.state.weights + xn .* nlms_coeff; - pwr(i) is the calculated signal power for sample 'i' - xn is the data samples used for 'L' taps (1024 in this case). - I am using step-size of 0.2 Now, the problem arises when I change how pwr(i) is calculated. If I use pwr(i) = xn' * xn , which is essentially the sum of squared elements, the algorithm works perfectly. I want to use a power estimate however, described in TI's application note spra063.pdf. This uses an IIR filter of the form: pwr(i) = (1-alpha_s)*pwr(i-1) + alpha_s*(wave_src(i)^2); where alpha_s = short-term time constant 1/128, and wave_src(i) is the current input sample. If I use this method for pwr(i), the algorithm blows up and spits out garbage (really large values). I tried dropping the step size from 0.2 to 2^-10, and that didn't seem to make a difference. Plotting the two methods of calculating pwr against eachother, they seem to follow the same trend, however the power 'estimate' is definitely scaled down by a factor of around 1000. I tried taking this into account in adjusting the weights, howevre, it still does not work. Any ideas?
NLMS Step Size Question
Started by ●November 5, 2007
Reply by ●November 6, 20072007-11-06
On Nov 5, 7:24 pm, "jai.d...@gmail.com" <jai.d...@gmail.com> wrote:> I'm running into difficulty implementing the NLMS algorithm, w.r.t. > step size.. > > I'm using Matlab to model the algorithm, and here is the core of the > calculation to update the tap weights: > > nlms_coeff = af_parms.mu/pwr(i) * en; > af_parms.state.weights = af_parms.state.weights + xn .* nlms_coeff; > > - pwr(i) is the calculated signal power for sample 'i' > - xn is the data samples used for 'L' taps (1024 in this case). > - I am using step-size of 0.2 > > Now, the problem arises when I change how pwr(i) is calculated. > > If I use pwr(i) = xn' * xn , which is essentially the sum of squared > elements, the algorithm works perfectly. > > I want to use a power estimate however, described in TI's application > note spra063.pdf. This uses an IIR filter of the form: > > pwr(i) = (1-alpha_s)*pwr(i-1) + alpha_s*(wave_src(i)^2); > > where alpha_s = short-term time constant 1/128, and wave_src(i) is the > current input sample. > > If I use this method for pwr(i), the algorithm blows up and spits out > garbage (really large values). I tried dropping the step size from 0.2 > to 2^-10, and that didn't seem to make a difference. > > Plotting the two methods of calculating pwr against eachother, they > seem to follow the same trend, however the power 'estimate' is > definitely scaled down by a factor of around 1000. I tried taking this > into account in adjusting the weights, howevre, it still does not > work. > > Any ideas?The canonical form of Normalized LMS (NLMS) scales the stepsize by the power of the tap-input vector to keep the adaptation bandwidth constant across variations in the input signal, which is exactly what you're doing when you use xn' * xn. Doing a dot product on a 1024 element vector is computationally expensive though, so you'd like to find a simpler way to estimate power. When you use the TI power approximation with a simple mag^2 and IIR filter, you have to choose the alpha_s time constant to constrain the power calculation to a time period equivalent to the length of the tap- input vector. Otherwise, you risk discarding the contribution of some elements, or allowing an influence from elements beyond the current set. Also, you note a scale difference between the dot product and the square/filter technique which will certainly affect the value of af_parms.mu which you use for the two approaches. EB
Reply by ●November 6, 20072007-11-06
That was an excellent explanation, thanks! I changed the alpha parameter to my tap size (1024), and then reduced the Mu parameter to around 2^-10, and it works perfectly! J On Nov 6, 11:48 am, emeb <ebromba...@gmail.com> wrote:> On Nov 5, 7:24 pm, "jai.d...@gmail.com" <jai.d...@gmail.com> wrote: > > > > > I'm running into difficulty implementing the NLMS algorithm, w.r.t. > > step size.. > > > I'm using Matlab to model the algorithm, and here is the core of the > > calculation to update the tap weights: > > > nlms_coeff = af_parms.mu/pwr(i) * en; > > af_parms.state.weights = af_parms.state.weights + xn .* nlms_coeff; > > > - pwr(i) is the calculated signal power for sample 'i' > > - xn is the data samples used for 'L' taps (1024 in this case). > > - I am using step-size of 0.2 > > > Now, the problem arises when I change how pwr(i) is calculated. > > > If I use pwr(i) = xn' * xn , which is essentially the sum of squared > > elements, the algorithm works perfectly. > > > I want to use a power estimate however, described in TI's application > > note spra063.pdf. This uses an IIR filter of the form: > > > pwr(i) = (1-alpha_s)*pwr(i-1) + alpha_s*(wave_src(i)^2); > > > where alpha_s = short-term time constant 1/128, and wave_src(i) is the > > current input sample. > > > If I use this method for pwr(i), the algorithm blows up and spits out > > garbage (really large values). I tried dropping the step size from 0.2 > > to 2^-10, and that didn't seem to make a difference. > > > Plotting the two methods of calculating pwr against eachother, they > > seem to follow the same trend, however the power 'estimate' is > > definitely scaled down by a factor of around 1000. I tried taking this > > into account in adjusting the weights, howevre, it still does not > > work. > > > Any ideas? > > The canonical form of Normalized LMS (NLMS) scales the stepsize by the > power of the tap-input vector to keep the adaptation bandwidth > constant across variations in the input signal, which is exactly what > you're doing when you use xn' * xn. Doing a dot product on a 1024 > element vector is computationally expensive though, so you'd like to > find a simpler way to estimate power. > > When you use the TI power approximation with a simple mag^2 and IIR > filter, you have to choose the alpha_s time constant to constrain the > power calculation to a time period equivalent to the length of the tap- > input vector. Otherwise, you risk discarding the contribution of some > elements, or allowing an influence from elements beyond the current > set. Also, you note a scale difference between the dot product and the > square/filter technique which will certainly affect the value of > af_parms.mu which you use for the two approaches. > > EB