Signal Function Definitions

Continuous-Time Signals

Unit Step Function

$$ u(t)=\begin{cases}0,&t<0\\1,&t\ge0\end{cases} $$

lambda t: np.where(t>=0,1,0)
Plot of Unit Step Function

Unit Impulse Function

$$ \delta(t)=\begin{cases}\infty,&t=0\\0,&t\ne0\end{cases},\ \int\delta(t)dt=1 $$

lambda t: np.where(t==0,1,0)
Plot of Unit Impulse Function

Ramp Function

$$ r(t)=t\,u(t) $$

lambda t: t*(t>=0)
Plot of Ramp Function

Exponential Function

$$ x(t)=e^{at}u(t) $$

lambda t, a=1: np.exp(a*t)*(t>=0)
Plot of Exponential Function

Cosine Function

$$ x(t)=\cos(\omega t) $$

lambda t, ω=2*np.pi: np.cos(ω*t)
Plot of Cosine Function

Rectangular Pulse

$$ \mathrm{rect}\!\bigl(\tfrac{t}{T}\bigr)=\begin{cases}1,&|t|<T/2\\0,&|t|>T/2\end{cases} $$

lambda t, T=1: np.where(np.abs(t)<T/2,1,0)
Plot of Rectangular Pulse

Triangular Pulse

$$ \mathrm{tri}\!\bigl(\tfrac{t}{T}\bigr)=\max\bigl(1-\tfrac{|t|}{T},0\bigr) $$

lambda t, T=1: np.maximum(1-np.abs(t)/T,0)
Plot of Triangular Pulse

Sinc Function

$$ \mathrm{sinc}(t)=\frac{\sin(\pi t)}{\pi t} $$

lambda t: np.sinc(t)
Plot of Sinc Function

Gaussian Pulse

$$ g(t)=e^{-t^2/(2\sigma^2)} $$

lambda t, σ=1: np.exp(-t**2/(2*σ**2))
Plot of Gaussian Pulse

Dirac Comb

$$ \mathrm{comb}_T(t)=\sum_{k=-3}^{3}\delta(t - kT) $$

lambda k, T=1: impulses at t=k·T for k in [-3..3]
Plot of Dirac Comb

Signum Function

$$ \mathrm{sgn}(t)=\begin{cases}-1,&t<0\\0,&t=0\\1,&t>0\end{cases} $$

lambda t: np.sign(t)
Plot of Signum Function

Sawtooth Wave

$$ \mathrm{saw}(t)=2\bigl(\tfrac{t}{T}-\lfloor\tfrac{t}{T}+1/2\rfloor\bigr) $$

lambda t, T=1: 2*(t/T-np.floor(t/T+0.5))
Plot of Sawtooth Wave

Discrete-Time Signals

Unit Step Sequence

$$ u[k]=\begin{cases}1,&k\ge0\\0,&k<0\end{cases} $$

lambda n: np.where(n>=0,1,0)
Plot of Unit Step Sequence

Unit Impulse Sequence

$$ \delta[k]=\begin{cases}1,&k=0\\0,&k\ne0\end{cases} $$

lambda n: np.where(n==0,1,0)
Plot of Unit Impulse Sequence

Ramp Sequence

$$ r[k]=k\,u[k] $$

lambda n: n*(n>=0)
Plot of Ramp Sequence

Exponential Sequence

$$ x[k]=a^k\,u[k] $$

lambda n, a=0.9: (a**n)*(n>=0)
Plot of Exponential Sequence

Cosine Sequence

$$ x[k]=\cos(\omega k) $$

lambda n: np.cos(2*np.pi*n/10)
Plot of Cosine Sequence

Rectangular Window

$$ w[k]=\begin{cases}1,&0\le k<N\\0,&\text{else}\end{cases} $$

lambda n, N=8: np.where((n>=0)&(n<8),1,0)
Plot of Rectangular Window

Triangular Window

$$ w[k]=\max\bigl(1-\tfrac{|k|}{N},0\bigr) $$

lambda n, N=4: np.maximum(1-np.abs(n)/4,0)
Plot of Triangular Window

Sinc Sequence

$$ \mathrm{sinc}[k]=\frac{\sin(\pi k)}{\pi k} $$

lambda n: np.sinc(n)
Plot of Sinc Sequence

Gaussian Sequence

$$ g[k]=e^{-k^2/(2\sigma^2)} $$

lambda n: np.exp(-n**2/2)
Plot of Gaussian Sequence

Comb Sequence

$$ \mathrm{comb}_N[k]=\sum_k\delta[k-kN] $$

lambda n, N=4: np.where(n%4==0,1,0)
Plot of Comb Sequence

Signum Sequence

$$ \mathrm{sgn}[k]=\begin{cases}-1,&k<0\\0,&k=0\\1,&k>0\end{cases} $$

lambda n: np.sign(n)
Plot of Signum Sequence

Sawtooth Sequence

$$ \mathrm{saw}[k]=2\bigl(\tfrac{k}{N}-\lfloor\tfrac{k}{N}+1/2\rfloor\bigr) $$

lambda n, N=8: 2*(n/8-np.floor(n/8+0.5))
Plot of Sawtooth Sequence