This commit is contained in:
PinkR1ver 2024-04-23 11:55:58 +08:00
parent 77d6bf93a9
commit b8846908ed
16 changed files with 300 additions and 7 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 331 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 219 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

View File

@ -0,0 +1,172 @@
---
title: EMD Basic
tags:
- advanced
- basic
- signal-processing
- signal
- algorithm
- math
date: 2024-04-17
---
# Introduction
Empirical Mode Decomposition (EMD) is a **non-linear** and **non-stationary** data analysis technique with the ability to **extract AM-FM components**, called **Intrinsic Mode Functions** (IMFs), of the signal, in the time domain itself (Huang et al., 1998).
EMD is similar to Fourier Transform (FT). FT assumes our signal is periodic and it's basic components are various simple sine waves. And FT makes our signal from time domain to frequency domain. The different with EMD is the **output remains in the time spectrum** and EMD **dose not assume our signal is periodic** and it's not based on simple sine wave instead, it's **Intrinsic Mode Function** (IMF). EMD is really based on the dataset, **doesnt have an assumption about the data** (That why its called Empirical).
# Detail
## Overview
![](signal_processing/algorithm/EMD/attachments/Pasted%20image%2020240417160805.png)
## Flow Chart
![](signal_processing/algorithm/EMD/attachments/Pasted%20image%2020240417160534.png)
## Step by Step
Input $x(t)$,
1. Identify all extrema of $x(t)$
2.  Create an envelope of minima and maxima from the array of minima and maxima.
* Interpolate the value of minima and maxima to create an envelope of minima and maxima using a cubic
spline.
* maxima envelope: $e_{\text{max}}(t)$
* minima envelope: $e_{\text{min}}(t)$
3. Compute the mean from the envelope of minima and maxima $m(t) = \frac{e_{\text{max}}(t) + e_{\text{min}}(t)}{2}$
4. Extract the detail $c(t) = x(t) - m(t)$
5. Iterate 1-4 with $x(t) \gets c(t)$ until $c(t)$ is zero-mean
* or some stopping criteria
* The resulting $c(t)$ is the intrinsic mode function (IMF)
6. Iterate 1-5 on the residue $m(t) = x(t) - \sum c_i(t)$
* Until some stopping criteria
* Peak Frequency is low
* Residuum signal is just a constant, monotonic, or just have 1 extremum
![](signal_processing/algorithm/EMD/attachments/Pasted%20image%2020240417160436.png)
## Hilbert Spectral Analysis (HSA)
### Instantaneous Frequency
To see:
[Instantaneous Frequency⭐](signal_processing/basic_knowledge/instantaneous_frequency.md)
### HSA after EMD
![](signal_processing/algorithm/EMD/attachments/2d8bbe7b82ba09ec5220d81af8a5c22.jpg)
得到这些IMF之后我们的信号$x(t)$可以表达为,
$$
x(t) = r_n(t) + \sum_{i}^{n} c_i(t)
$$
进而我们会通过这个$x(t)$的表达去得到时频分析图;如上图所示,得到这个时频分析图的过程中,不会用到最后的剩余部分$r_n(t)$,因为它要么是单调函数,要么是常数。尽管希尔伯特变换可以将单调趋势视为较长振荡的一部分,但残余趋势中涉及的能量可能会非常强大。考虑到较长趋势的不确定性,并且为了其他低能量和高频分量中包含的信息的利益,最终的非 IMF 分量应被排除。然而如果物理考虑证明其包含是合理的则可以将其包含在内。这是一个Tradeoff。
然后通过对IMF分量做Hilbert Transform构建analytic signal
$$
h_i(t) = c_i(t) \times \frac{1}{\pi t} = \frac{1}{\pi} \text{p.v.} \int_{-\infty}^{\infty} \frac{c_i(\tau)}{t - \tau}d\tau
$$
构建出来的解析信号为,
$$
A_i(t) = c_i(t) + iH_i(t) = \alpha_i(t) e^{i\theta_i(t)}
$$
进而得到瞬时幅值和瞬时相位,进而通过瞬时相位得到瞬时频率,
$$
\alpha_i(t) = \sqrt{c_i(t)^2 + h_i(t)^2}, \quad \theta(t) = \arctan(\frac{h_i(t)}{c_i(t)}), \quad \omega = \frac{d\theta_i(t)}{t}
$$
进而最后我们可以进行HSA
$$
\text{Plot} \quad H_i(\omega, t) = \begin{cases}
\alpha_i(t), & \omega = \omega_{i}(t) \\
0, & \text{otherwise}
\end{cases}
\quad H(\omega, t) = \sum_{i=1}^{n} H_i(\omega, t)
$$
# Demo code
```python
import numpy as np
import numpy as np
def EMD(signal, max_imf = 10, tolerance = 0.1):
def __extrema(signal):
max_peaks = []
min_peaks = []
for i in range(1, len(signal) - 1):
if signal[i] > signal[i-1] and signal[i] > signal[i+1]:
max_peaks.append(i)
if signal[i] < signal[i-1] and signal[i] < signal[i+1]:
min_peaks.append(i)
return max_peaks, min_peaks
def __mean_env(signal):
max_peaks, min_peaks = __extrema(signal)
max_env = np.interp(range(len(signal)), max_peaks, [signal[i] for i in max_peaks])
min_env = np.interp(range(len(signal)), min_peaks, [signal[i] for i in min_peaks])
return (max_env + min_env) / 2
def __IMF(signal):
imf = signal - __mean_env(signal)
resdiual = signal - imf
return imf, resdiual
# standardize the signal
mean = np.mean(signal)
std = np.std(signal)
signal = (signal - mean) / std
imfs = []
while True:
imf, residual = __IMF(signal)
imfs.append(imf)
if np.abs(np.std(residual)) < tolerance or max_imf == 0:
break
signal = residual
max_imf -= 1
imfs = [imf * std + mean for imf in imfs]
residual = residual * std + mean
return imfs, residual
```
# Reference
* [Huang, Norden E., et al. “The Empirical Mode Decomposition and the Hilbert Spectrum for Nonlinear and Non-Stationary Time Series Analysis.” _Proceedings of the Royal Society of London. Series A: Mathematical, Physical and Engineering Sciences_, vol. 454, no. 1971, Mar. 1998, pp. 90395. _DOI.org (Crossref)_, https://doi.org/10.1098/rspa.1998.0193.](https://royalsocietypublishing.org/doi/abs/10.1098/rspa.1998.0193#purchaseArea)
* https://www.youtube.com/watch?v=K-LhNvr-CSk
* https://towardsdatascience.com/decomposing-signal-using-empirical-mode-decomposition-algorithm-explanation-for-dummy-93a93304c541⭐
* https://en.wikipedia.org/wiki/Hilbert_spectrum

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

View File

@ -0,0 +1,30 @@
---
title: What's Linear in Signal Mean?
tags:
- basic
- signal
- signal-processing
---
有一个系统$\mathcal{F}$,
$$
\mathcal{F}(x_1(t)) = y_1(t)
$$
$$
\mathcal{F}(x_2(t)) = y_2(t)
$$
那么线性,则有:
$$
\mathcal{F}(\alpha_1 x_1(t) + \alpha_2 x_2(t)) = \alpha_1 y_1(t) + \alpha_2 y_2(t)
$$
线性系统的一个关键特性是它们是**可逆的**,这意味着我们可以通过逆运算来恢复原始信号。例如,线性滤波器可以被设计为从噪声信号中提取出有用的信息,或者反之亦然,从有用信号中去除噪声。这种可逆性使得线性系统在理论和实际应用中都非常有用。
线性系统的另一个重要特性是它们的行为是可预测的。由于线性系统遵循确定的数学规则,我们可以很容易地分析和预测系统的行为。这使得线性系统在工程、物理学、经济学和其他许多领域中非常有用。
然而,需要注意的是,许多现实世界的系统并不严格线性。在这些情况下,我们可能需要使用近似方法或非线性理论来描述和分析系统的行为。尽管如此,线性理论仍然是理解和设计复杂系统的一个重要工具。

View File

@ -0,0 +1,50 @@
---
title: What's Stationary mean in Signal?
tags:
- advanced
- basic
- signal
- signal-processing
date: 2024-04-17
---
平稳描述的是信号的**统计特性不随时间变化**的特性。平稳性是许多信号处理算法和理论分析的基础假设,特别是在随机过程和时间序列分析中。
一个平稳信号需要满足两个主要条件:
1. **均值的平稳性**:信号的统计平均值(均值)不随时间变化。换句话说,无论我们何时观察信号,其平均值都保持不变。对于连续时间信号,这意味着信号的平均值对于所有时间点都是恒定的;对于离散时间信号,这意味着信号的平均值对于所有时间步长都是恒定的。
$$
\mu_x(n) = \mu_x
$$
均值与n无关即于哪次观察信号无关
2. **自相关函数的平稳性**信号的自相关函数仅取决于时间间隔而不是绝对的时间点。自相关函数是衡量信号在不同时间点的相似性的一种方法。对于平稳信号如果我们将信号在时间点t和时间点t+τ的值进行比较这种比较的结果即自相关只与时间间隔τ有关而与具体的时间点t无关。
$$
R_x(n,n+m) = R_x(m)
$$
自相关函数与时间n无关之与时移m有关
平稳信号具有Ergodicity即各态历经即多样本**集合平均**和单一样本**时间平均**相同
![](signal_processing/basic_knowledge/concept/attachments/Pasted%20image%2020240417144416.png)
$$
\mu_x=E\{x(n)\}=\lim_{M\rightarrow\infty}\frac{1}{2M+1}\sum_{n=-M}^Mx(n)
$$
$$
R_x(m)=E\{x(n)x(n+m)\}=\lim_{M\rightarrow\infty}\frac{1}{2M+1}\sum_{n=-M}^M x(n)x(n+m)
$$
在实际应用中,完全平稳的信号是非常罕见的。大多数实际信号都是非平稳的,它们的统计特性(如均值、方差、自相关等)会随时间变化。然而,有些信号可以**在一定的时间范围内近似为平稳**,这种信号被称为“**宽平稳**”(**Wide-Sense Stationary, WSS**)信号。宽平稳信号的统计特性在观察的时间范围内大致保持不变,这使得它们可以用线性时不变系统进行有效分析。
平稳信号的概念对于信号处理和系统分析非常重要,因为许多信号处理技术,如**傅里叶变换**、**功率谱密度分析**、**滤波器设计**等,都是基于信号的平稳性假设。如果一个信号不是平稳的,那么在应用这些技术之前,我们可能需要对信号进行预处理,如去趋势、差分、归一化等,以使其满足平稳性的要求,或者使用专门为非平稳信号设计的分析方法,如**非平稳时间序列分析**、**小波变换**、**经验模态分解**等。

View File

@ -0,0 +1,38 @@
---
title: Instantaneous Frequency
tags:
- advanced
- basic
- signal
- signal-processing
- Hilbert
date: 2024-04-17
---
在1998年EMD提出的时候信号的瞬时能量或瞬时包络的概念已被广泛接受。另一方面瞬时频率的概念一直备受争议。
接受瞬时频率的概念有两个基本困难,如下所示。第一个源于**傅里叶谱分析**根深蒂固的影响。在传统的傅里叶分析中,**频率被定义为跨越整个数据长度且幅度恒定的正弦或余弦函数**。作为该定义的扩展,瞬时频率还必须与正弦或余弦函数相关。因此,我们需要至少一次正弦波或余弦波的完整振荡来定义本地频率值。根据这个逻辑,没有比全波更短的了。**对于频率必须不时改变值的非平稳数据,这样的定义没有意义**。第二个困难源于定义瞬时频率的非唯一方法。
当时使用HilBert Transform来定义瞬时频率的方法当时仍然被Cohen (1995)等人认为存在矛盾;
这里就不对瞬时频率做过多的展开讨论,直接给出定义:
$$
Y(t) = \frac{1}{\pi} \text{p.v.} \int_{-\infty}^{\infty} \frac{X(t')}{t - t'}dt' \quad or \quad Y(t) = X(t) \ \ \text{conv} \ \ \frac{1}{t}
$$
$$
Z(t) = X(t) + iY(t) = \alpha(t)e^{i\theta(t)}
$$
$$
\alpha(t) = [X^2(t) + Y^2(t)]^{\frac{1}{2}}, \quad \theta(t) = \arctan(\frac{Y(t)}{X(t)})
$$
这里$\theta(t)$即为瞬时角度,瞬时频率则为,
$$
\omega = \frac{d\theta(t)}{dt}
$$
# Reference

View File

@ -7,16 +7,19 @@ date: 2024-03-18
---
# Basic
* [Random Signal Basic](signal_processing/basic_knowledge/random_signal_basic.md)
* [Fourier Transform](signal_processing/basic_knowledge/FT/fourier_transform.md)
* [Power spectral density estimation](signal_processing/algorithm/PSD_estimation/PSD_estimation.md)
* [FBW - Fractional Band Width](signal_processing/basic_knowledge/concept/FBW.md)
## Fourier Transform
## Classic Signal Processing
* [Fourier Transform](signal_processing/basic_knowledge/FT/fourier_transform.md)
* [Fourier transform pairs and properties derivation](signal_processing/basic_knowledge/FT/fourier_transform_pairs_derivation.md)
* [FBW - Fractional Band Width](signal_processing/basic_knowledge/concept/FBW.md)
* [What's Linear in Signal Mean?](signal_processing/basic_knowledge/concept/linear.md)
## Modern Signal Processing
* [Random Signal Basic](signal_processing/basic_knowledge/random_signal_basic.md)
* [Power spectral density estimation](signal_processing/algorithm/PSD_estimation/PSD_estimation.md)
* [What's Stationary mean in Signal?](signal_processing/basic_knowledge/concept/stationary.md)
* [Instantaneous Frequency](signal_processing/basic_knowledge/instantaneous_frequency.md)
# Devices and Components
* [✨Learn VNA in practical way](signal_processing/device_and_components/VNA_learn.md)
@ -49,7 +52,7 @@ date: 2024-03-18
## Empirical Mode Decomposition
* [EMD Basic](signal_processing/algorithm/EMD/basic.md)
# Software