<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE document PUBLIC "-//CNX//DTD CNXML 0.5 plus MathML//EN" "http://cnx.rice.edu/cnxml/0.5/DTD/cnxml_mathml.dtd">
<document xmlns="http://cnx.rice.edu/cnxml" xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="id5940694">
  <name>Least Mean Squares Adaptive Filters</name>
  <metadata>
  <md:version>1.2</md:version>
  <md:created>2007/12/18 01:43:26 US/Central</md:created>
  <md:revised>2008/01/23 08:36:30.182 US/Central</md:revised>
  <md:authorlist>
      <md:author id="blakebrogdon">
      <md:firstname>Blake</md:firstname>
      
      <md:surname>Brogdon</md:surname>
      <md:email>bbrogdon@rice.edu</md:email>
    </md:author>
      <md:author id="tdeitch">
      <md:firstname>Thomas</md:firstname>
      <md:othername>James</md:othername>
      <md:surname>Deitch</md:surname>
      <md:email>tdeitch@rice.edu</md:email>
    </md:author>
      <md:author id="barnhart">
      <md:firstname>Kyle</md:firstname>
      
      <md:surname>Barnhart</md:surname>
      <md:email>barnhart@rice.edu</md:email>
    </md:author>
      <md:author id="bantley">
      <md:firstname>Britt</md:firstname>
      
      <md:surname>Antley</md:surname>
      <md:email>antley@rice.edu</md:email>
    </md:author>
  </md:authorlist>

  <md:maintainerlist>
    <md:maintainer id="blakebrogdon">
      <md:firstname>Blake</md:firstname>
      
      <md:surname>Brogdon</md:surname>
      <md:email>bbrogdon@rice.edu</md:email>
    </md:maintainer>
    <md:maintainer id="tdeitch">
      <md:firstname>Thomas</md:firstname>
      <md:othername>James</md:othername>
      <md:surname>Deitch</md:surname>
      <md:email>tdeitch@rice.edu</md:email>
    </md:maintainer>
    <md:maintainer id="barnhart">
      <md:firstname>Kyle</md:firstname>
      
      <md:surname>Barnhart</md:surname>
      <md:email>barnhart@rice.edu</md:email>
    </md:maintainer>
    <md:maintainer id="bantley">
      <md:firstname>Britt</md:firstname>
      
      <md:surname>Antley</md:surname>
      <md:email>antley@rice.edu</md:email>
    </md:maintainer>
    <md:maintainer id="mdavenport">
      <md:firstname>Mark</md:firstname>
      
      <md:surname>Davenport</md:surname>
      <md:email>md@rice.edu</md:email>
    </md:maintainer>
  </md:maintainerlist>
  
  

  <md:abstract/>
