<jupyter_start><jupyter_text>Characterization of Discrete Systems in the Spectral Domain*This Jupyter notebook is part of a [collection of notebooks](../index.ipynb) in the bachelors module Signals and Systems, Communications Engineering, Universität Rostock. Please direct questions and suggestions to [<EMAIL>](mailto:<EMAIL>).*  Phase and Group DelayThe [phase and group delay](https://en.wikipedia.org/wiki/Group_delay_and_phase_delay) characterize the phase and delay properties of an linear time-invariant (LTI) system. Both quantify the frequency dependent delay that is imprinted on a signal when passing through a system. In many applications the delay introduced by a system should be as small as possible or within reasonable limits.  Phase DelayFor an LTI system with transfer function $H(e^{j \Omega})$ the phase delay in samples is defined as follows\begin{equation}t_p(\Omega) = - \frac{\varphi(e^{j \Omega})}{\Omega}\end{equation}where $\varphi(e^{j \Omega}) = \arg \{ H(e^{j \Omega}) \}$ denotes the phase of the transfer function. The phase delay quantifies the delay of a single harmonic exponential signal $e^{j \Omega k}$ with normalized frequency $\Omega$ when passing through the system. The negative sign in the definition of the phase delay results in a positive phase delay $t_p(\Omega) > 0$ when a signal is delayed by a system. Note, the phase delay may not be defined for $\Omega = 0$. **Example - Phase delay of second-order recursive system**The phase delay $t_p(\Omega)$ for the before introduced [second-order recursive LTI system](difference_equation.ipynbSecond-Order-System) with transfer function\begin{equation}H(z) = \frac{1}{1 - z^{-1} + \frac{1}{2} z^{-2}}\end{equation}is computed. First the transfer function is defined<jupyter_code>import sympy as sym
sym.init_printing()
%matplotlib inline

z = sym.symbols('z', complex=True)
W = sym.symbols('Omega', real=True)
H = 1 / (1 - z**(-1) + sym.Rational(1, 2)*z**(-2))
H<jupyter_output><empty_output><jupyter_text>Now the phase delay $t_p(\Omega)$ is computed and plotted for illustration<jupyter_code>phi = sym.arg(H.subs(z, sym.exp(sym.I*W)))
tp = -phi/W

sym.plot(tp, (W, -sym.pi, sym.pi), xlabel='$\Omega$', ylabel='$t_p(\Omega)$ in samples')<jupyter_output><empty_output><jupyter_text>Group DelayThe group delay is defined as the derivative of the phase with respect to the normalized frequency\begin{equation}t_g(\Omega) = - \frac{\mathrm{d} \varphi(e^{j \Omega})}{\mathrm{d} \Omega}\end{equation}given in samples.The group delay quantifies the delay the amplitude envelope of a group of exponential signals observes when passing through a system. The negative sign in above definition results in a positive group delay for a system imposing a delay onto the input signal. Note that the [phase](https://en.wikipedia.org/wiki/Instantaneous_phase) $\varphi(e^{j \Omega})$ is in general only unique for $- \pi < \varphi(e^{j \Omega}) \leq \pi$. If the phase exceeds this range it is wrapped back. For meaningful results it is required to unwrap the phase before computing the group delay. **Example - Phase delay of second-order recursive system**The group delay $t_g(\Omega)$ of above second-order recursive system is computed and plotted<jupyter_code>tg = - sym.diff(phi, W)
sym.plot(tg, (W, -sym.pi, sym.pi), xlabel='$\Omega$', ylabel='$t_g(\Omega)$ in samples')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11691762621789194, 'fraction_numerical': 0.004133451431945674, 'mean_word_length': 5.262476894639557, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '622137', 'license': 'MIT', 'n_tokens_mistral': 994, 'n_tokens_neox': 965, 'n_words': 394, 'path': 'discrete_systems_spectral_domain/phase_group_delay.ipynb', 'repo_name': 'spatialaudio/signals-and-systems-lecture', 'size': '3427'}