<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!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:m="http://www.w3.org/1998/Math/MathML" xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="m0511">

  <name>Discrete-Time Filtering of Analog Signals</name>

  <metadata>
  <md:version>2.20</md:version>
  <md:created>2000/07/25</md:created>
  <md:revised>2007/06/03 16:23:55.319 GMT-5</md:revised>
  <md:authorlist>
      <md:author id="dhj">
      <md:firstname>Don</md:firstname>
      
      <md:surname>Johnson</md:surname>
      <md:email>dhj@rice.edu</md:email>
    </md:author>
  </md:authorlist>

  <md:maintainerlist>
    <md:maintainer id="dhj">
      <md:firstname>Don</md:firstname>
      
      <md:surname>Johnson</md:surname>
      <md:email>dhj@rice.edu</md:email>
    </md:maintainer>
    <md:maintainer id="jago">
      <md:firstname>Adan</md:firstname>
      
      <md:surname>Galvan</md:surname>
      <md:email>jago@rice.edu</md:email>
    </md:maintainer>
    <md:maintainer id="jac3">
      <md:firstname>John</md:firstname>
      <md:othername>Austin</md:othername>
      <md:surname>Cottrell</md:surname>
      <md:email>jac3@rice.edu</md:email>
    </md:maintainer>
  </md:maintainerlist>
  
  <md:keywordlist>
    <md:keyword>analog</md:keyword>
    <md:keyword>analog signals</md:keyword>
    <md:keyword>computational complexity</md:keyword>
    <md:keyword>digital filter</md:keyword>
    <md:keyword>digital signal processing</md:keyword>
    <md:keyword>discrete-time</md:keyword>
    <md:keyword>discrete-time filtering</md:keyword>
    <md:keyword>DSP</md:keyword>
    <md:keyword>filtering</md:keyword>
  </md:keywordlist>

  <md:abstract>A brief introduction on how to filter digital signals