</metadata>
  <content>
    <section id="id-554694002068">
      <name>Least Mean Squares Adaptive Filters</name>
      <section id="id-846603262408">
        <name>Why LMS?</name>
        <para id="id5940858">In our system, the music that is being played by the computer is a known output that is being fed into the room, which has an unknown response, and picked up by the microphone. Since we have the signal both before and after the influence of the room, this is a candidate for an adaptive filter. The adaptive filter can be used to try to estimate the room’s response based on the music being outputted and the input to the microphone. Once an estimate is available, we can use it to remove the interference of the music from the input to the microphone. </para>
      </section>
      <section id="id-805522087903">
        <name>LMS Overview</name>
        <para id="id7148813">One of the most popular adaptive algorithms used today is the Least Mean Squares (LMS) algorithm. Essentially, this algorithm attempts to minimize the error that occurs between the detected (or desired signal), d[n], and the estimated value of the signal, y[n]. This estimated signal is created by taking the original input, x[n] , and running it through an approximation of the unknown channel. Basically:</para>
        <para id="id5941142">
          <m:math>
            <m:semantics>
              <m:mrow>
                <m:mstyle fontsize="12pt">
                  <m:mrow>
                    <m:mrow>
                      <m:mi>y</m:mi>
                      <m:mo stretchy="false">[</m:mo>
                      <m:mi>n</m:mi>
                      <m:mrow>
                        <m:mo stretchy="false">]</m:mo>
                        <m:mo stretchy="false">=</m:mo>
                        <m:mi>x</m:mi>
                      </m:mrow>
                      <m:mo stretchy="false">[</m:mo>
                      <m:mi>n</m:mi>
                      <m:mrow>
                        <m:mo stretchy="false">]</m:mo>
                        <m:mo stretchy="false">∗</m:mo>
                        <m:mover accent="true">
                          <m:mi>h</m:mi>
                          <m:mo stretchy="false">ˆ</m:mo>
                        </m:mover>
                      </m:mrow>
                      <m:mo stretchy="false">[</m:mo>
                      <m:mn>0</m:mn>
                      <m:mrow>
                        <m:mo stretchy="false">]</m:mo>
                        <m:mo stretchy="false">+</m:mo>
                        <m:mi>x</m:mi>
                      </m:mrow>
                      <m:mo stretchy="false">[</m:mo>
                      <m:mrow>
                        <m:mi>n</m:mi>
                        <m:mo stretchy="false">−</m:mo>
                        <m:mn>1</m:mn>
                      </m:mrow>
                      <m:mrow>
                        <m:mo stretchy="false">]</m:mo>
                        <m:mo stretchy="false">∗</m:mo>
                        <m:mover accent="true">
                          <m:mi>h</m:mi>
                          <m:mo stretchy="false">ˆ</m:mo>
                        </m:mover>
                      </m:mrow>
                      <m:mo stretchy="false">[</m:mo>
                      <m:mn>1</m:mn>
                      <m:mrow>
                        <m:mrow>
                          <m:mo stretchy="false">]</m:mo>
                          <m:mo stretchy="false">+</m:mo>
                          <m:mo stretchy="false">…</m:mo>
                        </m:mrow>
                        <m:mo stretchy="false">+</m:mo>
                        <m:mi>x</m:mi>
                      </m:mrow>
                      <m:mo stretchy="false">[</m:mo>
                      <m:mrow>
                        <m:mi>n</m:mi>
                        <m:mo stretchy="false">−</m:mo>
                        <m:mi>N</m:mi>
                      </m:mrow>
                      <m:mrow>
                        <m:mo stretchy="false">]</m:mo>
                        <m:mo stretchy="false">∗</m:mo>
                        <m:mover accent="true">
                          <m:mi>h</m:mi>
                          <m:mo stretchy="false">ˆ</m:mo>
                        </m:mover>
                      </m:mrow>
                      <m:mo stretchy="false">[</m:mo>
                      <m:mi>N</m:mi>
                      <m:mo stretchy="false">]</m:mo>
                    </m:mrow>
                  </m:mrow>
                </m:mstyle>
                <m:mrow/>
              </m:mrow>
              <m:annotation encoding="StarMath 5.0"> size 12{y \[ n \] =x \[ n \] * { hat  {h}} \[ 0 \] +x \[ n - 1 \] * { hat  {h}} \[ 1 \] + dotslow +x \[ n - N \] * { hat  {h}} \[ N \] } {}</m:annotation>
            </m:semantics>
          </m:math>
        </para>
        <para id="id5805086">or </para>
        <para id="id6379178">
          <m:math>
            <m:semantics>
              <m:mrow>
                <m:mstyle fontsize="12pt">
                  <m:mrow>
                    <m:mrow>
                      <m:mi>y</m:mi>
                      <m:mo stretchy="false">[</m:mo>
                      <m:mi>n</m:mi>
                      <m:mrow>
                        <m:mo stretchy="false">]</m:mo>
                        <m:mo stretchy="false">=</m:mo>
                        <m:msubsup>
                          <m:mi>x</m:mi>
                          <m:mstyle fontsize="8pt">
                            <m:mrow>
                              <m:mi>N</m:mi>
                            </m:mrow>
                          </m:mstyle>
                          <m:mstyle fontsize="8pt">
                            <m:mrow>
                              <m:mi>T</m:mi>
                            </m:mrow>
                          </m:mstyle>
                        </m:msubsup>
                      </m:mrow>
                      <m:mo stretchy="false">[</m:mo>
                      <m:mi>n</m:mi>
                      <m:mrow>
                        <m:mo stretchy="false">]</m:mo>
                        <m:mo stretchy="false">∗</m:mo>
                        <m:mover accent="true">
                          <m:mi>h</m:mi>
                          <m:mo stretchy="false">ˆ</m:mo>
                        </m:mover>
                      </m:mrow>
                      <m:mo stretchy="false">[</m:mo>
                      <m:mi>n</m:mi>
                      <m:mo stretchy="false">]</m:mo>
                    </m:mrow>
                  </m:mrow>
                </m:mstyle>
                <m:mrow/>
              </m:mrow>
              <m:annotation encoding="StarMath 5.0"> size 12{y \[ n \] =x rSub { size 8{N} }  rSup { size 8{T} }  \[ n \] * { hat  {h}} \[ n \] } {}</m:annotation>
            </m:semantics>
          </m:math>
        </para>
        <para id="id7158840">where N is the order to which you are approximating the unknown system, 
