Bohrium
robot
新建

空间站广场

论文
Notebooks
比赛
课程
Apps
我的主页
我的Notebooks
我的论文库
我的足迹

我的工作空间

任务
节点
文件
数据集
镜像
项目
数据库
公开
Digital-Signal-Processing_04_Random Signals and LTI-Systems_Auto-Correlation Function
English
notebook
Signal Processing
EnglishnotebookSignal Processing
喇叭花
发布于 2023-08-02
推荐镜像 :digital-signal-processing:Digital-Signal-Processing-Lecture
推荐机型 :c2_m4_cpu
Random Signals and LTI-Systems
Auto-Correlation Function
Example - System Response to White Noise
Cross-Correlation Function
System Identification by Cross-Correlation
Example

Random Signals and LTI-Systems

🏃🏻 Getting Started Guide
This document can be executed directly on the Bohrium Notebook. To begin, click the Connect button located at the top of the interface, then select the digital-signal-processing:Digital-Signal-Processing-Lecture Image and choose your desired machine configuration to proceed.

📖 Source
This Notebook is from a famous Signal Processing Lecture. The notebooks constitute the lecture notes to the masters course Digital Signal Processing read by Sascha Spors, Institute of Communications Engineering, Universität Rostock.

This jupyter notebook is part of a collection of notebooks on various topics of Digital Signal Processing. Please direct questions and suggestions to Sascha.Spors@uni-rostock.de.

代码
文本

Auto-Correlation Function

The auto-correlation function (ACF) of the output signal of an LTI system is derived. It is assumed that the input signal is a wide-sense stationary (WSS) real-valued random process and that the LTI system has a real-valued impulse repsonse .

Introducing the output relation of an LTI system into the definition of the ACF and rearranging terms yields

where the ACF of the deterministic impulse response is commonly termed as filter ACF. This is related to the link between ACF and convolution. The relation above is known as the Wiener-Lee theorem. It states that the ACF of the output of an LTI system is given by the convolution of the input signal's ACF with the filter ACF . For a system which just attenuates the input signal with , the ACF at the output is given as .

代码
文本

Example - System Response to White Noise

Let's assume that the wide-sense ergodic input signal of an LTI system with impulse response is normal distributed white noise. Introducing and into the Wiener-Lee theorem yields

The example is evaluated numerically for and

代码
文本
[1]
import numpy as np
import matplotlib.pyplot as plt

L = 10000 # number of samples
K = 30 # limit for lags in ACF

# generate input signal (white Gaussian noise)
np.random.seed(2)
x = np.random.normal(size=L)
# compute system response
y = np.convolve(x, [1, 1, 1, 1, 1], mode='full')

# compute and truncate ACF
acf = 1/len(y) * np.correlate(y, y, mode='full')
acf = acf[len(y)-K-1:len(y)+K-1]
kappa = np.arange(-K, K)

# plot ACF
plt.figure(figsize=(10, 6))
plt.stem(kappa, acf)
plt.title('Estimated ACF of output signal $y[k]$')
plt.ylabel(r'$\hat{\varphi}_{yy}[\kappa]$')
plt.xlabel(r'$\kappa$')
plt.axis([-K, K, 1.2*min(acf), 1.1*max(acf)])
plt.grid()
代码
文本

Exercise

  • Derive the theoretic result for by calculating the filter-ACF .
  • Why is the estimated ACF of the output signal not exactly equal to its theoretic result ?
  • Change the number of samples L and rerun the example. What changes?

Solution: The filter-ACF is given by . The convolution of two rectangular signals results in a triangular signal. Taking the time reversal into account yields

for even . The estimated ACF differs from its theoretic value due to the statistical uncertainties when using random signals of finite length. Increasing its length L lowers the statistical uncertainties.

代码
文本

Cross-Correlation Function

The cross-correlation functions (CCFs) and between the in- and output signal of an LTI system are derived. As for the ACF it is assumed that the input signal originates from a wide-sense stationary real-valued random process and that the LTI system's impulse response is real-valued, i.e. .

Introducing the convolution into the definition of the CCF and rearranging the terms yields

The CCF between in- and output is given as the time-reversed impulse response of the system convolved with the ACF of the input signal.

The CCF between out- and input is yielded by taking the symmetry relations of the CCF and ACF into account