</md:abstract>
</metadata>

  <content>
    <para id="intro">
      Because of the <cnxn document="m0050" target="first_sampling_section" strength="8">Sampling
      Theorem</cnxn>, we can process, in particular filter, analog
      signals "with a computer" by constructing the system shown in
      <cnxn target="fig1000" strength="8"/>.  To use this system, we
      are assuming that the input signal has a lowpass spectrum and
      can be bandlimited without affecting important signal aspects.
      Bandpass signals can also be filtered digitally, but require a
      more complicated system.  Highpass signals cannot be filtered
      digitally. Note that the input and output filters must be analog
      filters; trying to operate without them can lead to potentially
      very inaccurate digitization.
    </para>

    <figure id="fig1000">
      <media type="image/png" src="sys12.png"/>
      <caption>
	To process an analog signal digitally, the signal 
	<m:math>
	  <m:apply>
	    <m:ci type="fn">x</m:ci><m:ci>t</m:ci></m:apply> </m:math>
	must be filtered with an anti-aliasing filter (to ensure a
	bandlimited signal) before A/D conversion.  This lowpass
	filter (LPF) has a cutoff frequency of
	<m:math><m:ci>W</m:ci></m:math> Hz, which determines allowable
	sampling intervals 
	<m:math>
	  <m:ci><m:msub>
	      <m:mi>T</m:mi>
	      <m:mi>s</m:mi>
	    </m:msub></m:ci>
	</m:math>
	.  The greater the number of bits in the amplitude
	quantization portion
	<m:math>
	  <m:apply>
	    <m:ci type="fn" class="discrete">Q</m:ci>
	    <m:ci>·</m:ci>
	  </m:apply>
	</m:math> of the A/D
	converter, the greater the accuracy of the entire system.  The
	resulting digital signal 
	<m:math>
	  <m:apply>
	    <m:ci type="fn">x</m:ci>
	    <m:ci>n</m:ci>
	  </m:apply>
	</m:math> can now be filtered in the time-domain with a
	difference equation or in the frequency domain with Fourier
	transforms.  The resulting output 
	<m:math>
	  <m:apply>
	    <m:ci type="fn">y</m:ci>
	    <m:ci>n</m:ci>
	  </m:apply>
	</m:math> then
	drives a D/A converter and a second anti-aliasing filter
	(having the same bandwidth as the first one).
      </caption>
    </figure>

    <para id="para2">
      Another implicit assumption is that the digital filter can operate
      in <emphasis>real time</emphasis>: The computer and the filtering
      algorithm must be sufficiently fast so that outputs are computed
      faster than input values arrive. The sampling interval, which is
      determined by the analog signal's bandwidth, thus determines how long
      our program has to compute <emphasis>each</emphasis> output 
      <m:math>
	<m:apply>
	  <m:ci type="fn">y</m:ci>
	  <m:ci>n</m:ci>
	</m:apply>
      </m:math>.  The computational complexity for calculating each
      output with a <cnxn document="m10251" target="eq3" strength="8">difference equation</cnxn> is
      <m:math>
	<m:apply>
	  <m:ci type="fn">O</m:ci>
	  <m:apply>
	    <m:plus/>
	    <m:ci>p</m:ci>
	    <m:ci>q</m:ci>
	  </m:apply>
	</m:apply>
      </m:math>.  Frequency domain implementation of the filter is
      also possible.  The idea begins by computing the Fourier
      transform of a length-<m:math><m:ci>N</m:ci></m:math> portion of
      the input
      <m:math>
	<m:apply>
	  <m:ci type="fn">x</m:ci>
	  <m:ci>n</m:ci>
	</m:apply>
      </m:math>, multiplying it by the filter's transfer function, and
      computing the inverse transform of the result.  This approach
      seems overly complex and potentially inefficient. Detailing the
      complexity, however, we have 
      <m:math>
	<m:apply>
	  <m:ci type="fn">O</m:ci>
	  <m:apply>
	    <m:times/>
	    <m:ci>N</m:ci>
	    <m:apply>
	      <m:log/>
	      <m:ci>N</m:ci>
	    </m:apply>
	  </m:apply>
	</m:apply>
      </m:math>
      for the two transforms (computed using the FFT algorithm) and
      <m:math>
	<m:apply>
	  <m:ci type="fn">O</m:ci>
	  <m:ci>N</m:ci>
	</m:apply>
      </m:math> for the multiplication by the transfer function, which makes
      the total complexity 
      <m:math>
	<m:apply>
	  <m:ci type="fn">O</m:ci>
	  <m:apply>
	    <m:times/>
	    <m:ci>N</m:ci>
	    <m:apply>
	      <m:log/>
	      <m:ci>N</m:ci>
	    </m:apply>
	  </m:apply>
	</m:apply>
      </m:math>
      <emphasis>for <m:math><m:mi>N</m:mi></m:math> input
	values</emphasis>.  A frequency domain implementation thus
	requires
      <m:math>
	<m:apply>
	  <m:ci type="fn">O</m:ci>
	  <m:apply>
	    <m:log/>
	    <m:ci>N</m:ci>
	  </m:apply>
	</m:apply>
      </m:math>
      computational complexity for each output value. The complexities
      of time-domain and frequency-domain implementations depend on
      different aspects of the filtering: The time-domain
      implementation depends on the combined orders of the filter
      while the frequency-domain implementation depends on the
      logarithm of the Fourier transform's length.
    </para>
    <para id="para3">It could well be that in some problems the time-domain version
      is more efficient (more easily satisfies the real time
      requirement), while in others the frequency domain approach is
      faster. In the latter situations, it is the FFT algorithm for
      computing the Fourier transforms that enables the
      superiority of frequency-domain implementations. Because complexity
      considerations only express how algorithm running-time increases
      with system parameter choices, we need to detail both
      implementations to determine which will be more suitable for any
      given filtering problem. Filtering with a difference equation is
      straightforward, and the number of computations that must be
      made for each output value is
      <m:math>
	<m:apply>
	  <m:times/>
	  <m:cn>2</m:cn>
	  <m:apply><m:plus/>
	    <m:ci>p</m:ci>
	    <m:ci>q</m:ci>
	  </m:apply>
	</m:apply>
      </m:math>.
    </para>

    <exercise id="exer1">
      <problem>
	<para id="exer1a">Derive this value for the number of computations for the general
	  <cnxn document="m10251" target="eq3" strength="8">difference
	  equation</cnxn>.
	</para>
      </problem>
      <solution>
	<para id="sol">
	  We have 
	  <m:math>
	    <m:apply>
	      <m:plus/> 
	      <m:ci>p</m:ci>
	      <m:ci>q</m:ci>
	      <m:cn>1</m:cn>
	    </m:apply>
	  </m:math>
	  multiplications and 
	  <m:math>
	    <m:apply>
	      <m:minus/>
	      <m:apply><m:plus/>
		<m:ci>p</m:ci><m:ci>q</m:ci>
	      </m:apply>
	      <m:cn>1</m:cn>
	    </m:apply>
	  </m:math>
	  additions. Thus, the total number of arithmetic operations equals  
	  <m:math>
	    <m:apply>
	      <m:times/>
	      <m:cn>2</m:cn>
	      <m:apply>
		<m:plus/><m:ci>p</m:ci><m:ci>q</m:ci>
	      </m:apply>
	    </m:apply>
	  </m:math>.
	</para>
      </solution>
    </exercise>

  </content>
</document>