<m:math><m:semantics><m:mrow><m:mstyle fontsize="12pt"><m:mrow><m:msub><m:mi>x</m:mi><m:mstyle fontsize="8pt"><m:mrow><m:mi>N</m:mi></m:mrow></m:mstyle></m:msub></m:mrow></m:mstyle><m:mrow/></m:mrow><m:annotation encoding="StarMath 5.0"> size 12{x rSub { size 8{N} } } {}</m:annotation></m:semantics></m:math> is a vector of the last N value of x, and each h[n] is a weight. </para>
        <figure id="id6050155"><name>LMS Algorithm Block Diagram</name>
          <media type="image/jpg" src="graphics1.jpg">
            <param name="height" value="207"/>
            <param name="width" value="456"/>
          </media>
        <caption>x[n] is the input to the filter, v[n] is the interference in the room, h[n] is the impulse response we're modeling, and e[n] is the error in this modeling. </caption></figure>
        <para id="id5748277">Once the signal and its approximation are found, the error is just the difference between the two signals at the current point in time.</para>
        <para id="id6064464">
          <m:math>
            <m:semantics>
              <m:mrow>
                <m:mstyle fontsize="12pt">
                  <m:mrow>
                    <m:mrow>
                      <m:mi>e</m:mi>
                      <m:mo stretchy="false">[</m:mo>
                      <m:mi>n</m:mi>
                      <m:mrow>
                        <m:mo stretchy="false">]</m:mo>
                        <m:mo stretchy="false">=</m:mo>
                        <m:mi>d</m:mi>
                      </m:mrow>
                      <m:mo stretchy="false">[</m:mo>
                      <m:mi>n</m:mi>
                      <m:mrow>
                        <m:mo stretchy="false">]</m:mo>
                        <m:mo stretchy="false">−</m:mo>
                        <m:mi>y</m:mi>
                      </m:mrow>
                      <m:mo stretchy="false">[</m:mo>
                      <m:mi>n</m:mi>
                      <m:mo stretchy="false">]</m:mo>
                    </m:mrow>
                  </m:mrow>
                </m:mstyle>
                <m:mrow/>
              </m:mrow>
              <m:annotation encoding="StarMath 5.0"> size 12{e \[ n \] =d \[ n \]  - y \[ n \] } {}</m:annotation>
            </m:semantics>
          </m:math>
        </para>
        <para id="id5937225">Using the error, we can approximate the next set of weights as follows:</para>
        <para id="id6033754">
          <m:math>
            <m:semantics>
              <m:mrow>
                <m:mstyle fontsize="12pt">
                  <m:mrow>
                    <m:mrow>
                      <m:mover accent="true">
                        <m:mi>h</m:mi>
                        <m:mo stretchy="false">ˆ</m:mo>
                      </m:mover>
                      <m:mo stretchy="false">[</m:mo>
                      <m:mrow>
                        <m:mi>n</m:mi>
                        <m:mo stretchy="false">+</m:mo>
                        <m:mn>1</m:mn>
                      </m:mrow>
                      <m:mrow>
                        <m:mo stretchy="false">]</m:mo>
                        <m:mo stretchy="false">=</m:mo>
                        <m:mi>h</m:mi>
                      </m:mrow>
                      <m:mo stretchy="false">[</m:mo>
                      <m:mi>n</m:mi>
                      <m:mrow>
                        <m:mo stretchy="false">]</m:mo>
                        <m:mo stretchy="false">+</m:mo>
                        <m:mrow>
                          <m:mi>μ</m:mi>
                          <m:mo stretchy="false">∗</m:mo>
                          <m:mi>e</m:mi>
                        </m:mrow>
                      </m:mrow>
                      <m:mo stretchy="false">[</m:mo>
                      <m:mi>n</m:mi>
                      <m:mrow>
                        <m:mo stretchy="false">]</m:mo>
                        <m:mo stretchy="false">∗</m:mo>
                        <m:msub>
                          <m:mi>x</m:mi>
                          <m:mstyle fontsize="8pt">
                            <m:mrow>
                              <m:mi>N</m:mi>
                            </m:mrow>
                          </m:mstyle>
                        </m:msub>
                      </m:mrow>
                      <m:mo stretchy="false">[</m:mo>
                      <m:mi>n</m:mi>
                      <m:mo stretchy="false">]</m:mo>
                    </m:mrow>
                  </m:mrow>
                </m:mstyle>
                <m:mrow/>
              </m:mrow>
              <m:annotation encoding="StarMath 5.0"> size 12{ { hat  {h}} \[ n+1 \] =h \[ n \] +μ*e \[ n \] *x rSub { size 8{N} }  \[ n \] } {}</m:annotation>
            </m:semantics>
          </m:math>
        </para>
        <para id="id6036853">where µ is a constant. </para>
      </section>
      <section id="id-247230892671">
        <name>Choosing µ</name>
        <para id="id5946510">The choice of µ is an important one as it greatly affects how the system will perform. Small values allow for greater precision in convergence, but slow down the response time of the system. If the value is too small, then the adaptive filter will not adapt fast enough. If it is too large, the system will not converge at all, and the value weights will actually diverge. Experimentation with different systems and environments is necessary to choose the ideal value for µ. </para>
      </section>
      <section id="id-660429227497">
        <name>Isolating the Whistle</name>
        <para id="id5885374">It can be shown that the error value will converge on a minimum point. This theoretical minimum will likely not be at zero error, since there is outside noise and interference, but it represents the original signal’s effect on d[n] being completely removed. In the case of our signal detection system, the whistle that we are trying to detect will still be in the e[n] and therefore we will use e[n] as the input to the rest of our system. Once the adaptive filter has settled down, this signal will be the input to the microphone minus the estimated value of the music when it reaches the microphone.</para>
      </section>
    </section>
  </content>
</document>
