From de7027f4060b5047a69c84a5de58496f2a21793d Mon Sep 17 00:00:00 2001
From: Jan Benda <jan.benda@uni-tuebingen.de>
Date: Fri, 12 Mar 2021 19:06:37 +0100
Subject: [PATCH] [spectral] note on how to compute the transfer function

---
 spectral/lecture/spectral.tex | 66 +++++++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)

diff --git a/spectral/lecture/spectral.tex b/spectral/lecture/spectral.tex
index 32af20e..e00d405 100644
--- a/spectral/lecture/spectral.tex
+++ b/spectral/lecture/spectral.tex
@@ -28,6 +28,72 @@ Correlation theorem:
 \[ {\cal F}\{Corr(x,y)\} = X(f)Y^*(f) = S_{x,y} \]
 
 \section{Transfer function}
+The complex valued transfer function of a linear, noiseless system
+relating stimulus $s(t)$ and response $r(t)$ is
+\begin{equation}
+  \label{transfer}
+  H(\omega) = \frac{R(\omega)}{S(\omega)}
+\end{equation}
+where $S(\omega)$ and $R(\omega)$ are the Fourier transformed stimulus
+and response, respectively. By means of the transfer function, the
+response of the system to a stimulus can be predicted according to
+\begin{equation}
+  R(\omega) = H(\omega) S(\omega)
+\end{equation}
+
+Now, if the system is noisy, then the transfer function can only
+predict the mean response $\langle R \rangle_n$, averaged over the
+noise, i.e. averaged over responses evoked by several presentations
+of the same, frozen stimulus:
+\begin{equation}
+  \langle R(\omega) \rangle_n = H(\omega) S(\omega)
+\end{equation}
+
+Both sides of this equation can be multiplied by the complex conjugate
+stimulus $S^*(\omega)$. Since the stimulus is always the same,
+$S^*(\omega)$ can be pulled into the average over the noise and we get
+\begin{equation}
+  \langle R(\omega)S^*(\omega) \rangle_n = H(\omega) S(\omega)S^*(\omega)
+\end{equation}
+The right hand side can also be averaged over the noise, but it makes
+no difference, because neither $S(\omega)$ nore $H(\omega)$ depend on
+the noise. In addition, we can average both sides over different
+realizations of the stimulus. We denote this average by $\langle \cdot
+\rangle_s$. Because the transfer function does note depend on the
+stimulus it can be pulled out of the stimulus average and we get
+\begin{equation}
+  \langle\langle R(\omega)S^*(\omega) \rangle_n\rangle_s = H(\omega) \langle \langle S(\omega)S^*(\omega) \rangle_n \rangle_s
+\end{equation}
+
+Finally, let's solve for the transfer function and denote both
+averages by $\langle \cdot \rangle$:
+\begin{equation}
+  \label{transfercsd}
+  H(\omega)  = \frac{\langle R(\omega)S^*(\omega) \rangle}{\langle S(\omega)S^*(\omega) \rangle}
+\end{equation}
+The transfer function of a noisy system is estimated by dividing the
+cross spectrum by the power spectrum of the stimulus.
+
+Computing the squared gain like this
+\begin{equation}
+  |H(\omega)|^2 = \frac{R(\omega)R^*(\omega)}{S(\omega)S^*(\omega)}
+\end{equation}
+is not possible, it again requires to average over the noise
+\begin{equation}
+  |H(\omega)|^2 = \frac{\langle R(\omega)R^*(\omega) \rangle_n}{S(\omega)S^*(\omega)}
+\end{equation}
+Subsequent averaging over stimuli leads to
+\begin{equation}
+  |H(\omega)|^2 = \left\langle\frac{\langle R(\omega)R^*(\omega) \rangle_n}{S(\omega)S^*(\omega)} \right\rangle_s
+\end{equation}
+which is \emph{not} just the power spectrum $\langle R R^* \rangle$ of
+the response devided by the power spectrum $\langle S S^* \rangle$ of
+the stimulus
+\begin{equation}
+  |H(\omega)|^2 \ne \frac{\langle\langle R(\omega)R^*(\omega) \rangle_n\rangle_s}{\langle S(\omega)S^*(\omega)\rangle_s}
+\end{equation}
+The gain can not be computed by simply dividing the response spectrum
+by the stimulus spectrum.
 
 \section{Coherence function}