# How to calculate the error signal in the LMS algorithm

Started by September 9, 2006
```  Hai All,
I am working with Acoustic Echo Cancellation using LMS
adaptive algorithm.In that I have understood each and every step.But I
am facing the problem with error calculation.If d[n] is the desired
signal that is captured by the microphone and x[n] be the filtered  far
end signal (that is echo replicated signal) and e[n] be the error
signal that is obtained by subtracting the far end signal from the
desired signal.

The question is whether we are subtracting (comparing) d[n]
and x[n] sample by sample or there is another way.Why I got this doubt
of 'another way of comparing' means when we go for sample by sample
subtraction we may not get the actual data as output.

For example, when the far end signal is x[n] = {1, 2, 1} and
d[n] = {3, 4, 5, 1, 2, 1} then the error signal would be e[n] = d[n] -
x[n] = {2, 2, 4, 1, 2, 1} where echo signal is not cancelled.If d[n] =
{1, 2, 1, 3, 4, 5} then the echo signal gets cancelled. So when we go
for subtraction of signals sample by sample we may not get the desired
result.

So I want to know how this far end signal and the desired
signal are subtracted.If any one can explain this please explain it
with one example.

Regards,
Aparna Ram.K

```
```
aparnaram84@gmail.com wrote:
>   Hai All,
>             I am working with Acoustic Echo Cancellation using LMS
> adaptive algorithm.In that I have understood each and every step.

A very modest statement. Why asking the questions then?

But I
> am facing the problem with error calculation.If d[n] is the desired
> signal that is captured by the microphone and x[n] be the filtered  far
> end signal (that is echo replicated signal) and e[n] be the error
> signal that is obtained by subtracting the far end signal from the
> desired signal.
>
>           The question is whether we are subtracting (comparing) d[n]
> and x[n] sample by sample or there is another way.

In the simplest case, it is done sample by sample.
There are more efficient ways to do it then the direct substraction,
however the basic idea is the same.

Why I got this doubt
> of 'another way of comparing' means when we go for sample by sample
> subtraction we may not get the actual data as output.
>
>           For example, when the far end signal is x[n] = {1, 2, 1} and
> d[n] = {3, 4, 5, 1, 2, 1} then the error signal would be e[n] = d[n] -
> x[n] = {2, 2, 4, 1, 2, 1} where echo signal is not cancelled.

Of course it is not canceled. It is the task of the adaptive filter
to match the signals. When your filter is converged, the x[n] = ( 0, 0,
0, 1, 2, 1 } and e[n] = { 3, 4, 5, 0, 0, 0 }

VLV
```