The CCF between out- and input is given as the impulse response of the system convolved with the ACF of the input signal.

For a system which just attenuates the input signal , the CCFs between input and output are given as and .

代码
文本

System Identification by Cross-Correlation

The process of determining the impulse response or transfer function of a system is referred to as system identification. The CCFs of an LTI system play an important role in the estimation of the impulse response of an unknown system. This is illustrated in the following.

The basic idea is to use a specific measurement signal as input signal to the system. Let's assume that the unknown LTI system is excited by white noise. The ACF of the wide-sense stationary input signal is then given as . According to the relation derived above, the CCF between out- and input for this special choice of the input signal becomes

For white noise as input signal , the impulse response of an LTI system can be estimated by estimating the CCF between its out- and input signals. Using noise as measurement signal instead of a Dirac impulse is beneficial since its crest factor is limited.

代码
文本

Example

The application of the CCF to the identification of a system is demonstrated. The system is excited by wide-sense ergodic normal distributed white noise with . The ACF of the in- and output, as well as the CCF between out- and input is estimated and plotted.

代码
文本
[2]
import scipy.signal as sig

N = 10000 # number of samples for input signal
K = 50 # limit for lags in ACF

# generate input signal
# normally distributed (zero-mean, unit-variance) white noise
np.random.seed(5)
x = np.random.normal(size=N)
# impulse response of the system
h = np.concatenate((np.zeros(10), sig.triang(10), np.zeros(10)))
# output signal by convolution
y = np.convolve(h, x, mode='full')


def compute_correlation_function(x, y):
'''Compute correlation function/kappa.'''
N, M = len(x), len(y)
ccf = 1/N * np.correlate(x, y, mode='full')
kappa = np.arange(-M+1, N)

return ccf, kappa


def plot_correlation_function(cf, kappa):
'''Plot correlation function.'''
plt.stem(kappa, cf)
plt.xlabel(r'$\kappa$')
plt.axis([-K, K, -0.2, 1.1*max(cf)])


# compute correlation functions
acfx, kappax = compute_correlation_function(x, x)
acfy, kappay = compute_correlation_function(y, y)
ccfyx, kappayx = compute_correlation_function(y, x)

# plot ACFs and CCF
plt.rc('figure', figsize=(10, 3))
plt.figure()
plot_correlation_function(acfx, kappax)
plt.title('Estimated ACF of input signal')
plt.ylabel(r'$\hat{\varphi}_{xx}[\kappa]$')

plt.figure()
plot_correlation_function(acfy, kappay)
plt.title('Estimated ACF of output signal')
plt.ylabel(r'$\hat{\varphi}_{yy}[\kappa]$')

plt.figure()
plot_correlation_function(ccfyx, kappayx)
plt.plot(np.arange(len(h)), h, 'g-')
plt.title('Estimated and true impulse response')
plt.ylabel(r'$\hat{\varphi}_{yx}[k]$, $h[k]$');
代码
文本

Exercise

  • Why is the estimated CCF not exactly equal to the true impulse response of the system?
  • What changes if you change the number of samples N of the input signal?

Solution: The derived relations for system identification hold for the case of a wide-sense ergodic input signal of infinite duration. Since we can only numerically simulate signals of finite duration, the observed deviations are a result of the resulting statistical uncertainties. Increasing the length N of the input signal improves the estimate of the impulse response.

代码
文本

Copyright

This notebook is provided as Open Educational Resource. Feel free to use the notebook for your own purposes. The text is licensed under Creative Commons Attribution 4.0, the code of the IPython examples under the MIT license. Please attribute the work as follows: Sascha Spors, Digital Signal Processing - Lecture notes featuring computational examples.

代码
文本
English
notebook
Signal Processing
EnglishnotebookSignal Processing
点个赞吧
推荐阅读
公开
Digital-Signal-Processing 04Random Signals and LTI-Systems_Measurement of Acoustic Impulse Responses
EnglishnotebookSignal Processing
EnglishnotebookSignal Processing
喇叭花
发布于 2023-08-02
公开
Digital-Signal-Processing_04_Random Signals and LTI-Systems_Power Spectral Densitity
EnglishnotebookSignal Processing
EnglishnotebookSignal Processing
喇叭花
发布于 2023-08-02