Page MenuHomec4science

lti_intro.tex
No OneTemporary

File Metadata

Created
Sat, Mar 15, 03:38

lti_intro.tex

\documentclass[aspectratio=169]{beamer}
\def\stylepath{../styles}
\usepackage{\stylepath/com303}
\begin{document}
\intertitle{review of filters}
\begin{frame} \frametitle{A generic signal processing device}
\note<1>{Say it's single input/single output.\\Also from now on we will assume two-sided\\
infinite sequences unless otherwise stated}
\begin{figure}
\center
\begin{dspBlocks}{1.2}{1}
$x[n]$~~ & \rnode{F}{\BDfilter{$\mathcal{H}$}} & ~~$y[n]$ \\
\ncline{->}{1,1}{1,2}\ncline{->}{1,2}{1,3}
\end{dspBlocks}
\end{figure}
\vspace{1em}
\[
y[n] = \mathcal{H}\{x[n]\}
\]
\end{frame}
\begin{frame} \frametitle{Linearity and time invariance}
\[
\mathcal{H}\{\alpha\, x_1[n] + \beta\, x_2[n]\} = \alpha\, \mathcal{H}\{x_1[n]\} + \beta\, \mathcal{H}\{x_2[n]\}
\]
\vspace{2em}
\[
y[n] = \mathcal{H}\{x[n]\} \quad \Longleftrightarrow \quad \mathcal{H}\{x[n-n_0]\} = y[n-n_0]
\]
\end{frame}
\begin{frame} \frametitle{Impulse response}
\centering
\[
h[n] = \mathcal{H}\{\delta[n]\}
\]
\vspace{2em}
\[
y[n] = \sum_{k=-\infty}^{\infty} x[k] h[n-k] = (x \ast h)[n]
\]
\end{frame}
\begin{frame}
\frametitle{A remarkable result}
\begin{figure}
\center
\begin{dspBlocks}{1.2}{1}
$e^{j\omega_0 n}$~~ & \rnode{F}{\BDfilter{$\mathcal{H}$}} & ~~$H(e^{j\omega_0}) \, e^{j\omega_0 n}$ \\
\ncline{->}{1,1}{1,2}\ncline{->}{1,2}{1,3}
\end{dspBlocks}
\end{figure}
\end{frame}
\begin{frame}
\frametitle{The frequency response}
\centering
In general:
\[
\DTFT{x[n] \ast h[n]} = H(e^{j\omega}) \, X(e^{j\omega})
\]
\vspace{1em}
\begin{itemize}
\item {\color{red} magnitude:} amplification ($|H(e^{j\omega})| > 1$) or attenuation ($|H(e^{j\omega})| < 1$) of input frequencies
\item {\color{red} phase:} overall delay and shape changes
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{MA: impulse response}
\centering
\begin{align*}
y[n] &= \frac{1}{M}\sum_{k=0}^{M-1}x[n-k]
\end{align*}
\begin{align*}
h[n] &= \frac{1}{M}\sum_{k=0}^{M-1}\delta[n-k] \\
&= \begin{cases}
1/M & \mbox{for $0 \leq n < M$} \\
0 & \mbox{otherwise}
\end{cases}
\end{align*}
\end{frame}
\begin{frame}
\frametitle{MA: impulse response}
\begin{figure}
\begin{dspPlot}[xticks=custom,yticks=custom]{-20,20}{-0.5,1.2}
\moocStyle
\dspSignal{x 0 lt {0} {x 8 gt {0} {1} ifelse} ifelse}
\dspCustomTicks[axis=x]{0 0 8 $M-1$}
\dspCustomTicks[axis=y]{0 0 1 $1/M$}
\end{dspPlot}
\end{figure}
\end{frame}
\def\sinInt#1{ 90 mul dup dup 0 eq {pop pop 1} {#1 mul sin exch sin div} ifelse #1 div}
\begin{frame}
\frametitle{Moving Average, magnitude response}
\note<1>{Circle by hand the zone of little attenuation\\ and the zone of high attenuation}
\begin{center}
$|H(e^{j\omega})| = \frac{1}{M}\,\left| \frac{\sin \left( \frac{\omega}{2}M \right)}{\sin \left( \frac{\omega}{2} \right)}\right| \qquad$ %e^{-j\frac{\omega}{2}(M-1)
\begin{figure}
\begin{dspPlot}[xtype=freq,ylabel={$|H(e^{j\omega})|$}]{-1,1}{0, 1.2}
\moocStyle
\only<1>{\dspFunc{x \sinInt{9} abs}\dspText(0.5,1){$M=9$}}
\only<2>{\dspFunc{x \sinInt{20} abs}\dspText(0.5,1){$M=20$}}
\only<3>{\dspFunc{x \sinInt{100} abs}\dspText(0.5,1){$M=100$}}
\end{dspPlot}
\end{figure}
\end{center}
\end{frame}
\begin{frame}
\frametitle{MA: analysis}
\begin{itemize}
\item impulse response has finite support: \textbf{FIR filter}
\item smoothing effect proportional to $M$
\item number of operations and storage also proportional to $M$
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{The Leaky Integrator}
\begin{itemize}
\item $y[n] = \lambda y[n-1] + (1-\lambda) x[n] $
\vspace{1em}
\item filter is \textit{recursive}, since it uses its previous output value
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{Impulse response}
\[ h[n] = (1-\lambda)\lambda^n\,u[n] \]
\begin{figure}
\begin{dspPlot}[xticks=15]{-10,30}{-0.05,0.12}
\moocStyle
\dspSignal{x 0 ge {1 0.9 sub 0.9 x exp mul} {0} ifelse}
\dspCustomTicks[axis=y]{0.1 $1-\lambda$}
\end{dspPlot}
\end{figure}
\end{frame}
\def\pole{0.9 }
\def\lifr#1{#1 1 sub dup mul 1 #1 #1 mul add x 180 mul cos 2 mul #1 mul sub div abs sqrt }
\def\lipr#1{x 0 gt {#1 x 180 mul sin mul 1 #1 x 180 mul cos mul sub atan 180 div -1 mul 3.14 mul} {#1 x 180 mul sin mul -1 mul 1 #1 x 180 mul cos mul sub atan 180 div 3.14 mul} ifelse }
\begin{frame}
\frametitle{Leaky integrator, magnitude response}
\begin{center}
$|H(e^{j\omega})| = \left| \frac{1-\lambda}{1-\lambda e^{-j\omega}} \right| $
\begin{figure}
\begin{dspPlot}[xtype=freq,ylabel={$|H(e^{j\omega})|$}]{-1,1}{0, 1.2}
\moocStyle
\only<1>{\dspFunc{\lifr{0.9} } \dspText(0.5,0.8){$\lambda=0.9$}}
\only<2>{\dspFunc{\lifr{0.95} } \dspText(0.5,0.8){$\lambda=0.95$}}
\only<3>{\dspFunc{\lifr{0.98} } \dspText(0.5,0.8){$\lambda=0.98$}}
\end{dspPlot}
\end{figure}
\end{center}
\end{frame}
\begin{frame}
\frametitle{Leaky integrator: analysis}
\begin{itemize}
\item recursion generates impulse response with infinite support: \textbf{IIR filter}
\item smoothing effect dependent on $\lambda$
\item number of operations and storage: {\em independent of $\lambda$}
\item infinite-length impulse responses are computable
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{Causal vs Noncausal}
\begin{itemize}
\item causal:
\begin{itemize}
\item only past samples (with respect to the present) are involved in the computation of current output
\item causal systems can work ``on line'' since they only need the past
\item for LTI systems, causality $\Rightarrow$ impulse response is zero for $n<0$
\end{itemize}
\item noncausal:
\begin{itemize}
\item output depends on future values
\item can still be implemented in a offline fashion (when all input data is available on storage, e.g. in Image Processing)
\item for LTI systems, impulse response is nonzero for some (or all) $n<0$
\end{itemize}
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{Causal example}
\centering
Moving Average filter
\begin{figure}
\begin{dspPlot}{-20,20}{-0.1,0.3}
\moocStyle
\dspSignal{x 0 lt {0} {x 5 gt {0} {1 5 div} ifelse} ifelse}
\end{dspPlot}
\end{figure}
\end{frame}
\begin{frame}
\frametitle{Noncausal example}
\centering
Zero-centered Moving Average filter
\begin{figure}
\begin{dspPlot}{-20,20}{-0.1,0.3}
\moocStyle
\dspSignal{x -2 lt {0} {x 2 gt {0} {1 5 div} ifelse} ifelse}
\end{dspPlot}
\end{figure}
\end{frame}
\begin{frame}
\frametitle{Causal and Noncausal Moving Average}
\centering
\begin{figure}
\begin{dspPlot}[xticks=100,xout=true,sidegap=0]{0,499}{-8,8}
\moocStyle
\dspFuncFile[linecolor=blue!40]{causal-example-1.txt}
\only<2->{\dspFuncFile[linecolor=orange!60]{causal-example-2.txt} \uput[0](400,6){$M=100$}}
\only<3->{\dspFuncFile{causal-example-3.txt}}
\end{dspPlot}
\end{figure}
\end{frame}
\begin{frame}
\frametitle{What about the phase?}
Assume $|H(e^{j\omega})| = 1$
\begin{itemize}
\item zero phase: $\angle H(e^{j\omega}) = 0$
\item linear phase: $\angle H(e^{j\omega}) = d\omega$
\item nonlinear phase
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{Linear phase}
\begin{figure}
\center
\begin{dspBlocks}{1.2}{1}
$x[n]$~~ & \rnode{F}{\BDfilter{$z^{-d}$}} & ~~$x[n-d]$ \\
\ncline{->}{1,1}{1,2}\ncline{->}{1,2}{1,3}
\end{dspBlocks}
\end{figure}
\begin{itemize}
\item $y[n] = x[n-d]$
\item $Y(e^{j\omega}) = e^{-j\omega d}\,X(e^{j\omega})$
\item $H(e^{j\omega}) = e^{-j\omega d}$
\item linear phase term
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{Phase and signal shape}
\[
x[n] = \frac{1}{2}\sin(\omega_0 n) + \cos(2\omega_0 n) \qquad \omega_0 = \frac{2\pi}{40}
\]
\begin{figure}
\begin{dspPlot}[xout=true]{-10,160}{-2,2}
\moocStyle
\dspFunc{x 360 mul dup
20 div cos exch
40 div sin 0.5 mul
add}
\end{dspPlot}
\end{figure}
\end{frame}
\begin{frame}
\frametitle{Phase and signal shape: linear phase}
\[
x[n] = \frac{1}{2}\sin(\omega_0 n + \theta_0) + \cos(2\omega_0 n + 2\theta_0) \qquad \theta_0 = \frac{8\pi}{5}
\]
\begin{figure}
\begin{dspPlot}[xout=true]{-10,160}{-2,2}
\moocStyle
\dspFunc{x 360 mul dup
20 div 144 add cos exch
40 div 72 add sin 0.5 mul
add}
\end{dspPlot}
\end{figure}
\end{frame}
\begin{frame}
\frametitle{Phase and signal shape: nonlinear phase}
\[
x[n] = \frac{1}{2}\sin(\omega_0 n) + \cos(2\omega_0 n + 2\theta_0)
\]
\begin{figure}
\begin{dspPlot}[xout=true]{-10,160}{-2,2}
\moocStyle
\dspFunc{x 360 mul dup
20 div 144 add cos exch
40 div sin 0.5 mul
add}
\end{dspPlot}
\end{figure}
\end{frame}
\begin{frame}
\frametitle{Linear phase}
\centering
In general, if $H(e^{j\omega}) = A(e^{j\omega}) e^{-j\omega d}, \quad$ with $A(e^{j\omega}) \in \mathbb{R}$
\vspace{2em}
\begin{figure}
\center
\begin{dspBlocks}{1.2}{0.2}
$x[n]$~~ & \BDfilter{$A(e^{j\omega})$} & \BDfilter{delay by $d$} & ~~$y[n]$ \\
\ncline{->}{1,1}{1,2}\ncline{->}{1,2}{1,3}\ncline{->}{1,3}{1,4}
\end{dspBlocks}
\end{figure}
\end{frame}
\begin{frame}
\frametitle{Moving Average is linear phase}
\[
H(e^{j\omega}) = \frac{1}{M}\,\frac{\sin \left( \frac{\omega}{2}M \right)}{\sin \left( \frac{\omega}{2} \right)} e^{-j\frac{M-1}{2}\omega}
\]
\end{frame}
\begin{frame}
\frametitle{Leaky integrator is nonlinear phase}
\[
H(e^{j\omega}) = \frac{1-\lambda}{1-\lambda e^{-j\omega}}
\]
\vspace{1em}
\begin{align*}
|H(e^{j\omega})|^2 &= \frac{(1-\lambda)^2}{1-2\lambda\cos\omega + \lambda^2} \\ \\
\angle H(e^{j\omega}) &= \tan^{-1} \left[ \frac{\lambda\sin\omega}{1-\lambda\cos\omega} \right]
\end{align*}
\end{frame}
\def\pole{0.9 }
\def\lifr#1{#1 1 sub dup mul 1 #1 #1 mul add x 180 mul cos 2 mul #1 mul sub div abs sqrt }
\def\lipr#1{x 0 gt {#1 x 180 mul sin mul 1 #1 x 180 mul cos mul sub atan 180 div -1 mul 3.14 mul} {#1 x 180 mul sin mul -1 mul 1 #1 x 180 mul cos mul sub atan 180 div 3.14 mul} ifelse }
\begin{frame}
\frametitle{Leaky integrator, phase response}
\begin{center}
\begin{figure}
\begin{dspPlot}[xtype=freq,xout=true,yticks=custom,ylabel={$\angle H(e^{j\omega})$}]{-1,1}{-1.57,1.57}
\moocStyle
\only<1>{\dspFunc{\lipr{0.9}}\dspText(0.6,0.8){$\lambda=0.9$}}
\only<2>{\dspFunc{\lipr{0.95}}\dspText(0.6,0.8){$\lambda=0.95$}}
\only<3>{\dspFunc{\lipr{0.98}}\dspText(0.6,0.8){$\lambda=0.98$}}
\dspCustomTicks[axis=y]{-1.57 $-\pi/2$ 1.57 $\pi/2$}
\end{dspPlot}
\end{figure}
\end{center}
\end{frame}
\def\pole{0.8 }
\def\lpr{0.1}
\begin{frame}
\frametitle{Phase is sufficiently linear where it matters}
\begin{figure}
\begin{dspPlot}[xtype=freq,ylabel={$|H(e^{j\omega})|$},height=2.5cm]{-1,1}{0,1.1}
\moocStyle
\dspFunc{\lifr{\pole}}
\end{dspPlot}
\begin{dspPlot}[xtype=freq,xout=true,yticks=custom,ylabel={$\angle H(e^{j\omega})$},height=2.5cm]{-1,1}{-1.57,1.57}
\moocStyle
\dspFunc{\lipr{\pole}}
\dspCustomTicks[axis=y]{-1.57 $-\pi/2$ 1.57 $\pi/2$}
\only<2->{\psframe[linecolor=green,linewidth=1pt](\lpr,-1.57)(-\lpr,6.2)}
\end{dspPlot}
\end{figure}
\end{frame}
\begin{frame}
\frametitle{Stability}
\begin{itemize}
\item key concept: avoid ``explosions'' if the input is nice
\item a nice signal is a bounded signal: $|x[n]| < M$ for all $n$
\item Bounded-Input Bounded-Output (BIBO) stability: if the input is nice the output should be nice
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{Fundamental Stability Theorem}
\centering
A filter is BIBO stable if and only if its impulse response is absolutely summable
\end{frame}
\begin{frame}
\frametitle{The good news}
\centering
FIR filters are always stable
\end{frame}
\begin{frame}
\frametitle{Checking the stability of IIRs}
\centering
Let's check the Leaky Integrator:
\begin{align*}
\sum_{n=-\infty}^{\infty} |h[n]| &= |1-\lambda| \sum_{n=0}^{\infty} |\lambda|^n \\
&= \lim_{n\rightarrow\infty} |1-\lambda|\frac{1-|\lambda|^{n+1}}{1-|\lambda|} \\
&< \infty \quad \mbox{for $|\lambda| < 1$}
\end{align*}
\vspace{1em}
stability is guaranteed for $|\lambda| < 1$
\end{frame}
\begin{frame}
\frametitle{Checking the stability of IIRs}
\centering
We will study indirect methods for filter stability later
\end{frame}
\end{document}

Event Timeline