diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 00000000..e69de29b diff --git a/2022/09/02/cpp-multi-file/index.html b/2022/09/02/cpp-multi-file/index.html new file mode 100644 index 00000000..09e4afa6 --- /dev/null +++ b/2022/09/02/cpp-multi-file/index.html @@ -0,0 +1,89 @@ +使用VSCode进行c++/c多文件开发 | Guo_Yun + + + + + + + + + + + + + +

使用VSCode进行c++/c多文件开发

前言

vscode是个非常优秀的跨平台编辑器,尤其在Linux上更为常用。在vscode上进行c++语言的编译、运行和调试已经有了很多教程,但是使用vscode进行多文件的c++编译、调试的教程却相对难找。以下整理出一个在VScode上搭建C++/C开发环境的全过程。

+

原理

在Linux上进行c++的多文件编译,主要依靠的是GNU的Makefile,使用make命令进行编译。而makefile的可读性差、语法复杂、跨平台性差等问题又催生了可以在多平台运行、语法简洁的CMake,用来自动生成Makefile。

+

CMake是一个语法简单的跨平台编译工具。只要编写CMakeLists.txt文件,然后使用cmake命令,就可以根据不同的平台生成合适的Makefile文件,再利用make命令即可编译文件。

+

问题是,Makefile是Linux的编译工具,怎么在Windows平台上使用呢?毫无疑问可以使用WSL,在Linux子系统中进行c++项目开发。

+

但是在Windows上使用Makefile也不是没有可能,只要安装GNU在Windows上的移植版——mingw就行了。MinGW中的mingw64-make即为Linux中的make。

+

实操

前置工作

没下载MinGW就去下一个。用处很多。

+

然后下载CMake。

+

Linux: sudo apt-get install make

+

Windows: 上官网下最新版。

+

配置CMakeLists.txt

首先将文件夹设置为项目名称。

+

然后在项目文件夹下添加CMakeLists.txt:

+
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# CMakeLists.txt
# cmake最低版本号要求
cmake_minimum_required (VERSION 3.0)
# # 设置指定的C++编译器版本是必须的,如果不设置,或者为OFF,则指定版本不可用时,会使用上一版本。
# set(CMAKE_CXX_STANDARD_REQUIRED ON)
# # 指定为C++03 版本
# set(CMAKE_CXX_STANDARD 03)

# 设置gdb为调试工具
# 构建模式设置为Debug
SET(CMAKE_BUILD_TYPE "Debug")
# 调试时使用gdb
SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g2 -ggdb")
# 发布时使用优化(1~3)
SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")

# 获取当前文件夹名称
string(REGEX REPLACE ".*/\(.*\)" "\\1" CURDIR ${CMAKE_CURRENT_SOURCE_DIR})
# 设置PROJECT_NAME变量
set(PROJECT_NAME ${CURDIR})
# 设置工程名
project (${PROJECT_NAME})
# 查找./src目录下的所有源文件并存入DIR_SRCS变量
aux_source_directory(src DIR_SRCS)
# 添加一个可编译的目标到工程
add_executable (${PROJECT_NAME} ${DIR_SRCS})
# 从./include中添加静态库, 必须写在add_executable之后
target_include_directories(${PROJECT_NAME} PUBLIC ./include)
message("PROJECT_NAME: ${PROJECT_NAME}")
message("CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}")
message("PROJECT_SOURCE_DIR: ${PROJECT_SOURCE_DIR}")
+ +

从上面的配置中可以分析出:源文件应该写在./src文件夹下,而头文件应该写在./include文件夹下。也可以改成其他目录。

+

代码什么意思在注释中写得很明白了,想要实现更多功能,可以上网查找CMake教程。

+

tasks.json配置–CMake构建,Makefile编译

在/.vscode下添加tasks.json:

+
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
{
"tasks": [
{
"label": "CMake",
"detail": "运行CMake",
"type": "shell",
"command": "CMake",
"args": [
"-G \"MinGW Makefiles\"", //这个参数指定CMake在mingw下使用makefile进行构建,如果去掉则使用默认的vs进行构建
"..",
],
"options": {
"cwd": "build"
},
"group": "build",
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared",
"showReuseMessage": true,
"clear": true
},
"problemMatcher": "$msCompile",
"dependsOn": [
"MkBuild"
]
},

{
"label": "MkBuild",
"detail": "建立build文件夹",
"type": "shell",
"command": "mkdir",
"args": [
"-p",
"build"
],
"windows": {
"args": [
"-Force",
"build"
]
},
"group": "build",
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared",
"showReuseMessage": true,
"clear": true
},
"problemMatcher": "$msCompile"
},

{
"label": "Make",
"detail": "使用Makefile编译",
"type": "shell",
"command": "mingw32-make",
"args": [
],
"options": {
"cwd": "build"
},
"group": "build",
"presentation": {
"reveal": "always",
"clear": true
},
"problemMatcher": "$msCompile",
},

{
"label": "Compile",
"detail": "仅编译。使用CMake --build编译,根据操作系统选择合适的编译器",
"type": "shell",
"command": "CMake --build .",
"options": {
"cwd": "build"
},
"group": "build",
"presentation": {
"reveal": "always",
"clear": true
},
"problemMatcher": "$msCompile",
},

{
"label": "Run",
"detail": "编译并运行程序",
"type": "shell",
"command": "start",
"args": [
"./${workspaceFolderBasename}.exe"
],
"group": "build",
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared",
"showReuseMessage": true,
"clear": true
},
"options": {
"cwd": "build"
},
"windows": {
"options": {
"cwd": "build" //exe文件所在的目录
}
},
"problemMatcher": "$msCompile",
"dependsOn": [
"Compile"
]
},
{
"label": "CMake and Run",
"detail": "创建Makefile, 编译并运行程序",
"type": "shell",
"group": "build",
"dependsOn": [
"CMake",
"Run"
],
"dependsOrder": "sequence"
},
{
"label": "CMake and Make",
"detail": "创建Makefile, 并编译",
"type": "shell",
"group": "build",
"dependsOn": [
"CMake",
"Make"
],
"dependsOrder": "sequence"
},
],
"version": "2.0.0"
}
+

这里面定义了一大堆Task,有的是编译并运行,有的是仅编译,有的是仅调用cmake,有的是调用CMake和make,使用时按下Ctrl + Shift + B选择合适的task, 看下中文解释就行。

+

唯一需要解释的一个Task就是MkBuild。MkBuild实际上就是执行mkdir -p build。会创建一个叫做build的文件夹。项目的中间文件和最后的可执行文件都会生成在这个文件夹里。后面调试时的文件路径也依赖于build文件夹。

+

推荐使用CMake and Make进行编译,使用Run进行运行。可以设置task的快捷键,参考网上资料。

+

注意:按照CMake在原理中的描述,它仅仅是作为生成Makefile文件的工具使用,但是如果运行cmake . --build,CMake就可以不依赖Makefile,自己寻找合适的编译器进行编译。Tasks中的Compile就是这样。此时CMake会根据平台自动选择合适的编译器。在Linux的平台上,CMake会选择g++, make等工具。而在Windows平台上, CMake大概率是不知道你安装了MinGW的,它会选择微软著名的编译器Visual Studio进行编译,还会顺带生成一个Visual Studio解决方案方便你调试。不过我既然都生成Visual Studio的C++工程了,直接用Visual Studio开发不是更香吗(笑)。

+

至此已经可以进行编译。

+

launch.json配置–gdb断点调试项目

新建launch.json:

+
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Debug", //名称
"type": "cppdbg", //调试类型,除使用msvc进行调试外,均为该类型
"request": "launch",
"program": "${workspaceFolder}/build/${workspaceFolderBasename}", //指定C/C++程序位置
"args": [], //指定运行参数
"stopAtEntry": false,
"cwd": "${workspaceFolder}/build", //指定工作目录
"preLaunchTask": "CMake and Make", //在调试前会先调用这个task编译构建程序
"environment": [],
"externalConsole": true,
"osx": { //macOS的特定配置
// "miDebuggerPath": "/Applications/Xcode.app/Contents/Developer/usr/bin/lldb-mi", //修改使用的lldb-mi,一般不需要修改
"MIMode": "lldb" //指定使用lldb进行调试
},
"linux": { //linux的特定配置
"MIMode": "gdb", //指定使用gdb调试
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
"windows": {
"MIMode": "gdb", //指定使用gdb调试
"miDebuggerPath": "C:/mingw64/bin/gdb.exe", //指定gdb的路径
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
}
]
}
+ +

默认调试按键是F5。打上断点,按下F5,系统自动运行CMake and Make编译程序。会有点慢。

+

注意:在CMakeLists.txt中有三句话:

+

SET(CMAKE_BUILD_TYPE "Debug")

+

SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g2 -ggdb")

+

SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")

+

分别是:项目构建方式设置为调试模式(如果是Release则是发布模式)、调试时使用gdb、发布时使用3级优化(有0~3级)。

+

至此可以进行调试。

+

tasks.json内容解释

待更新。

+

更进一步

手动配置文件虽然自由度高,但是还是挺麻烦。VSCode给我自动推荐了一个CMake插件叫做CMake Tools,好像也挺好用的,不知道后续能不能用插件一键生成多文件项目。

+

Tasks中的功能有点多了。之后尝试简化,方便使用。

+

gdb调试有个问题,就是长时间挂在一边不动,或者在监视窗口贸然输入一个变量进行监视时就有可能突然停止调试,错误信息闪了一下就消失了。稳定性还不行,原因未知。

+

这些配置还没有在Linux平台上尝试,可能需要进一步的测试和完善。

+

参考资料

使用VSCode和CMake构建跨平台的C/C++开发环境

+

cmake gdb 编译调试详解

+
\ No newline at end of file diff --git a/2022/09/13/DataAndAlgorithms/index.html b/2022/09/13/DataAndAlgorithms/index.html new file mode 100644 index 00000000..534f1ad5 --- /dev/null +++ b/2022/09/13/DataAndAlgorithms/index.html @@ -0,0 +1,848 @@ +笔记-数据与算法 | Guo_Yun + + + + + + + + + + + + + + + + + + +

笔记-数据与算法

相关资源

Princeton Algorithm 4th Edition

+

课程说明

课程内容

数据处理,数学模型,算法分析

+

非数值问题:

+

数据结构:线性表,栈,队列,串,树,图

+

非数值算法:查找,排序

+

数值问题:

+

误差分析

+

线性方程组

+

非线性方程

+

拟合与插值

+

最优化初步

+

算法设计:蛮力,分治、减治、贪心、动态规划、搜索算法

+

绪论

数据与算法

数学模型

对于现实世界的某一特定对象,为特定目的而得到的一个抽象的简化的数学结构。

+

算法

算法是问题的程序化解决方案。

+

算法强调精确定义的求解过程,并不是问题的答案。

+

设计实现算法,并没有得到答案,但是给出了一般的解决方案。

+

一个算法能够解决很多看似好无关系的问题,只要这些问题可以抽象为某种相同的算法。

+

数据

数据是客观世界的描述。

+

数据是信息的载体,是算法处理的对象。

+

算法是处理数据的系统。

+

人的因素也被纳入了数学模型的和算法。

+

IBM Watson

+

算法分析和算法设计

算法及其特性

算法的五个重要特性:

+

有穷性:一个算法必须可以在有穷步之后结束,且每一步可以在有穷时间内完成

+

确定性:算法的描述无歧义,算法的执行结果是确定的且精确地符合要求或期望

+

可行性:算法中描述的操作都可以通过已经实现的基本操作运算的有限次执行来实现

+

输入:一个算法有零个或多个输入,这些输入取自某个特定的对象集

+

输出:一个算法有一个或多个输出,输出量是算法计算的结果

+

算法的评价

正确性

不含语法错误

+

几组一般的输入数据

+

精心选择的、典型、苛刻且带有刁难性的输入数据(衡量标准)

+

一切合法的输入数据

+

健壮性

输入的数据非法

+

可读性

描述清楚,便于理解

+

高效率

占用的空间和时间资源

+

算法效率的衡量方法

和算法执行时间相关的因素有很多。

+

一个特定算法运行工作量的大小,是问题规模的函数。

+

渐进时间复杂度

算法的渐进时间复杂度(Time Complexity): $T(n) = O[f(n)]$

+

Big-O 记号的形式化定义

+
    +
  • 若 f(n)是正整数 n 的一个函数,则$x_n = O[f(n)]$表示存在正的常数$M$和$n_0$, 使得当$n > n_0$时,都满足$|x_n| \le M|f(n)|$
  • +
  • 标记的是算法效率的上限
  • +
+
算法效率估算方法
    +
  • 算法执行的时间 = Σ 操作的执行次数 × 操作的执行时间
  • +
  • 算法操作包括控制操作原操作
    一般来说,相比于循环体,控制操作本身的复杂度可被忽略。而在原操作中,我们又可以寻找其中执行次数最多的一种或几种操作,这些操作被称为基本操作。
  • +
  • 选取算法中的基本操作
  • +
  • 算法的执行时间与基本操作执行次数之和成正比
  • +
+
描述指标
    +
  • 最好情况(best-case):对于任何一个输入的运行时间下限
  • +
  • 最坏情况(worst-case):对于任何一个输入的运行时间下限
  • +
  • 平均(average-complexity): 根据各种操作出现概率的分布进行加权平均
  • +
  • 分摊(amortized complexity): 连续实施足够多次操作,总成本摊至单次操作
  • +
+

最重要的是平均情况下的性能

+
引入大 O 表示的渐进时间复杂度和空间复杂度实际上是建立了算法效率分析的数学模型
迅速找到会被多次反复执行的基本操作
感兴趣的复杂度形式非常有限
按照对数坐标画图

空间复杂度

算法空间
    +
  • 指令空间(instruction space): 用来存储程序指令所需的空间
  • +
  • 数据空间(data space): 存储运行过程中常量和变量所需的空间
  • +
  • 环境空间: 系统为程序运行,特别是函数调用提供的空间
  • +
+
算法的渐进空间复杂度: $S(n) = O[f(n)]$
输入数据所占空间只取决于问题本身,和算法无关,则只需要分析输入和程序之外的额外空间

数据结构

数据元素和数据项

数据元素(Data Element): 数据的最小单位

+

数据项:(Data Item): 数据结构中讨论的最小单位

+

数据结构是带结构的数据元素的集合

逻辑结构:集合,线性结构,树结构,图结构

+

存储结构:顺序存储,链式存储

+

二元关系

定义

定义:设有几何$M, N$, 其笛卡尔积$M \times N$的任意一个子集$R \in M \times N$

+

二元关系表示了集合$M$和集合$N$中元素之间的某种相关性。

+

若$(a, b) \in R$, 则称$a$为$R$的前件,$b$称为$R$的后件。

+

若$M = N$, 则称$R \sub M \times M$为 M 上的二元关系。

+
二元关系的性质

设$R$为集合$M$上的一个二元关系:

+

(1) 自反性:对于每个$a \in M$, 有 $(a, a) \in R$;

+

反自反性: 对于所有$a \in M$, 有$(a, a) \notin R$;

+

(2) 对称性:当$(a, b) \in R$时,则$a = b$;

+

反对称性:当$(a, b) \in R$且$(b, a) \in R$时,必有$a = b$;

+

(3) 传递性: 当$(a, b) \in R$且$(b, c) \in R$ 时, 必有$(a, c) \in R$。

+
常见的二元关系

等价关系:满足自反性、对称性、传递性

+

偏序关系:满足自反性、反对称性、传递性

+

全序关系:若$M$中的任意两个元素$a$和$b$是可比的,也就是说或者有$aRb$成立,或者有$bRa$成立,则称$R$是集合$M$上的全序关系(Totala Order Relation)

+

数据类型(Data Type)

C 语言中的类型定义

五种基本数据类型:字符型,整型,浮点型,双精度浮点型和无值类型

+

程序中任何变量,常量都必须先定义类型。

+

整数类型 int 及定义在其上的操作:+, -, *, /, %, ++, –

+

双精度浮点型 double 及定义在其上的操作:+, -, *, /, ++, –

+
数据类型用来刻画(程序)操作对象的特性

数据类型是一个元素的集合和定义在此集合上的一组操作的总称。

+

数据类型实现了信息的隐藏,把一切用户无需了解的细节封装在类型中。

+

高级语言中的数据类型分为原子类型和结构类型。

+

抽象数据类型(Abstract Data Type, ADT)

是指一个数学模型以及定义在此数学模型上的一组操作。

+

数据抽象:描述的是实体的本质特征、功能以及外部用户接口

+

数据封装:将实体的外部特性和内在实现细节发呢里,对外部用户隐藏内部实现细节,使得应用和实现分离

+

ADT 的优点:

+
    +
  • 程序结构清晰,易于扩展易于维护而不失其效率
  • +
  • 提高程序的数据安全性
  • +
  • 大大增加了软件的复用程度
  • +
+

抽象数据类型的描述

1
2
3
4
5
6
7
8
ADT 抽象数据类型名{
数据对象: <数据对象的定义>
数据关系: <数据关系的定义>
基本操作: <基本操作的定义>
基本操作名(参数表)
初始条件: <初始条件描述>
操作结果: <操作结果描述>
}ADT 抽象数据类型名
+ +

基本操作参数:

+
    +
  • 赋值参数提供输入值
  • +
  • 引用参数以&打头,用于返回操作结果
  • +
+

数据结构

线性表

线性表的元素可以是各种各样的,但是同一线性表的元素必然具有相同特性-同质

+

线性表中的相邻元素之间存在有序关系-位序

+

线性表是一种“有序结果”,即在数据元素的非空有限集合中

+
    +
  • 存在唯一的一个被称为“第一个”的数据元素,无前驱;
  • +
  • 存在唯一的一个被称为的“最后一个”的数据元素,无后继;
  • +
  • 除第一个之外,每一个数据元素均只有一个直接前驱;
  • +
  • 除最后一个之外,每个数据元素均只有一个直接后继
  • +
+

线性表中元素个数定义为线性表的长度

+
$$(a_0, a_1, \dots, a_{i-1}, a_i, a_{i+1}, \dots, a_{n-1})$$
+ +

若线性表为空,则其长度为 0,称为空表

+

在非空表中,每个数据元素都有一个确定的位置

+
    +
  • $a_0$是第 0 个数据元素,$a_{n-1}$是第$n-1$个数据元素
  • +
  • $a_i$是第 i 个数据元素
  • +
  • 称 i 为数据元素$a_i$在线性表中的位序
  • +
+

线性表 ADT

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
ADT List{
数据对象:
数据关系:
基本操作:
InitList(&L);
操作结果:构造一个空的线性表L。
DestroyList(&L);
初始条件:线性表已存在。
操作结果:销毁线性表L。
IsEmpty(L);
初始条件:线性表已存在。
操作结果:若L为空表,则返回TRUE,否则返回FALSE。
ListLength(L);
初始条件:线性表L已存在。
操作结果:用e返回L中第i个数据元素的值
GetElem(L, i, &e);
初始条件:线性表L已存在。
操作结果;用e返回L中第i个数据元素的值。
LocateElem(L, e, compare());
初始条件:线性表L已存在,compare()是数据元素判定函数。
操作结果:返回L中第1个与e满足关系compare()的数据元素的位序。若这样的元素不存在,则返回-1
PriorElem(L, cur_e, &pre_e);
初始条件:线性表L已存在。
操作结果:若cur_e是L的数据元素,且不是最后一个,则用next_e返回它的后继,否则操作失败,next_e无定义。
ClearList(&L);
初始条件:线性表L已存在;
操作结果:将L重置为空表。
ListInsert(&L, i, e);
初始条件:线性表L已存在, 0 <=i <= ListLength(L)。
操作结果:在L中第i个位置插入新的数据元素e,L的长度加1
ListDelete(&L, i, &e)
初始条件:线性表L已存在,0 <= i <= ListLength(L) - 1
操作结果:删除L的第i个数据元素,用e返回其值,L的长度减1
ListTraverse(L, visit());
初始条件:线性表L已存在。
操作结果:依次对L的每个数据元素调用函数 visit()。

+ +

线性表的合并:$O(m+n)$

+

线性表的保序归并:$O(m+n)$

+

线性表的顺序存储:顺序表

+
    +
  • 用一组地址连续的存储单元依次存储线性表的数据元素
  • +
+

顺序表的主要操作:

+

插入操作:在顺序表的第 i 个位置插入一个新元素,使顺序表的长度增加到$n+1$

+

复杂度分析:

+
    +
  • 在顺序表的第$i$个位置插入一个新元素,需要移动$n - i$个元素;
  • +
  • 假设从顺序表的第$i$个位置插入元素的先验概率为$p_i$
  • +
  • 插入操作移动元素次数的期望为$E_{insert} = \sum_{i = 0}^n(n - i) \times p_i$
  • +
+

删除操作:把顺序表的第$i$个位置的元素从表中删除,使长度为$n$的顺序表的长度变为$n - 1$

+

复杂度分析:

+
    +
  • 把顺序表的第$i$个位置上的元素删除,需要移动$n - i -1$个元素
  • +
  • 假设从顺序表的第$i$个位置删除元素的先验概率为$q_i$
  • +
  • 删除操作移动元素次数的期望为: $E_{delete} = \sum_{i = 0}^{n - 1}(n - i - 1) \times q_i$
  • +
+

不失一般性,我们假设插入或删除元素出现在任何位置的概率都是相等的,因此有$p_i = p = 1/(n+1), q_i = q = 1/n$。

+

推导得到:

+
$$E_{insert} = \frac1{n+1}\sum_{i = 0}^n(n-i) = \frac n2\newline E_{delete} = \frac1n\sum_{i = 0}^{n - 1}(n - i - 1) = \frac{n - 1}2$$
+ +

单向链表

最简单的链表结构:链表节点(node)由两个域组成。

+

数据域:存储数据元素,

+

指针域:指向直接后继节点

+

单向链表的 C++实现:

+
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class LinkList {
private:
NODE *head;
public:
LinkList() {head = NULL;}
~LinkList();
bool clearSqList();
bool IsEmpty(){return head == NULL;}
bool GetElem(int i, int *e);
int LocateElem(int e);
bool PriorElem(int cur_e, int *next_e);
bool NextElem(int cur_e, int* pre_e);
bool Insert(int i, int e);
bool Delete(int i, int *e);
bool Traverse(bool (*visit)(int e));//遍历所有节点
}

+ +

单向链表的不足:

+
    +
  • 单链表的表长是一个隐含的值,遍历链表才能得到
  • +
  • 在单链表中插入或者删除元素时,需要在链表中依序寻找操作位置
  • +
  • 在链表中,元素的“位序”概念淡化,结点的“位置”概念强化
  • +
  • 如何得到某个元素的前驱?
  • +
+

改进链表的设置:

+
    +
  • 增加“表长”、“表尾指针”和“当前位置指针”三个数据域

    +
  • +
  • 将基本操作中的“位序i”改为“指针p”

    +
  • +
+

双向链表

由数据,前驱和后继构成。

+

方便寻找前驱,但是增加了维护成本。

+

顺序表和链表的比较:

顺序表

+

用一组地址连续的存储单元依次存储线性表中的数据元素

+

优点:可以随机存取

+

缺点:插入,删除操作需要移动表中的数据元素,事先确定规模,空间效率不高。

+

链表:

+

用一组“任意”的存储单元(附加指针)存储表中的数据元素

+

优点:插入,删除操作无需移动表中的数据元素,空间利用率高

+

缺点:不能随机存取

+

栈是LIFO(Last In First Out,先进后出)的线性表。

+

允许插入和删除的一段称为栈顶(top), 另一端称为栈底(bottom)

+

栈的ADT

1
2
3
4
5
{
Push(&s, e);
Pop(&s, &e);
ClearStack(&s);
} ADT Stack;
+ +

栈的表示和实现

栈的顺序表示

+

top指向最后一个元素可以,指向空也可以,但是实现时要自洽。

+

栈的链式表示

+

有头插入和尾插入两个方式

+

总体来看,头插入比尾插入的优势要更大。首先,插入时虽然头插入要修改的指针更多,但是时间复杂度小,头插入$O(1)$,尾插入$O(n)$。其次,如果以尾部为栈顶,删除时会很麻烦。

+

静态分配

+
1
#define STACK_MAX_SIZE 100
+

动态分配

+

程序隐含设定

+
1
2
#define STACK_INT_SIZE 100
#define STACKINCREMENT 10
+ +

用户给定

+

复杂度分析

顺序栈的效率分析

+

时间复杂度

+
    +
  • 进栈、出栈:$O(1)$
  • +
  • 栈的溢出处理
  • +
  • 如果栈元素时简单数据类型,则构造和销毁函数也是$O(1)$的
  • +
+

空间复杂度

+
    +
  • 顺序栈的长度构造时确定
  • +
  • 空间利用效率低
  • +
+

链式栈的效率分析

+

时间复杂度

+
    +
  • 链式栈的入栈出栈是$O(1)$时间的
  • +
  • 建立和销毁是$O(n)$时间的
  • +
+

空间复杂度

+
    +
  • 一般不会产生溢出
  • +
  • 空间利用率高
  • +
+

栈的一些应用

显式应用:括号匹配,表达式求值,迷宫求解

+

隐式应用:函数调用,递归

+

系统栈

+

递归

栈与递归具有相似性。

+

Fibonacci的递归次数:$C(n) = O(t^n)$

+

(证明思路:归纳法证明$C(n) = 2F(n) - 1$, 根据F(n)通项可以判断。)

+

使用递推法的时间复杂度:$O(n)$.

+

经常需要进行递归的消除。消除方法:递推,循环等,没有统一的解决方案。可以借用显式栈实现非递归过程。

+

递归的评价:

+
    +
  • 简洁,便于理解,便于叙述和设计
  • +
  • 运行效率低,无法控制递归堆栈的规模
  • +
+

队列

队列是FIFO(First In First Out, 先进先出)的线性表。

+

队列的表示和实现

队列的顺序表示法

+

入队: rear = rear + 1

+

出队: front = front + 1

+

需要判定队满和队空。

+

顺序队列的问题:被出队的空间不会再次被使用了。

+

循环队列:

+

队尾指针指向maxSize - 1时, 入列则指向0;

+

队头指针指向maxSize - 1,出列也指向0。

+

可以使用模运算实现。

+

缺点:无法区分队空和队满的状态。

+

区分方法:

+

设置一个空位;设置标志;设置队列长度变量

+

队列的链式表示法

+

入队不会出现队满的问题,出队可能回有队空的问题,队空的条件为front = NULL.

+

串是有线长度的字符序列。

+

串的长度是字符个数。

+

字符在串中的位置。

+

两个串相等的条件。

+

子串和主串,子串在主串中的位置。

+

匹配算法

Brute-Force算法:一个一个比。复杂度最高O(m * n)。

+

KMP算法:尽可能跳过更多不必要的匹配。复杂度最多O(m + n)。

+

Horspool算法:启发式算法。复杂度低则O(m/n),高则O(m * n + s),s为字符表规模

+

Boyer-Moore算法:最坏O(n)。KMP和Horspool的综合(或者说Horspool是BM算法的简化版本。)

+

树与二叉树

空树,子树。

+

结点(node)是树的基本单位。

+

结点的度(degree):结点的子树个数。

+

树的度:结点度的最大值。

+

k叉树:树的度为k

+

child, parent, cousin, ancestor, descendant

+

depth/height

+

树的性质:

+
    +
  1. 树中结点数等于所有结点度数和加一
  2. +
  3. k叉树第i层至多$k^{i - 1}个结点$
  4. +
  5. 深度为h的k叉树至多有$(k^h - 1)/(k - 1)$个结点
  6. +
  7. 具有n个结点的k叉树的最小深度为$[\log_k(n(k - 1) + 1)]$
  8. +
+

二叉树

二叉树是结点的一个有限集合,该集合或者为空,或者是由一个根节点加上两棵分别称为左子树和右子树的、互不相交的二叉树组成。

+

二叉树的性质:

+
    +
  1. 叶子结点数 = 度为二的结点数 + 1
  2. +
  3. 第i层至多$2^{i - 1}$个结点
  4. +
  5. 深度为h,则最多有$(2^h - 1)$个结点
  6. +
  7. 具有n个结点的完全二叉树的深度为$\lceil\log_2(n + 1)\rceil$
  8. +
  9. 对于完全二叉树(最后一层从右向左缺若干结点),从左向右,从上到下编号,则$\lfloor(i - 1)/2\rfloor$为编号i的parent结点,$2i + 1$为其左子树,$2i + 2$为其右子树。
  10. +
+

二叉树的顺序表示

+

完全二叉树按照编号存储。不完全二叉树按照它对应的完全二叉树存储,但是缺少的部分留空。

+

不完全二叉树结点越少,空间效率越低。

+

二叉树的链式表示

+

空间效率很高。

+

二叉树的遍历:

+

记根节点为V,遍历左子树为L,遍历右子树记为R

+

先序遍历:V - L - R

+

中序遍历:L - V - R

+

后序遍历:L - R - V

+

遍历可以通过递归实现,但是递归可能会对效率产生影响。可以利用栈的特性实现遍历。

+

层序遍历:从上到下优先遍历同一层的结点。

+

遍历实现了树的线索化过程。

+

霍夫曼树

霍夫曼树:寻找加权路径长度(WPL)的最小树。

+

用途:实现性能最好的变长二进制编码。

+

霍夫曼编码不是唯一的,但是所有霍夫曼树的WPL都相等。

+

不足:

+

没有错误保护功能

+

二叉树的建立

只知道二叉树的先序序列,不能确定这棵二叉树。

+

但是如果同时知道先序序列和中序序列,则可以确定这棵二叉树。

+

概念

图的定义

+

顶点,边,弧

+

邻接顶点

+

有向图,无向图

+

有向完全图,无向完全图

+

子图

+

握手定理,度

+

权,网络
边上的数叫做权。有权的图叫网络。

+

连通

+

连通图

+

连通分量
无向图的极大连通子图为连通分量。(所谓极大,就是再加入一个点都会导致它不连通)

+

强连通图
有向图中存在vi到vj且存在vj到vi的图。

+

强连通分量
有向图的极大强连通子图为强连通分量。

+

Euler路径和Euler回路

+

图的存储和表示

+

邻接矩阵表示
如果v和w之间有边,则元素为1,否则为0.

+

邻接表表示
采用链表数组表示图。同一个顶点发出的边在同一个链表中。

+

图的遍历

深度优先遍历和广度优先遍历

+

图的遍历:从已给连通图的某一顶点出发,沿着一些边访问所有顶点,且每个顶点只访问一次,则叫做图的遍历。

+

邻接矩阵的遍历:$O(v^2)$

+

邻接表的遍历:$O(v + e)$

+

生成树

连通图的生成树,包含图中全部n个顶点,但只有n-1条边。

+

深度优先和广度优先遍历分别会得到一个搜索树。

+

最小生成树:权值之和最小的生成树。

+

求最小生成树的算法:贪心算法思想。Kruskal算法和Prim算法。

+

Prim算法

+

+

Prim算法的时间复杂度为$O(n^2)$。对稠密图而言是线性的。对于稠密图而言,Prim的邻接矩阵实现是首选方法。

+

Kruskal算法

+

Kruskal的时间复杂度为$O(E\log E)$。

+

Kruskal算法对于稀疏图是好的选择。

+

最短路径树

从根到其他顶点的最短路径

+

源点-汇点最短路径:给定一个起始顶点s和一个结束顶点 ,在图中找出从s到t的一条路径。起始顶点称为“源点”,结束顶点称为“汇点”

+

单源最短路径:给定一个起始顶点s,找出从s到图中其它各顶点的最短路径

+

全源最短路径:找出连接图中各对顶点的最短路径

+

单源最短路径

Dijkstra算法

+

+

Dijkstra算法通过构造加权有向图图的最短路径树SPT,来实现单源最短路径算法。

+

时间复杂度为$O(v^2)$,和Prim算法很相似。

+

全源最短路径

可以对每个顶点用Dijkstra算法。

+

Floyd算法

+

时间复杂度:$O(v^3)$。可以计算出一个网络中所有的最短路径。

+

Floyd算法允许图中带有负权值的边,但不允许有包含带负权值的边组成回路。

+

算法

非数值算法

查找

查找算法的复杂性:关键字/数据规模

+

查找算法的分类:

+
    +
  • 内部/外部
  • +
  • 静态/动态
  • +
+

查找表

查找表(Search Table)是由同一类型数据元素构成的集合。

+

按关键字查找

+
    +
  1. 查询某元素是否存在
  2. +
  3. 检索某数据元素的各种属性
  4. +
  5. 在查找表中插入一个数据元素
  6. +
  7. 从查找表中删除一个数据元素
  8. +
+

查找表的种类

+
    +
  1. 静态查找表-仅可执行1,2
  2. +
  3. 可执行1,2,3,4
  4. +
+

平均查找长度:在查找过程中,为确定目标在查找表中的位置,需要进行关键字比较次数的期望值

+
$$ +ASL = \sum_{0}^{n - 1}P_i C_i +$$
+ +

$P_i$为第i条记录的查找概率,$C_i$为第i条记录的查找长度。

+

有时我们会假设查找概率相等或不等,有时要考虑查找失败的比较次数。

+

ASL越小,查找性能越好。

+

顺序查找:又称线性查找,是从线性
表的一端开始,依次把每个元素的
关键字同给定值进行比较

+

假设每个元素的查找概率相等,则平均查找长度为:$ASL = \sum_0^{n - 1}\frac{i + 1}{n} = \frac{n + 1}{2}$。

+

更多考虑:查找概率不等;查找失败需要N次比较;越界判断

+

折半查找:如果顺序表有序,我们可以采用高效率的折半查找

+

折半查找可以用一个二叉树结构来表述。比较次数不会超过$\lfloor\log_2 N + 1\rfloor$。

+

索引查找:将线性表划分为若干子表,再建立指向这若干子表的一个索引表。相同性质的数据归类到一个子表中。

+

索引表:顺序表或链表

+

子表:顺序表或链表

+

因而可以有四种不同的索引存储方式。

+

索引表的特点:表不大, 表中元素不常变动。因而适合用顺序表来表示索引表。

+

分块查找:也称索引顺序查找,是顺序查找的改进。子表之间有序;块内元素无序。索引表包括关键字项,指针项,子表长度。

+

索引文件:单关键字,多关键字。

+

稠密索引:索引表的索引项和主文件的各记录一一对应,称为稠密索引。

+

稀疏索引(非稠密索引):索引项对应主文件的一部分记录。

+

索引文件的好处:减少访问外存的次数,提高查找速度。

+

倒排文件:不同之处是辅索引表包含物理地址序列。(为什么要倒排?)

+

二叉搜索树(BST)

或者是一棵空树,或者是具有下列性质
的二叉树:每个结点有一个关键字(key),
并且:

+
    +
  1. 任意结点关键字大于等于该结点左
    子树中所有结点含有的关键字
  2. +
  3. 同时该结点的关键字小于等于右子
    树中所有结点含有的关键字
  4. +
+

BST是一种重要的动态搜索结构。它的中序遍历是确定的。

+

BST的插入操作和查找操作同样简单。

+

删除操作比较复杂。叶子结点的删除比较简单;如果结点只有一棵子树,也比较简单;如果左右子树都不空,可以用中序后继替换。

+

BST的性能:越“平衡”越好。

+

二叉搜索树的路径长度和高度直接关系到BST中搜索的开销,对于一棵
含有N个关键字的BST

+
    +
  • 最好情况下,所有搜索都可以保证对数运行时间
  • +
  • 最坏情况下,进行一次搜索需要 次比较
  • +
  • 平均情况下搜索需要 次比较操作
  • +
+

BST的旋转操作:结点和一个子孙交换角色。分为左旋转和右旋转。右旋转涉及到结点和右孩子。(右旋转和左旋转是以结点自己作为参考系而言。)

+

BST通过不断的旋转来保证自己的平衡性。

+

AVL树:
一棵AVL树或者是空树,或者是具有下列性质的二叉搜索树:

+
    +
  1. 左子树和右子树都是AVL树
  2. +
  3. 且左子树和右子树的高度之差的绝对
    值不超过1
  4. +
+

AVL的高度为$O(\log_2 n)$,平均查找长度也为$O(\log_2 n)$。

+

AVL具有良好的搜索性能,能够避免一般BST性能恶化的问题。但是AVL的维护比较复杂,在进行插入和删除操作后,都必须通过大量的旋转操作保证AVL的平衡性。

+

寻找其他方法,以提高BST的平衡程度,保证BST的性能。

+
    +
  • 实用的平衡二叉搜索树-红黑树

    +
  • +
  • 多路平衡的动态查找结构-B-树

    +
  • +
+

散列

散列的关键是散列函数和冲突处理。

+

散列函数应是简单的,能在较短的时间内计算出结果

+

散列函数的定义域必须包括需要存储的全部关键码,如果散列表允许有m
个地址,其值域必须在0到m-1之间

+

理想的散列函数应近似为随机的,对每一个输入,相应的输出在值域上是
等概的。

+

冲突处理:

+
    +
  • 链地址法:把散列到同一个地址的关键字存进链表中。(表长小于元素数目)
  • +
  • 开放定址法:放在表中空的位置。查找时采用“探测”的方法。如果探测下一个位置,称为线性探测。(表长大于元素数目,稀疏表,一般不允许表达到半满状态)
  • +
  • 双重散列法:用第二个散列函数表达散列的增量。时间复杂度略大,但是性能比线性探测好很多。
  • +
+

散列的其他应用:字符串的匹配;搜索引擎对URL的散列;信息安全中的内容鉴别技术(MD5, sha)。

+

散列提供常数时间的查找性能,实现简单;但是好的散列函数不易找到,删除操作和空间性能不好,最坏情况下性能不好,忽略了数据间的逻辑关系。

+

排序

排序算法的稳定性:如果两个对象的排序码相等,排序前后的顺序不变,则是稳定的;否则是不稳定的。

+

内排序:数据对象存放在内存。

+

外排序:数据对象在内、外存之间移动。

+

冒泡排序:复杂度为$O(n^2)$。添加排序标记,最好情况下只需要$n - 1$次比较和0次交换。

+

插入排序:有直接插入,折半插入,希尔排序

+

直接插入:$O(n^2)$

+

折半插入:查找插入位置的时候可以采用折半查找,因为表中可以插入的部分已经排好序了。复杂度没有变化,依然是$O(n^2)$

+

希尔排序:如果序列中,间距为h的元素都有序,称这个序列为h-排序的。希尔排序就是不断缩小h,直到h=1。

+

选择特定的步长序列$h_n$,取出序列中增量为$h_n$的子列进行插入排序。然后取$h_{n-1}$,直至取$h_1=1$。

+

它在h比较大的时候排序,由于间距短,速度快;而h小的时候,由于有序性强,速度快。总体速度依赖于步长序列的选择,时间复杂度比直接插入好一些。

+

选择排序:比较次数$O(n^2)$,移动次数$O(n)$,移动次数少一些。

+

冒泡排序和插入排序都是稳定的,而选择排序是不稳定的。

+

快速排序:一种交换类排序。具有很好的性能。

+

将待排序序列分为两个部分,满足:

+
    +
  1. a[i]位于它在序列中的正确位置
  2. +
  3. 前面的元素比a[i]小
  4. +
  5. 后面的元素比a[i]大
    然后对两个部分继续划分,每次划分都将一个元素划分到它的正确位置。
  6. +
+

如何划分:

+

选择划分元素v。从序列左边扫描,找到一个比v大的元素,从右边扫描,找到一个比v小的元素,交换两个元素。反复交换,直到左右扫描指针相遇,则划分完成。

+

快速排序的递归树是一颗二叉搜索树,因为每次递归都是对比自己大和比自己小的两个部分递归。

+

时间复杂度:理想情况下$O(N\log_2N)$,如果递归树是平衡的。平均情况下为$O(N\log N)$,而最坏情况下退化为$O(N^2)$。

+

快速排序是不稳定的排序算法。

+

改进:

+

划分元素是最大或者最小的元素时是最坏情况。为了避免最坏情况,采用中间元素法:取序列的左端元素,右端元素和中间元素,选择关键字处于中间的元素作为划分元素。

+

快速排序中,子序列非常小时仍然要递归调用,可以采用插入排序代替,提高效率。

+

归并排序:合并有序表。两个表的归并,叫二路归并。利用二路归并可以实现归并排序。

+

自底向上归并:将文件分割成长度为m的子序列,每次m翻倍。

+

自顶向下归并:将文件分割为两个部分,分别进行递归的归并排序后再合起来进行归并排序。

+

归并排序是稳定的,时间最好情况是$O(N\log N)$,最坏是$O(N^2)$.

+

堆:堆是满足堆性质的完全二叉树。

+

最大堆:任意节点的值小于父节点的值。

+

最小堆;任意节点的值小于父节点的值。

+

因为是完全二叉树,适合用顺序存储方式。

+

堆:顺序存储在一维数组中。

+

堆的操作,例如插入,删除或者修改结点会破坏堆的性质,因此修复堆是重要的操作。

+

对于最大堆,如果某结点的关键值小于其子节点的关键值,可以采用自顶向下堆化(Heapify-down)的算法进行修复。

+

对于最大堆,若结点的关键值大于父节点的关键值,采用自底向上堆化(Heapify-up的算法进行修复)

+

向堆中插入结点:在新节点插入堆尾,调用自底向上算法调整堆。这种构造堆方法称为自顶向下的堆构造。

+

自顶向下的堆构造:$O(N\log N)$

+

自底向上的堆构造:时间复杂度$O(N)$

+

自底向上构造复杂度小的原因:离根远的复杂度小,离根近的复杂度大。而自顶向下是离根远的复杂度大,离根近的复杂度小。离根远的数量多,而离根近的数量少,因此自底向上的整体的复杂度更小。

+

优先级队列可以用堆实现,性能非常好。

+

堆排序:节约空间,比较次数和移动次数都是$O(N\log N)$。堆排序是不稳定的排序方法。

+

从小到大排序的方法:自底向上构造最大堆。将堆首与堆尾交换,堆序列长度-1,调整堆,再次交换,重复上述过程,直到堆空。

+
+

堆排序大概可以理解成优先队列的出队过程。

+
+

采用决策树的方法可以求得比较次数的下界为$O(N\log N)$

+

数值算法

基础

一个数值问题是适定的(well posed),需要满足:

+
    +
  • 解存在
  • +
  • 解唯一
  • +
  • 连续地依赖于问题数据
  • +
+

不满足条件的问题被称为不适定的(ill-posed)。

+

适定的问题,如果解对输入数据非常敏感,则称之为病态的(ill-conditioned)。

+

针对适定和良态(well-conditioned)问题,数值分析可以得到具有一定精度的近似解。

+

数值分析重视误差。误差=计算误差+传播误差,算法影响的是计算误差。误差有模型误差、测量误差、截断误差、舍入误差。

+

前向误差反映了输出的误差,后向误差反映了输入的误差。相对前向误差与相对后向误差的比值叫做条件数(condition number)。$cond \le 1$说明问题是良态的;否则是病态的。

+

实际问题中我们通常求解条件数的估计值或者上限。进而求得前向误差。

+

相对条件数:$\left|\frac{xf^\prime (x)}{f(x)}\right|$。绝对条件数:$\left|f(x)\right|$

+

算法的稳定性:如果一个算法对于计算过程中的微小扰动不敏感,则算法是稳定的。

+

问题的病态性针对输入数据的微小扰动,而算法的稳定性针对的是计算过程中的误差。

+

最近舍入法:与x最相近的浮点数,如果相等,取最后一个存储位为偶数。

+

若是偶数,则区间是闭区间;若是奇数,则对应的区间为开区间。

+

浮点数的下溢限主要由尾数决定,机器精度由尾数决定。

+

浮点数的表示法:

+
$$ +x = \pm \left(d_0 + \frac{d_1} \beta + \frac{d_2} {\beta^{2}}+ \dots + \frac{d_{p-1}} {\beta^{p-1} } \right)\beta^E +$$
+ +

在正规化浮点数系统中:

+
$$ +\text{UFL}=\beta_L\\ +\text{OFL}=\beta^{U+1}(1 - \beta^{1-p})\\ +$$
+ +

机器精度:舍入造成的相对误差上限:

+
$$ +\left|\frac{fl(x) - x}{x}\right| \le \epsilon_{mach} +$$
+ +

最近舍入方式下:

+
$$ +\epsilon_{mach} = \beta^{1-p} / 2 +$$
+ +

线性方程求解

解矩阵方程$A\mathbb x = \mathbb b$。

+

误差分析:

+

条件数:$\text{cond}(A) = ||A||||A^{-1}||$

+

直观理解:两条线接近平行的时候,两条线截距的轻微扰动会造成解很大的不确定性。

+

解方程:

+

直接求解法

+

高斯消元法:复杂度$O(n^3)$。通常采用列选主元的方法提高算法的稳定性。

+

LU分解:如果$b$变化而$A$不变,可以较快地多次求解。

+

解的精度分析:条件数大,即使残差很小,也会得出极大的计算误差。是因为问题本身非常敏感。

+

高斯-约当法:把A变换为对角阵。

+

乔列斯基分解:A是对称正定阵,则A=LL’。

+
    +
  • 算法是良态的
  • +
  • 不需要选主元就有稳定性
  • +
  • 只需要存储下三角部分即可
  • +
  • 分解的乘法和加法次数都约为$n^3/6$
  • +
+

线性方程的迭代解法:

+

不动点迭代法:

+
$$ +Ax = b \Rightarrow x = Gx + C +$$
+ +

不动点迭代的收敛核心在于G。

+

对于矩阵M,定义谱半径$\rho(M)$为M的特征值绝对值的最大值。

+

如果$\rho(G)< 1$,则不动点迭代收敛。

+

分裂$A = M - N$,则

+
$$ +(M - N)x = b\Rightarrow\\ +x = M^{-1}Nx + M^{-1}b +$$
+ +

当$\rho(M^{-1}N) < 1$时,不动点迭代收敛。

+

Jacobi(雅克比)方法:$A = D + L + U$, $M = D$, $N = - (L + U)$, $x^{k+1} = D^{-1}[b - (L+U)x^k]$。

+

高斯-赛德方法:
$A = D + L + U$, $M = D + L$, $N = -U$, $x^{k+1} = (D+L)^{-1}(b - Ux^k)$。

+

这两种迭代都不一定收敛,但是实际中一般都可以。高斯赛德方法速度比雅克比快一倍。

+

非线性方程求解

误差分析:

+

非线性方程$f(x) = 0$,真解为$x^*$,近似解为$\hat x$。

+

残差:$||f(\hat x)||$

+

前向误差:$||\hat x - x^*||$,能更准确地描述解的精确程度。

+

绝对条件数:$1/|f^\prime(x^*)|$

+

可见,如果f(x)在$x^*$处接近水平,则问题是病态的。

+

具有重根的问题也是病态的。

+

解法:

+

二分法:定义误差$e_k = x_k - x^*$,定义迭代法的收敛速度定义:$\lim_{k\rightarrow \infty}\frac{||e_{k + 1}||}{||e_k||^r} = C$,则收敛速度为$r$。r=1称为线性的,r>1称为超线性的,r=2称为平方的。二分法的迭代次数与函数的具体形式无关。

+

不动点迭代法:

+

收敛性:

+
$$ +\lim_{k\rightarrow \infty}\frac{||e_{k+1}||}{||e_k||} \\=\lim_{k\rightarrow \infty}\frac{g(x_k) - x^*}{x_k - x^*} \\ += \lim_{k\rightarrow \infty} g^\prime (\xi_k) = g^\prime(x^*) +$$
+ +

绝对条件数为$g^\prime(x^*)$。如果$|g^\prime(x^*)|$非零,则收敛是线性的,如果为0,则是超线性的。

+

牛顿迭代法:

+
$$ +x_{k + 1} = x_k - \frac{f(x_k)}{f^\prime(x_k)} +$$
+ +

由于$g^\prime(x^*)=0$,收敛是超线性的。进一步分析得到$\lim_{k\rightarrow \infty}\frac{x_{k+1} - x^*}{(x_k - x^*)^2} = \frac{f^{\prime\prime}(x^*)}{2f^\prime(x)}$,因此牛顿法是平方收敛的。

+

牛顿法的特点:

+
    +
  • 初值的选取很重要
  • +
  • $f^\prime(x)\ne 0$
  • +
  • 速度快,但是可能出现振荡的情况
  • +
  • 对多重根的收敛速度退化为线性
  • +
  • 涉及到求导,有时候比较困难
  • +
+

准牛顿法:免去了求导

+
$$ +x_{k + 1} = x_k - \frac{f(x_k)}{g_k} +$$
+ +

割线法:准牛顿法的一种

+
$$ +g_k = \frac{f(x_k) - f(x_{k - 1})}{x_k - x_{k - 1}} +$$
+ +

反插:割线法是用两次的迭代值确定一条直线,取直线与x轴的交点。可以采用反二次插值:用前三次迭代值确定抛物线$x = p(y)$,取它与x轴的交点。

+

二分法较安全,但速度慢;迭代法速度快,但不安全。可以在区间较大时采用二分法缩小区间,等区间较小时再采用迭代法。

+

拟合与插值

拟合

如果方程的数目多于未知数的数目,则是超定方程。

+

如果方程的数目少于未知数的数目,则是欠定方程。

+

超定方程在线性最小二乘的意义下得到一个近似解。

+

转而求解$A^TAx = A^Tb$。如果矩阵A是列满秩的,则解唯一。

+

若$A^TA$是正定的,则有$A = LL^T$。

+

可以采用QR分解将长方阵A简化:

+
$$ +A = Q\begin{bmatrix} +R\\ +0 +\end{bmatrix} +$$
+ +

进一步,如果$Q = \begin{bmatrix}Q_1\Q_2\end{bmatrix}$,则$Rx = Q_1^Tb$。

+

利用household变换进行QR分解。

+

正规方程方法的复杂度:$mn^2/2 + n^3/6$

+

household变换的复杂度:$mn^2 - n^3 / 3$

+

如果m和n相当,则两种变换的复杂度相当,而m远大于n时,QR分解的复杂度是正规方程方法的两倍。

+

QR分解的适用性更宽。

+

插值

插值使得函数精确地通过给定数据点。

+

单项式基底:$\phi_j(x) = x^{j - 1}$。给定点数越多的插值问题,病态性越高,插值多项式的系数不稳定。

+

霍纳法则:$t_1 + x(t_2+x(t_3+(\dotsb)))$,减少乘法次数。

+

拉格朗日插值:

+
$$ +l_j(x) = \frac{\prod_{k = 1, k \ne j}^{n}(x - x_k)}{\prod_{k = 1, k\ne j}^{n}(x_j - x_k)} +$$
+ +
    +
  • 确定形式容易
  • +
  • 计算值困难
  • +
  • 微分,积分不方便
  • +
+

牛顿插值:基底取$\prod_{k = 1}^{j - 1}(t - t_k)$。

+
    +
  • 容易确定,系数较容易求解
  • +
  • 计算可以通过类似霍纳法则的方法求得,时间复杂度低
  • +
  • 在确定和求值之间形成了较好的平衡。
  • +
+

优化问题

分为连续优化问题和离散优化问题。

+

可行点,约束集合。

+

连续优化问题

有线性规划和非线性规划问题。

+

线性规划:不细讲。

+

非线性规划:

+

(严格/非严格)全局最小值,局部最小值。全局最小值的求解,甚至验证都很困难。

+

闭集:闭集是补集为开集的集合。如果一个集合中所有的极限点都是这个集合中的点,则这个集合是闭集。

+

有界闭集上的连续函数有全局最小值。如果不是闭的或者无界,就可能没有最小值。

+

$\lim_{||x||\rightarrow \infty} f(x) = \infty$,称$f(x)$在无界闭集$S\sube \mathbb{R^n}$上是强制的。

+

如果连续函数$f$在无界闭集$S\sube \mathbb{R^n}$上是强制的,则$f$在$S$上存在全局最小值。

+

集合是凸的:任意两点的连线属于这个集合。

+

函数是凸的:区间内函数值不超过端点连线上的函数值。

+

如果集合和函数都是凸的,称为凸优化问题。

+

我们有如下结论:

+
    +
  • 如果$f$是凸集$S\sube \mathbb{R^n}$上的凸函数,则在 $S\sube \mathbb{R^n}$的任意内点上连续
  • +
  • 凸函数$f$在凸集$S\sube \mathbb{R^n}$上的任意局部最小值,都是$f$在$S\sube \mathbb{R^n}$上的全局最小值
  • +
  • 严格凸函数$f$在凸集 $S\sube \mathbb{R^n}$上的局部最小值,是$f$在$S\sube \mathbb{R^n}$上的唯一全局最小值
  • +
  • 如果$f$在有界闭集$S\sube \mathbb{R^n}$上严格凸,则$f$在$S\sube \mathbb{R^n}$上存在唯一的全局最小值
  • +
  • 如果$f$在无界闭集 $S\sube \mathbb{R^n}$上严格凸,则$f$在$S\sube \mathbb{R^n}$上存在唯一全局最小值的充要
    条件是$f$在$S\sube \mathbb{R^n}$上是强制的
  • +
+

下面考虑无约束优化:

+

梯度为0的点是临界点。

+

临界点可能是局部最大值/最小值/鞍点。

+

如果函数是凸的,临界点就是全局最小值点。

+

海森矩阵正定,则f是凸的。

+

如果$x^*$是函数$f$的最小值,
则$\nabla f(x^*) = 0$,$\nabla^2f(x^*)$非负定。

+

如果$\nabla f(x^*) = 0$且$\nabla^2f(x^*)$正定,则$x^*$是严格局部最小值。

+

如果是凸优化,则$\nabla f(x^*) = 0\Leftrightarrow f(x^*)$为严格局部最小值

+

矩阵的正定性:

+
    +
  • 特征值全正
  • +
  • Cholesky分解唯一
  • +
  • 顺序主子式的行列式全正
  • +
+

拉格朗日乘数法:

+
$$ +\mathcal{L}(x, \lambda) = f(x) + \lambda^Tg(x) +$$
+ +

海森矩阵:

+
$$ +H_{\mathcal{L}}(x, \lambda) = \begin{bmatrix} + B(x, \lambda) && J_g^T(x)\\ + J_g(x) && 0 +\end{bmatrix}\\ +B(x,\lambda) = H_f(x) + \sum_{i = 1}^m\lambda_iH_{g_i}(x) +$$
+ +

只要$B(x^*, \lambda^*)$正定,则$x^*$是极小值点。

+

敏感性和病态性:依赖于海森矩阵

+
    +
  • 海森矩阵奇异,则极值问题病态
  • +
  • 海森矩阵接近奇异,则极值问题敏感
  • +
+

下面考虑一维优化问题:

+

单峰函数:最小值左侧递减,最小值右侧递增。

+

类似于二分法,可以用黄金分割搜索求单峰函数的极小值。

+

好处:每次迭代只需要更新一个点;安全性好;收敛速度线性;

+

坏处:收敛速度还可以提高。

+

方法二:逐次抛物插值。用两个端点和一个近似极值点拟合一条抛物线,取抛物线的最小值点作为新的近似极值点,反复直到收敛。

+

当初始点接近极值点时能够收敛;收敛是超线性的。

+

牛顿迭代法:

+
$$ +x_{k + 1} = x_k - \frac{f'(x_k)}{f''(x_k)} +$$
+ +

实际上采用黄金分割搜索和逐次抛物插值混合方案,避免求函数的导数。

+

多维优化问题:

+

最速下降法:

+
$$ +x_{k + 1} = x_k - \alpha_k\nabla f(x_k) +$$
+ +

确定$\alpha_k$:$\min_{\alpha_k} f(x_k - \alpha_k \nabla f(x_k))$

+

非常可靠,只要梯度不为0;速度可能不快,呈之字形;收敛速度线性;初值的选择很重要。

+

牛顿法:

+
$$ +x_{k + 1} = x_k - H_f^{-1}(x_k)\nabla f(x_k) +$$
+ +

平方收敛,速度快于梯度下降;需要距离最优解很近;不需要搜索参数;如果目标具有连续的二阶偏导数,则海森矩阵对称。

+

拟牛顿法

+
$$ +x_{k + 1} = x_k - \alpha_kB_k^{-1}\nabla f(x_k) +$$
+ +

算法设计思想

贪心算法

    +
  • 可行性
  • +
  • 局部最优
  • +
  • 不可取消
  • +
+

不是所有优化问题都能通过贪心算法求解,即使可以使用贪心算法,也不一定能够得到最优解。

+

如果一个优化问题可以通过局部最优选择得到全局最优解,则说这个问题满足贪心选择性质,此时可以简单高效地求得问题的最优解。

+

贪心策略可以有很多种。不同的算法有不同的性能。不一定得到全局最优解。

+

动态规划

多阶段动态过程的优化问题

+

阶段:把问题分成几个相互联系的有顺序的几个环节,这些环节被称
为阶段

+

状态:某一阶段的出发位置称为状态。通俗的说状态是对问题在某一
时刻的进展情况的数学描述

+

决策:从某阶段的一个状态演变到下一个阶段某状态的选择

+

条件:最优化原理;无后效性

+

动态规划用空间换时间,有大量重叠子问题时才能体现它的优势。

+

例:Floyd算法,Viterbi译码

+

蛮力法

分治法

快速排序

+

分治法:分成若干个小的同类问题

+

减治法:变成一个更小的同类问题

+

变治法:变成若干个更简单的问题

+

搜索算法

组合优化问题的解空间指的是搜索答案的过程中搜索过的可行解。

+

回溯法:没有希望的解就不去搜索。

+

分支界限法:一边搜索一边给出当前部分解的下界。对于下界比搜索到的可行解还大的分支,不去搜索。下界的估计方法很重要。

+

回溯法和分支界限法都不能保证求解的效率。

+

随机算法

Sherwood算法

+

快速排序在某些序列下会发生时间复杂度的退化。随机划分元素,可以使得达到最坏复杂度的概率降到很低。

+

一般地,若确定型算法在最坏情况下的时间复杂度和它在平均情况下的时间复杂度有较大的差异,通过随机性可以消除这种差别。并不是避免这种最坏的情况发生,而是切除这种最坏情况和特定实例之间的联系。

+

Las Vegas算法

+
    +
  • 随机化决策
  • +
  • 减少算法运行的时间
  • +
  • 有概率会失败
  • +
  • 多尝试几次以提高成功率
  • +
+

Monte Carlo算法

+
    +
  • 概率为基础的统计模拟方法
  • +
  • 不保证得到正确的解
  • +
  • 设计合理,大量重复可以大概率得到高精度的解
  • +
+

随机投点求面积

+

一个蒙特卡洛方法得到正确判定的概率不小于p,则算法是p正确的。

+

如果同一实例不会给出不同的解,称算法是一致的。

+

对于判定问题,如果能够保证返回true时是正确的,称为偏真的;保证返回false时是正确的,则算法是偏假的。

+

Sherwood:一定得到正确解,一般不会遇到最坏情况

+

Las Vegas:不一定得到正确解,但如果得到了一定是正确的

+

Monte Carlo:不一定得到正确解,即使得到了也不一定是正确的

+

算法优化技术

输入增强技术

+
    +
  • 字符串匹配算法

    +
  • +
  • 计数排序

    +
  • +
+

预构造技术

+
    +
  • 并查集

    +
  • +
  • 二叉查找树

    +
  • +
  • 倒排索引

    +
  • +
  • 堆和堆排序

    +
  • +
+

时空平衡

+
    +
  • 比特逆序
  • +
  • 散列
  • +
+
\ No newline at end of file diff --git a/2022/09/14/Physics/index.html b/2022/09/14/Physics/index.html new file mode 100644 index 00000000..2e2ab554 --- /dev/null +++ b/2022/09/14/Physics/index.html @@ -0,0 +1,1264 @@ +大雾笔记 | Guo_Yun + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

大雾笔记

参考教材

嫌教材太简单可以看看

+

《热学》lhf例题很多,很详细,很多数学比教材难

+

《》

+

《新概念物理教程-力学》新颖,比较硬核。

+

《费恩曼物理学讲义》

+

《新概念物理教程-光学》公认最好教材

+

《光学》chb, lyp

+

量子物理没有太好的参考书。

+

《原子物理学》杨福家编。现在没有原子物理了,只有量子物理。有时用经典方法,有时候用量子物理的方法。前几章和教材一致,实验讲得不错。

+

量子力学教程。周世勋。内容有点少。

+

《费恩曼物理学讲义》第3卷。相当有深度(量子物理)。

+

Phyisics Vol.1 & 2。难度介于大学物理学和物理系教材之间。

+

杂项

牛顿运动方程一般个数少,微分阶数高;哈密顿正则方程一般个数多,微分阶数低。

+

热学

温度

分子动理论:热学中比较古老的理论。

+

教材中关于统计物理的内容不够透彻。

+

建议学习分析力学(重点:哈密顿力学),对后续量子力学有帮助。固体物理也会使用相关技巧。哈密顿量,相空间,拉格朗日方程。不用看证明,能用就行。

+

热学研究内容与对象

内容:与热现象有关的性质和规律。

+

热现象:宏观上与温度有关,微观上与分子热运动有关。

+

对象:大量微观粒子构成的体积有限的物体-热力学系统。(量大:统计学规律。)

+

经常讨论系统和外界(环境)。一种说法:宇宙是不是热力学系统?不是,因为宇宙之外没有外界。所以热二定律可能不适用于整个宇宙。

+

孤立系统:与外界没有任何相互作用。

+

绝热系统:有功的交换,没有热量交换

+

封闭系统:有能量交换,无粒子交换

+

开放系统:既有能量交换,也有粒子交换

+

热力学的研究方法

热力学

宏观理论方法。依赖于实验。不涉及物质的微观结构和微观运动规律。具有极大的普遍性,可靠性。

+

统计物理学

微观理论方法。从微观模型假设出发,力学 + 统计理论建立微观量和宏观量的关系。可解释本质,但是受模型局限。

+

几个重要概念

平衡态

热力学系统内部,宏观上不存在能量和粒子的流动,系统宏观性质不随时间变化。(体积、压强、温度)

+

热力学平衡条件:

+

力学平衡条件:若系统与外界有力学作用,平衡时内外压强相等。

+

热平衡条件:若系统与外界可交换热量,平衡时内外温度应相等。

+

相平衡条件:若系统与外界处于不同相的共存状态,平衡时要达到力学平衡、热平衡以及相平衡。

+

化学平衡条件:浓度不同的系统混到一起,平衡时要满足上面三个条件,并且浓度均匀。

+

注意区分平衡态和稳定态:

+

![../images/pht.png]

+

宏观量

描述系统宏观性质的量。可直接测量。

+

广延量:有累加性。如M, V, E…

+

强度量:无累加性。如p, T…

+

微观量

描述微观粒子性质的量。需要间接测量。

+

如分子的m, v, d…

+

状态参量

描述系统平衡态及其宏观性质的物理量。

+

p, V, T, v, 内能E, 熵S, 焓H

+

一组态参量对应一个平衡态。

+

实验表明:状态参量之间不是相互独立的。

+

常选p, V, T作为自变量,其他的当作函数(E, S, H)-热力学函数。

+

对物质量确定的单元(单一组元,不能由多种物质混合)单相(同一种状态,不能有固液同时存在等等)系统,p, V, T只有两个是独立的:T(p, V), E(p, V)。

+

统计物理:状态参量之间的偏导数关系。

+

物态方程

两个最基本的热力学函数之一(物态方程和内能)。态参量之间的函数关系: f(T, p, V) = 0

+

通过测量确定。

+

理想气体物态方程:

+

$pV = νRT$

+

$p = nkT$

+

$k = \frac{R}{N_A}$

+

$\nu$ 气体摩尔数

+

$k$ 玻尔兹曼常量

+

温度

热平衡态

两个系统长时间热接触达到的共同平衡态。

+

热力学第零定律

实验表明: A与C热平衡,B与C热平衡,A和B也必然保持热平衡。

+

非热接触的两个系统也可以处在同一个热平衡态。

+

温度:处于同一热平衡态下的热力学系统所具有的共同的宏观性质。

+

处在同一热平衡态的系统具有相同的温度。

+

温标

理想气体温标;用理想气体做测温物质。单位: $K$(Kelvin), 范围适用 $> 0.5K$

+

实验表明:一定质量的理想气体在同一个热平衡态下,$pV$不变。

+

规定$T \propto pV$,水的三相点温度为$T_3 = 273.16K$

+
$$T = T_3\frac{pV}{p_3V_3} = 273.16\frac{pV}{p_3V_3}$$
+ +

热力学温标$T$:理论温标,与物质无关。

+

单位: $K$,适用于所有温度范围,在理想气体温标范围内与理气温标一致。

+

统计物理学的观点、概念简介

统计物理学包括平衡态统计理论,非平衡态统计理论和涨落理论。它从物质的微观结构和微观运动来阐明物质的宏观性质。其基本观点:

+
    +
  • 宏观物体由大量的微观粒子(原子、分子、电子、光子等)构成。
  • +
  • 微观粒子的运动服从力学规律。原则上说服从量子力学规律,一定条件下可以用经典力学处理。
  • +
  • 从微观角度看,物体以一定的概率出现在各个微观状态上,物质的宏观性质就是物质微观性质的统计平均。宏观量是有关微观量的统计平均值。
  • +
+

近独立子系统

构成系统的粒子间相互作用很弱,系统能量近似等于各粒子能量总和,如理想气体。

+

微观状态(力学运动状态)

经典力学描述

常采用正则形式,即广义坐标和广义动量描述。

+
    +
  • 子相空间(μ空间):由粒子的广义坐标$q_i$和广义动量$p_i$($i = 1, \dots, r$, $r$是粒子自由度)构成的2r维空间。

    +

    1组$(q_1, \dots, q_r, p_1, \dots, p_r)$的取值表示粒子的1个微观状态,对应于子相空间的一个点。

    +

    更确切的说,在子相空间 $( q_1,… , q_r , p_1,…, p_r )$位置处的体积元 $d q_1…d q_r dp_1…dp_r$中的点,都是由$( q_1,… , q_r , p_1,…, p_r )$描述的相同的粒子微观状态。

    +

    位形空间(坐标构成的空间),速度空间(速度构成的空间)。

    +

    傅里叶变换和傅里叶级数的区别:一个离散,一个连续。

    +
  • +
  • 系统的微观状态是由所有粒子的广义坐标和广义动量描述的。

    +
  • +
+
量子力学描述

量子力学中假设运动状态用量子态描述。

+
    +
  • 粒子的微观状态用单粒子(量子)态描述。

    +

    单粒子态由一组量子数描述:如 $|n, l, m_l, m_s >$ 。 1 组取值确定的$ |n, l, m_l, m_s > $表示 1 个单粒子态。 当粒子状态是由某个单粒子态描述时,称为粒子处于某个单粒子态,或粒子占据某个单粒子态

    +
  • +
  • 系统微观状态用多粒子(量子)态描述。

    +

    对近独立子系统,多粒子态可由单粒子态表示: 系统所有粒子的 1 组单粒子占据态就表示系统的 1 个 多粒子态,即表示系统的 1 个 微观状态。

    +
  • +
+

微观粒子全同性原理

+

全同粒子:内禀属性如质量、电荷、自旋等相同

+

微观粒子全同性原理是量子力学假设。

+

全同性原理:对全同粒子组成的系统,交换任意 2个全同粒子,系统微观状态不变。

+

泡利不相容原理:对全同费米子系统,不能有两个及以上的费米子占据同一单粒子态。

+

费米子:自旋为半整数;玻色子:自旋为整数。

+

宏观状态和微观状态的关系

系统的宏观状态由宏观量表征,如 E、N、V。

+

系统的微观状态,如果用经典描述,则由所有粒子 的坐标和动量表征。

+

玻耳兹曼认为:从微观上看,对于一个系统的状态 的宏观描述是非常不完善的,系统的同一个宏观状 态实际上可能对应于非常非常多的微观状态,而这 些微观状态是粗略的宏观描述所不能加以区别的。

+

这意味着宏观状态和微观状态、宏观量和微观量具 有内在联系,这种联系是种统计关系。

+

统计规律性

统计物理发展早期,人们普遍认为:研究物体宏观 性质,应从求解粒子的力学运动方程出发来解决。 但由于粒子数太多,求解力学方程困难,迫不得已 得引入统计方法。而且这个统计是:宏观量是相应 微观量的长时间平均。 即原则上力学规律可完全决定物体宏观性质

+

这种观点无法解释根本问题:热现象的不可逆性。 因为把力学运动方程(牛顿方程或薛定谔方程)用 到微观粒子,是时间反演对称的 — 可逆的。

+

这表明仅通过力学规律来解释物体的宏观性质是 不可能的,而有赖于新的规律 — 统计规律。

+

力学规律是决定论性的,可表述为:在一定初始 条件下,某时刻系统必然处于一确定的运动状态。

+

统计规律可以表述为:在一定的宏观条件下,某 时刻系统以一定的概率处于某一微观状态。

+

即宏观状态与微观状态之间的联系是概率性的, 具有统计规律的特性,而不是决定论性的。

+

统计规律的稳定性:只要 N 足够大,每次得到的分布几乎相同

+

统计规律的涨落:每次实验中得到的比例 Ni /N 稍有差别。N 越大,涨落越小。

+

即对变量是离散取值的情况,直接采用概率, 对变量是连续取值的情况,需要引入概率密度。

+

热现象本质是统计规律的反映。

+
平衡态统计理论的基本假设:等概率原理

处于平衡态下的孤立系统,系统各个可能的微观 状态出现的概率相等。 “可能的微观状态”是指孤立系统的宏观条件所 允许的那些微观状态,即这些微观状态对应于给 定的 E、V、N

+
平衡态下近独立子系统的统计规律

处于平衡态下的热力学系统,宏观状态不变,但 相应的微观状态不断变化,是一种动态平衡。 根据等概率原理,平衡态包含的微观状态数目是 最多的 — 最概然态

+

求统计分布函数:对于每个统计分布函数,可以计算它们对应的微观态数目(微观态数目是统计分布函数的函数)。在E, N不变的条件下,只要找到对应微观态数目最多的统计分布函数,就是平衡态的统计分布函数。

+

对近独立子系统,采用经典力学及等概率原理只能得到一种经典统计:麦克斯韦-玻尔兹曼统计;采用量子力学及等概率原理得到3种统计:麦克斯韦-玻尔兹曼统计,费米-狄拉克统计,玻色-爱因斯坦统计。

+

造成 3 种量子统计规律的原因是微观粒子的全同性原理和泡利不相容原理。

+

麦克斯韦-玻尔兹曼统计适用于定域子系统,费米 - 狄拉克统计、玻色 - 爱因斯坦统计适用于非定域 子系统。

+

定域:全同粒子系统中的粒子的波包局限在空间 一定范围内,之间没有重叠,全同性原理 不起作用,可以通过位置分辨粒子。

+

经典的和量子的麦克斯韦-玻尔兹曼统计在数学形 式上一致。而在一定条件下,量子的 3 种统计都可 退化为经典的麦克斯韦-玻尔兹曼统计

+

气体动理论

气体动理论的基本观点

气体动理论(分子动理论),发展于 19 世纪下半 期,基于经典理论,是统计物理学的原型,被不断 补充发展完善成为统计物理学,其所得的结论可通 过统计物理得到。至今仍在诸多领域有重要应用。

+
    +
  1. 宏观物体是由大量分子、原子构成的,分子间 存在一定的间隙。
  2. +
  3. 分子永不停息地作无规则运动 — 热运动
  4. +
  5. 分子间存在一定的相互作用。
  6. +
+

理想气体的压强

关于理想气体的假设
单个分子服从的力学规律

理想气体模型:

+

大小:分子线度<<分子间平均距离

+

分子力:除碰撞的瞬间,在分子间、分子与器壁间无作用力

+

碰撞性质:弹性碰撞

+

服从规律:牛顿力学

+
大量分子处于平衡态时的统计假设

(1)无外场时,分子在各处出现的概率相同

+
$$n = \frac{\mathrm d N}{\mathrm d V} = \frac NV = \text{const}.$$
+(2)由于碰撞,分子可以有各种不同速度 + +

速度取向各方向等概率:

+
$$\bar{v_x} = \bar{v_y} = \bar{v_z} = 0\\\\\bar{v_x^2} = \bar{v_y^2} = \bar{v_z^2} = \frac 13 \bar{v^2}$$
+ +
理想气体压强公式

前提:平衡态,忽略重力,分子当成质点

+
$$p = \frac13nm\bar{v^2} = \frac23n\bar\varepsilon_t, \\\\\bar\varepsilon_t = \frac12 mv^2$$
+ +

温度的统计意义

$$\bar\varepsilon_t = \frac{3p}{2n} = \frac{3nkT}{2n} = \frac32kT\\\\\sqrt{\bar{v^2}} = \sqrt{\frac{3kT}{m}} = \sqrt{\frac{3RT}{M}}$$
+ +

$T = 273K$,

+

$\bar{\varepsilon}_t$数量级:$10^{-2}$eV

+

$\sqrt{\bar{v^2}}$

+

$H_2$: $1.84\times 10^3m/s$

+

$O2$: $4.61\times 10^2m/s$

+

能量均分定理

自由度:决定物体空间位置的独立坐标数,用$i$表示

+
单原子分子

平动自由度:$t = 3$

+

$i = 3$

+
双原子分子

质心平动:$t = 3$

+

轴取向:$r = 2$

+

距离变化:$v = 1$

+

总自由度: $i = 6$

+
多原子分子

设分子包含$N$个原子

+

$i = 3N$

+

$t = 3$

+

$r = 3$

+

$v = 3N-6$

+
能量均分定理

一个平动自由度对应的平均动能为$\frac12kT$

+

考虑平动、振动和转动,由于分子的碰撞,分子平均动能均匀分配到每个自由度上。

+

在温度$T$的平衡态下,分子热运动的每个自由度对应的平均动能都等于$\frac12kT$。

+

普遍的能量均分定理:

+

分子能量中每具有一个平方项,就对应一个$\frac12kT$的平均能量。

+

分子振动的动能和势能都是平方项,所以:

+

$\bar\varepsilon_{vP} = \bar\varepsilon_{vk} = v\frac12kT$, $\bar\varepsilon_v = \bar\varepsilon_{vP} + \bar\varepsilon_{vk} = vkT$

+
$$\bar\varepsilon = \bar\varepsilon _t + \bar\varepsilon_r + \bar\varepsilon_v = (t + r + 2v)\frac12kT$$
+通常情况下($T < 10^3K$),振动自由度被“冻结”,分子可视为刚性 + +

刚性分子:$v = 0, i = t + r$

+
$$\bar\varepsilon = \frac{t+ r}2kT$$
+ +
理想气体内能

内能:系统内部各种形式能量的总和,不包括系统整体质心运动的能量

+

分子内部: $\bar\varepsilon = (t + r + 2v)\frac12kT$

+

分子之间:相互作用势能$\varepsilon_{\mathrm pij}$

+

内能:$E = N\bar\varepsilon + \sum_i\sum_{j<i}\varepsilon_{\mathrm pij} = E(T, V)$

+

理想气体: $\varepsilon_{\mathrm pij} = 0,E = E(T)$

+

麦克斯韦速度分布律

分布函数是体现热力学系统的统计规律性的重要函数.

+

常见的统计分布函数包括:速率分布函数、速度分布函数、能量分布函数等。

+

通过分布函数可计算微观量的统计平均值,如$\bar\varepsilon_t, \bar{v^2}$等,进而得到系统的宏观量。

+
速率分布函数
$$f(v) = \frac{\text dN}{N\text dv}\\\\\int_0^\infty f(v)\text dv = \int_0^\infty\frac{\text dN}{N} = 1$$
+ +
麦克斯韦速率分布函数(不用记)
$$f(v) = 4\pi (\frac m{2\pi kT})^{3/2}e$$
+ +
三种统计速率
最概然速率
$$v_p = \sqrt{\frac{2kT}{m}}$$
+ +

m一定时,温度T越高,速率大的分子数比例越大,最概然速率越大, $f(v_p)$越小。

+
平均速率
$$\bar v = \int_0^\infty vf(v)\text dv$$
+ +

任意函数对全体分子按速率分布的平均值为

+

$f(v)$一定要归一化!

例如求0到vp/2的平均速率,首先要将f(v)归一化成这个区间内的速率分布,而不是直接用全部速率分布

+
$$\bar{\phi(v)} =\int_0^\infty \phi(v)f(v)\text dv$$
+ +

由麦克斯韦速率分布函数

+
$$\bar v = \sqrt{\frac{8kT}{\pi m}} = \sqrt{\frac{8RT}{\pi M}}$$
+ +
方均根速率
$$\bar{v^2} = \int_0^\infty v^2f(v)\text dv = \frac{3kT}{m}\\\sqrt{\bar{v^2}} = \sqrt{\frac{3kT}{m}} = \sqrt{\frac{3RT}M}$$
+ +
麦克斯韦速度分布律
$$\frac{\text dN}{N} = \left(\frac{m}{2\pi kT}\right)^{3/2}e^{-m(v_x^2 + v_y^2 + v_z^2)/2kT}\text{d}v_x\text{d}v_y\text{d}v_x$$
+ +

速度分量的分布函数

+
$$g(v) = (\frac m{2\pi kT})^{1/2}e^{-mv^2/2kT}$$
+ +
分子碰壁数$Γ$
$$\Gamma = \frac14 n\bar v$$
+ +
玻尔兹曼分布
恒温气压公式
$$p = p_0e^{-mgz/kT}\\\\n = n_0e^{-mgz/kT}$$
+ +
玻尔兹曼分布
$$\text dN_{\vec r} = n_0 \cdot e^{-\varepsilon_p(\vec r)/kT} \cdot \text d^3 \vec r\\\\\text d^3\vec r = \text dx \ \text dy \ \text dz$$
+ +
玻尔兹曼-麦克斯韦分布
$$\text dN = n_0 \cdot (\frac m{2\pi kT})^{3/2} \cdot e^{-[\frac12 mv^2 + \varepsilon_p(\vec r)]/kT} \cdot \text d^3\vec r \cdot \text d^3 \vec v$$
+ +

能量简并:不同子相空间分子能量相等。

+

分子按能量分布:

+
$$N(\varepsilon) = C \cdot w(\varepsilon) \cdot e^{-\frac{\varepsilon}{kT}}$$
+ +

$\varepsilon$为粒子的能量,$w(\varepsilon)$为具有此能量的体积元个数.

+

范德瓦尔斯方程

范氏气体模型

气体分子间的作用力:分子间的作用力很复杂,主要是电磁力,可以分为引力和斥力

+

范氏气体模型:对理想气体做两方面的修正。考虑分子体积、分子间作用力引起的修正。

+

范氏气体

+
    +
  • 分子是直径为d的刚球
  • +
  • 在$d\rightarrow s$的范围内,分子间有恒定引力
  • +
+

范德瓦尔斯方程

范德瓦尔斯方程:

+

设:

+

$\nu = 1 mol$

+

$p$ – 实测气体压强

+

$V_m$ – $1\ mol$气体容积

+

对理想气体:$pV_m = RT$

+

对真实气体:

+
    +
  1. 分子体积引起的修正
  2. +
+

分子自由活动空间的体积为$V_m - b$

+
$$p(V_m - b) = RT$$
+ +
$$ +p = \frac{RT}{V_m - b} +$$
+ +
    +
  1. 分子间引力引起的修正
  2. +
+

气体分子间作用力一般表现为引力。

+

在容器内部,单个气体分子受到各个方向的平均引力相等,合力可以看作零。

+

但是在容器边缘,单个气体分子受到的引力是不对称的。气体分子所受的合力指向容器内部,因此撞击容器壁的气体分子动量比理想气体下的情况要小,宏观上形成的压强比理想气体情况要小。

+
$$ +p < \frac{RT}{V_m - b}\\ +$$
+ +

+
$$ +p = \frac{RT}{V_m - b} - p_{in} +$$
+ +

$p_{in} \propto nf_{合}, f_{合}\propto n \Rightarrow p_{in} \propto n^2 \propto \frac 1{V_m^2}$

+

最后得到:

+
$$ +(p + \frac a{V_m^2})(V_m - b) = RT +$$
+ +

对 ν mol 气体:

+
$$ +(p + \nu^2 \cdot \frac a{V^2})(V - \nu b) = \nu RT +$$
+ +

常温常压下:$b/V_m \sim 10^{-3}, p_{in}/p \sim 10^{-2}$,这时分子体积和分子间的作用力修正可以忽略。

+

气体的等温线

真实气体的等温线:

+

RealGasTemp

+

范氏气体的等温线:

+

VanGasTemp

+

如何计算临界参数:

+

临界参数:临界点K对应的$p_K, V_K, T_K$

+

临界点K是等温线的拐点:

+
$$ +\left(\frac{\partial p}{\partial V}\right)_{T = T_K} = 0\\ +\left(\frac{\partial^2 p}{\partial V^2}\right)_{T = T_K} = 0 +$$
+ +

K同时也是三次方程的三重根,因此可以通过假设$(V_m - V_{mK})^3 = 0$展开后和范德瓦尔斯方程对比系数求解。

+

范氏气体内能

理想气体: $E(T) = i\nu RT / 2$

+

范氏气体:$V\uparrow \rightarrow p_{in}做负功\rightarrow 分子间势能E_p\uparrow$

+

要计算势能,首先要定义势能为0的状态:定义某种位形为0势能。其他状态的势能定义为从这种状态变形到0势能状态的过程中保守力的变化。

+
$$\mathrm dA = -p_{in}S\mathrm dl = -p_{in}\mathrm dV$$
+ +

设$E_p(V = \infty) = 0$。

+
$$ +E_p(V) = \int_V^\infty -p_{in}\mathrm dV = \int_V^\infty-\nu^2 \cdot \frac a{V^2}\mathrm dV = -v^2 \cdot \frac aV +$$
+ +
$$ +E = E_k + E_p = \frac i2\nu RT - \nu ^2\frac aV +$$
+ +

结论:

+
$$E(T, V) = \frac i2 \nu RT - \nu^2 \frac aV$$
+ +

一个细节

为什么不考虑气体分子和容器壁分子间的引力?

+

事实上,这引力确实存在。但是可以通过动量定理证明,碰撞过程这引力的作用总和为0。

+

气体分子的碰撞、平均自由程

平均碰撞频率和平均自由程

+

平均碰撞频率$\bar z$:单位时间内一个气体分子与其他分子碰撞的平均次数

+

平均自由程$\bar \lambda$:气体分子在相邻两次碰撞之间飞行的平均路程。

+

平均碰撞频率和平均频率之间关系

+

对象:平衡态下的理想气体

+

假定:

+

(1)只有一种分子;

+

(2)分子可视作直径为d的刚球;

+

(3)被考察的分子以平均相对速率$\bar u$运动,其余的分子静止。

+

碰撞界面为$\sigma$。分子间平均相对速率为$\bar u = \sqrt 2 \bar v$。

+
$$ +\bar z = \sigma \bar u n = \pi d^2 n \bar u = \sqrt 2 \pi d^2 n\bar v +$$
+ +

平均自由程和压强、温度的关系:

+
$$ +\bar\lambda = \frac {\bar v} {\bar z} = \frac 1{\sqrt2 \pi d^2 n} = \frac {kT}{\sqrt2\pi d^2p} \propto \frac{T}{p} +$$
+ +

气体输运过程

非平衡态下,气体内部各部分性质不均匀,就会产生热量、动量、质量的迁移,称为输运过程或内迁移过程。

+

气体输运过程包括:热传导、扩散和内摩擦(粘滞)。

+

输运现象的宏观实验定律和原因。

+

热传导

+

温度不均匀。实验定律:傅里叶定律,热传导方程。

+

考虑1维的情形。

+
$$ +\mathrm dQ = -\kappa \frac{\partial T}{\partial x}\mathrm dS \mathrm dt +$$
+ +
$$ +j(x, t) = \frac{\mathrm dQ}{\mathrm dS\mathrm dt} = -\kappa \frac {\partial T(x, t)}{\partial x} +$$
+ +

$j(x, t)$:热流密度,$\partial T/\partial x$:温度梯度。

+

温度梯度“力”导致热流。

+
+

$T$在这里相当于电势,$-\partial T / \partial x$相当于电势的负梯度即电场强度,$j$相当于电流密度,$\kappa$相当于电导率。因此类比$\vec{J} = \sigma \vec{E}$有$j = -\kappa \partial T /\partial x$。类似的,也许可以推导出热阻的概念?热学的“麦克斯韦”方程组又是什么?

+
+

统计物理给出的结论:

+
$$ +\kappa = \frac 13 nm\bar v \bar \lambda c_V +$$
+ +
+

如何理解此公式:热传导的本质是分子能量(热量)的交换,交换的热量等于粒子数乘以单个粒子交换的热量。

+

$m$为单个分子质量。$c_V$为定体热容。$n\bar v$用于描述$\mathrm dt$内穿过$\mathrm dS$的粒子数,$\bar\lambda$乘以$\partial T/\partial x$得到温度的变化量$\mathrm dT$ ,$m,c_V$与温度的变化量相乘,得到单个粒子交换的热量。

+
+

稳恒热流:$\frac{\mathrm dQ}{\mathrm dt} = C$,$j$, $T$与$t$无关。

+

$\kappa$称为导热系数,由气体特性和$T, p$决定。

+

扩散

+

原因:气体内部离子数浓度不均匀。

+

斐克定律

+
$$ +\mathrm dN = -D\frac {\partial n}{\partial x}\mathrm dS \mathrm dt +$$
+ +
+

教材的表述为

+
$$ +\mathrm dM = -D\frac {\partial \rho}{\partial x}\mathrm dS \mathrm dt +$$
+这里的两个$D$是一样的。 +
+

统计物理给出的结论:

+
$$ +D = \frac13\bar v\bar \lambda +$$
+ +

扩散流密度:

+
$$ +j(x, t) = \frac {\mathrm dN}{\mathrm dS \mathrm dt} = -D\frac {\partial n}{\partial x} +$$
+ +

稳恒扩散流:$\frac {\mathrm dN}{\mathrm dt} = C$,$j$, $n$, 与$t$无关。

+

粒子数守恒方程

+
$$ +\oiint_S j\cdot \vec {s} = -\frac {\mathrm dN}{\mathrm dt}, \nabla \cdot \vec j + \frac{\partial n}{\partial x} = 0. +$$
+ +

结合粒子数守恒方程(微分形式)和斐克定律得到扩散方程

+
$$ +\frac{\partial n}{\partial t} = D\frac{\partial^2 n}{\partial x^2} +$$
+ +

考试考定场稳恒流,不考内摩擦。

+

内摩擦(粘滞)

+

根据流体力学,对定常流动的粘滞流体,流速不太大时(雷诺数小),出现层流。

+

粘滞定律(牛顿摩擦定律)

+
$$ +\Delta F = - \eta \frac{\mathrm du}{\mathrm dz}\Delta S +$$
+ +
$$ +p = -\eta \frac{\mathrm du}{\mathrm dz} +$$
+ +

粘度和温度有关,气体粘度随温度增加,液体温度随温度减小。遵从粘滞定律的流体称为牛顿流体。

+

内摩擦原因:流速不均匀。

+

统计物理给出的结论:

+
$$ +\eta = \frac 13 nm\bar v\bar \lambda +$$
+ +

热力学第一定律

准静态过程

准静态过程:过程的任一时刻,系统都处于平衡态— 一系列平衡态组成的理想化过程。

+

若外界条件改变时,能保证和系统相应的强度量之间差无穷小,则过程是准静态的。

+

弛豫时间τ:平衡破坏到恢复平衡的时间.

+

当$\Delta t_{过程} > \tau$时,过程就可视为准静态过程。

+

体积功:$\mathrm{\bar dA} = p\mathrm dV$

+

系统对外界做功:$A = \int_{V_1}^{V_2}p\mathrm dV$是一个过程量。

+

通过做功改变系统热力学状态,微观上是分子规则运动的能量通过碰撞转变为无规则运动的能量。

+

内能,热量和热力学第一定律

内能:定义为$E_2 - E_1 = A_{1\rightarrow 2}$(绝热过程)

+

内能通过绝热功度量。

+

热量:定义为$Q = (E_2 - E_1)$(无功过程)

+

微观本质是分子无规则运动的能量通过碰撞从高温物体向低温物体传递。

+

热力学第一定律:

+

$Q = \Delta E + A$

+

$\mathrm {\bar{d}}Q = \mathrm d E + \mathrm{\bar{d}}A$

+

热力学第一定律是一条实验定律,适用于任何热力学系统的任何过程。

+

热容量:

$$ +C = \frac{\mathrm dQ}{\mathrm dT} +$$
+ +

定体热容量:$C_v = \left(\frac{\mathrm dQ}{\mathrm dT}\right)_V$

+

定压热容量:$C_p = \left(\frac{\mathrm dQ}{\mathrm dT}\right)_p$

+

摩尔热容量:

+
$$ +C_m = \frac1\nu\frac{\mathrm dQ}{\mathrm dT} +$$
+ +

对应地有定体摩尔热容量和定压摩尔热容量。

+

理想气体内能:$\Delta E = \nu C_{V, m}\Delta T$。(推导:内能变化与过程无关,假设先等体后等温,等体过程无功只有热交换,等温过程内能不变。)

+

迈耶公式:

+
$$ +C_{p, m} - C_{V, m} = R +$$
+ +

(推导:用等压过程计算内能的变化,与定体过程的结论比较一下可得。)

+

理想气体热容量理论公式:

+
$$ +C_{V, m} = \frac i2R, C_{p, m} = \frac{i+2}{2}R +$$
+ +

推导:结合理想气体内能公式。

+

定义比热容比:$\gamma = C_{p, m}/C_{V, m}$

+

绝热过程

系统和外界没有热交换的过程。

+

理想气体的准静态绝热过程:

+
+
$$ +0 = p\mathrm dV + \nu C_{V, m}\mathrm dT\\ +p\mathrm dV + V\mathrm dp = \nu R\mathrm dT\\ +R = C_{p, m} - C_{V ,m} +$$
+ +

得到:

+
$$ +\frac{\mathrm dp}{p} = -\gamma\frac{\mathrm dV}V +$$
+
+

两边积分得到:

+
$$ +pV^{\gamma} = C, TV^{\gamma - 1} = C, p^{\gamma - 1}T^{-\gamma} = C +$$
+ +

绝热功

+
$$ +A = \int_{V_1}^{V_2} p\mathrm dV = C \int_{V_1}^{V_2}\frac 1{V^{\gamma}}\mathrm dV = \frac{C}{1 - \gamma}(V_2^{1 - \gamma} - V_1^{1 - \gamma}) =\frac{p_2V_2 - p_1V_1}{1 - \gamma} +$$
+ +

绝热功等于内能的减少量:

+
$$ +A = -\Delta E = \nu C_{V, m}\Delta T +$$
+ +

理想气体的多方过程

+

多方过程:热容量$C$为常数的过程

+

多方过程方程:$pV^n = \text{const}$

+

其中,$n = (C - C_p)/(C - C_V) = (C_m - C_{p, m})/(C_m - C_{V, m}) = \text{const}$

+

如果为绝热过程则$C = 0$,$n = \gamma$,从而$pV^{\gamma} = \text{const}$。

+

如果为等温过程则$C = \infty$,$n = 1$,因此$pV = \text{const}$。

+

绝热自由膨胀过程(非准静态过程!!)

+

理想气体:$Q = 0, A = 0 \Rightarrow E_1 = E_2$

+

真实气体:若分子间以引力为主, $T_2 < T_1$,以斥力为主,$T_2 > T_1$。

+

焓:气体的绝热节流过程是等焓过程,即$H = E + pV$为常数,对于非理想气体而言,内能不仅与温度有关,也与体积有关(焦耳-汤姆孙效应)。

+

绝热自由膨胀:初末状态在等温线上,但是过程中不是平衡态。

+

准静态等温膨胀:吸热用来做功。

+

准静态绝热膨胀:内能的减少量用来做功。

+

+

循环过程:

+

系统,如热机中的工质,经一系列变化的回到初态的整个过程。

+

状态图:

+

+

热循环:

+

+

蒸汽机的效率约为十几%,内燃机20-30%。

+

制冷循环:

+

+

制冷系数:

+
$$ +w = \frac{Q_2}{A} = \frac{Q_2}{Q_1 - Q_2} +$$
+ +

卡诺循环

卡诺循环是一种可逆循环,包括两个等温过程和两个绝热过程。它的效率为

+
$$ +\eta = 1 - \frac{|Q_2|}{Q_1} = 1 - \frac{T_2}{T_1} +$$
+ +

卡诺循环的效率仅与热源的温度比有关。

+

由卡诺定理可以证明,卡诺循环的效率与工质无关。因此,不妨设工质为理想气体,利用理想气体等温和绝热过程方程得到效率公式。

+

热力学第二定律

开尔文表述:不可能将热量从低温热源搬运到高温热源,而不产生其他影响。(制冷系数不可能为无穷大)

+

克劳修斯表述:不可能将功全部转化为热。(热机效率不可能为1)

+

开尔文表述和克劳修斯表述是等价的。事实上,任何关于热现象不可逆的描述都是等价的,它们要么同时成立,要么同时不成立。因此,描述热现象的方向性,只需要举一个例子即可。

+

卡诺定理

在温度相同的高温热源和温度相同的低温热源之间工作的一切热机,可逆热机的效率最大。

+

推论:一切可逆热机,只要它们的高温热源的温度相等,低温热源的温度相等,效率就相等。

+

对于制冷机:

+

可逆制冷机的制冷系数最大。

+

所有2热源可逆制冷机制冷系数都相等,等于卡诺制冷机的制冷系数。

+

热力学温标

根据卡诺定理,可逆热机的效率只与温度有关。因此可以用效率,或者说热量比来定义温标。

+

在热力学温标下,低温热源的温度不能为0,否则可逆热机的效率为1.

+

任意可逆循环的效率

$$ +\eta \le 1 - \frac {T_2}{T_1} +$$
+ +

其中,$T_1$,$T_2$分别为循环中工质的最高和最低温度。

+

克劳修斯熵公式

热力学第零定理导出了温度,热力学第一定律导出了内能,热力学第二定律则导出了熵。

+

可逆循环可以拆成若干小卡诺循环,每个卡诺循环满足

+

可逆循环有克劳修斯等式

+
$$ +\oint_R \frac{\mathrm {\bar d} Q}{T} = 0 +$$
+ +

因此得到一个与路径无关的状态函数。

+

熵与状态有关,和过程无关。即便过程是不可逆过程。

+

但是,仅当过程为可逆过程时才有$\mathrm dS= \mathrm{\bar d}Q/T$。

+

对于可逆过程:

+
$$ +T\mathrm dS = \mathrm{\bar d}Q = \mathrm dE + p\mathrm dV +$$
+ +

因而可以用$E, V$表示熵:

+
$$ +\mathrm dS = \frac 1T \mathrm dE + \frac pT \mathrm dV = \frac 1T() +$$
+ +

克劳修斯不等式

不可逆循环有

+
$$ +\oint_{Ir} \frac{\mathrm {\bar d} Q}{T} < 0 +$$
+ +

因而有熵增加原理:

+
$$ +\int_{1_{Ir}}^{2} + \int_{2_R}^1 < 0\Rightarrow S_1 - S_2= \int_{1_{Ir}}^2 +$$
+ +

振动和波动

波动

多普勒效应

一般形式:

+

+

机械波不存在多普勒效应。

+

电磁波的多普勒效应:

+

+

横向多普勒效应:$\theta = \pi /2$

+

纵向多普勒效应:$\theta = 0,\pi$

+

激波

马赫数:$\frac{v_s}{u} = \frac 1{\sin\alpha}$

+

光学

光学分为几何光学,波动光学和量子光学。

+

光的相干叠加

光源:

+
    +
  1. 普通光源:自发辐射。不同原子发光独立、不相干;同原子不同次发光独立、不相干。
  2. +
  3. 激光光源:受激辐射。光放大,全通光子,相干光,波列长,相干性好。
  4. +
+

光的相干性:
光学中强调电磁波的电场矢量$\vec E$:光矢量

+

相干条件:光矢量有平行分量,频率相同,相差恒定。

+

电磁波叠加的强度公式推导:

+
$$ +I = \sqrt{\varepsilon / \mu}\left<\vec E \cdot \vec E \right>_t \\ + +

I \propto \left<\vec E \cdot \vec E \right>_t \

+

叠加的电磁波:\vec E_1 + \vec E_2\

+

矢量的点乘运算可得叠加后的强度:\

+

I = I_1 + I_2 + 2\sqrt{\varepsilon / \mu}\left<\vec E_1 \cdot \vec E_2 \right>_t

+

$$

+

对光的相干叠加,用光矢量的平行分量描述光场–标量波函数。

+
$$ +I = I_1 + I_2 + 2\sqrt{I_1I_2}\cos \Delta \varphi +$$
+ +

其中$\Delta\varphi = -k(r_2 - r_1) + (\varphi_{20} - \varphi_{10})$为相位差。

+

在上面两式中,若$\vec E_1 \cdot \vec E_2 \ne 0$或者$\Delta\varphi \ne \pm\frac{\pi}{2}…$,则满足相干的条件。

+

条纹的明显程度用衬比度衡量:$V = (I_{max} - I_{min})/(I_{max} + I_{min})$

+

不同的位置$\Delta\varphi$不同,因而对应的$I$不同,造成了干涉条纹的出现。$I_1 = I_2$时$V=1$,$I_1 \ne I_2$时,$V \ne 1$。

+

普通光源获得相干光的途径一般有分波阵面法(双缝干涉)和分振幅法(薄膜干涉)。

+

双缝干涉

+

明纹:$\delta = \pm k\lambda$

+

暗纹:$\delta = \pm (2k + 1)\frac \lambda 2$

+

$(k\in N)$

+

条纹间距:$\Delta x = \frac{D}{d}\lambda$

+

$\Delta \varphi \approx \frac{d\sin \theta}{\lambda}2\pi$

+

时间相干性(光的颜色):

+

光的非单色性:

+

准单色光:由某个中心频率或波长附近的频率或波长连续分布的光构成。采用谱密度函数描述。

+

+

造成谱线宽度的原因:自然宽度、多普勒增宽、碰撞增宽

+

非单色性对干涉条纹的影响:

+

+

从图中可以看出,如果某个位置谱线中波长最长的成分的k级明纹和波长最短的成分的(k+1)级明纹重合,则在这个位置以后的条纹看不清楚了。

+

可以解得最大相干级次:$k_M = \lambda/\Delta\lambda$,进而有最大波程差:$\delta_M = \lambda^2/\Delta\lambda$。

+

相干长度等于波列长度。

+

通常用相干时间(光通过相干长度所需的时间)$\tau = \delta_M / c$ 衡量光的单色性。相干时间或相干长度越长,则单色性越好。

+

空间相干性(光的宽度):

+

较宽的光源会导致明纹的非相干叠加,使衬比度下降。

+

设光的宽度为$b_0$,则看到干涉条纹的条件是$b_0 < \frac{R}{d}\lambda$,这一上界称为光源极限宽度。

+

固定b和R,则得到$d < \frac{R}{b}\lambda$,上界称为相干间隔。

+

光源中心对两孔的张角为$\theta = \frac{d}{R} < \frac{\lambda}{b}$,上界称为相干孔径角。

+

光程

用于计算光经过不同介质的相差。
$\Delta\varphi = \frac{2\pi r}{\lambda}$。

+

透镜不产生附加光程差。

+

薄膜干涉

为什么要薄?相干长度(时间相干性)限制。

+

薄膜干涉有实际意义的是等倾条纹和等厚条纹。

+

光程差

+
$$ +\delta = 2ne \cos r + \frac{\lambda}{2} +$$
+ +

e为膜厚度。

+

等厚条纹:

+

厚度不同,角度相同

+

单色平行光入射,近似垂直于膜表面,因而$i, r \approx 0$

+
$$ +\delta = 2ne + \frac{\lambda}{2} +$$
+ +

劈尖:

+

由于明纹需满足$\delta = k\lambda$,暗纹需满足$\delta = (2k+1)\lambda/2$,故相邻亮纹所在的厚度差为$\Delta e = \lambda / (2n)$,而条纹间距为$L = \Delta e / \theta = \lambda / (2n\theta)$

+

牛顿环:

+

+

可以得到暗环半径公式:$r_k=\sqrt{kR\lambda}$

+

总结:条纹跟着厚度走。

+

等倾条纹:

+

厚度相同,角度不同。

+

光程差(记!)

+
$$ +\delta = 2ne \cos r + \frac{\lambda}{2} = 2e\sqrt{n^2 - n^{\prime2}\sin ^2 i} + \frac \lambda2 +$$
+ +

等倾条纹实验通常采用面光源,因为透镜会把方向相同的光汇聚到一点,因而条纹的非常鲜明,衬比度很高,不会出现光源宽度和条纹衬比度的矛盾。

+

应用:增透膜和增反膜

+

迈克尔逊干涉仪

平行:等倾条纹

+

倾斜:等厚条纹

+

条纹缩进N个,代表厚度变化:

+
$$ +\Delta d = \frac{\lambda}{2n} = \frac {\lambda}{2} +$$
+ +

在光路上放一个介质,条纹移动N个:

+
$$ +\delta = 2(n - 1)l = N\lambda +$$
+ +

简而言之,一个条纹对应光程变化一个波长,厚度的变化(介质变化折算成厚度变化)乘以2等于光程的变化,因为一来一回经过了两次。

+

衍射

菲涅尔衍射和夫琅禾费衍射。

+

惠更斯-菲涅尔原理

+

夫琅禾费衍射研究光源和投影面在无限远处的情形。采用透镜将无限远转化为有限远。

+

单缝衍射(夫琅禾费)

利用半波带法计算明暗纹位置:

+

中央明纹:$a\sin \theta = 0$

+

暗纹:$a\sin \theta = \pm k\lambda$

+

明纹(近似):$a\sin \theta = \pm (2k + 1)\frac \lambda 2$

+

上述的$k$不能为0。因为如果k=0,即中央明纹,它没有半波带,因此要单独考虑。

+

光强公式:$I_p = I_0(\frac{\sin \alpha}{\alpha})^2$

+

其中$I_0$为中心亮纹强度,$\alpha = \frac{\pi a \sin \theta}{\lambda}$

+

条纹宽度:

+

条纹宽度的定义:两个相邻暗纹之间的距离,就是它们之间那个条纹的宽度。

+

中央明纹角宽度:$\Delta \theta_0\approx 2\frac{\lambda}{a}$,线宽度:$\Delta x_0 \approx 2 f \frac{\lambda}{a}$

+

其他明纹线宽度:$\Delta x \approx f\frac{\lambda}{a}$

+

光栅衍射

光栅是由衍射单元(狭缝、反射面等)排列成的具有空间周期性结构的光学元件。

+

光栅常数d-空间周期性结构常数

+

正入射光栅方程:$d\sin \theta = \pm k\lambda$。(明纹位置)

+

暗纹方程:$d\sin \theta = \pm k\lambda + \frac{m}{N}\lambda$

+

主极大缺级公式:$k = k^\prime d / a$

+

主极大半角宽:$\frac {\lambda}{N d \cos \theta_k}$

+

斜入射光栅方程:$d(sin\theta - \sin i) = \pm k\lambda$

+

斜入射可以获得更高级次的条纹,但是观察到的条纹总数不变。

+

调节入射角i或者波长$\lambda$,衍射角$\theta_k$也会改变。对于0级衍射光,$\sin \theta_0 = \frac{\lambda}{2\pi d}\Delta \varphi_{in}$

+

光学仪器的分辨本领:

+

艾里斑半角宽$D\sin \theta_1 \approx 1.22\lambda$

+

瑞利判据:一个象斑中心在另一个象斑边缘。

+

根据瑞利判据得到透镜分辨本领(最小分辨角):$R = \frac{D}{1.22\lambda}$

+

光栅光谱:

+

取决于光栅的色散能力和谱线(条纹)的线宽度

+

角色散本领:$D_{\theta} = \frac{\delta \theta}{\delta \lambda}$

+

色分辨本领:$R = \frac{\lambda}{\delta \lambda} = Nk$,$\delta \lambda$,$\lambda $取较小者的波长,$k$是主极大级数。

+

偏振

定义

线偏振光:光矢量做同向振动,方向不变。

+

圆偏振光:光矢量的端点是圆。

+

椭圆偏振光:光矢量的端点是椭圆。

+

非偏振光:例如自然光。它的振动方向随机,各个方向振幅相等。自然光可以分解为两束垂直振动,振幅相等,相差随机的线偏振光。

+

部分偏振光:自然光+完全偏振光。

+

偏振度:$P = \frac{I_p}{I_t} = \frac{I_p}{I_n + I_p}$

+

起偏与检偏

偏振片:利用二向色性。有微晶型和分子型。

+

线偏振光的起偏:通过偏振片。

+

马吕斯定律:$A = A_0 \cos \alpha, I = I_0 \cos^2 \alpha$

+

反射与折射中的偏振

S分量:垂直于入射面。P分量:平行于入射面。

+

反射光S分量多,折射光P分量多。

+

当$i = i_0$使得反射光只有S分量,折射光大部分是P分量。称为布儒斯特角。$i_0 + r_0 = 90\degree$,因而有布儒斯特定律:$\tg i_0 = \frac{n_2}{n_1}$

+

玻璃片堆可以增强反射光的强度,增加折射光的偏振程度。

+

散射引起光的偏振:

+

微粒散射:丁达尔效应

+

分子散射:纯净气体、液体的散射。

+

双折射现象:

+

1束光入射到各向异性介质内,产生2束折射光。o光为寻常光,符合折射定律;e光为非常光,不符合折射定律一般,也不一定在入射面内。o,e光都是线偏振光,振动方向互相垂直。

+

晶体光轴:是晶体中的特殊方向,光在晶体中沿该方向传播不发生双折射。方解石是单轴晶体。云母是双轴晶体。

+

主平面:晶体中光的传播方向与晶体光轴构成的平面。o光振动方向垂直于主平面,e的振动方向在主平面内。只有当光轴在入射面内,o光主平面、e光主平面、入射面才重合。

+

折射角度不同的本质是不同角度下光的传播速度不同。据此区分正晶体和负晶体:

+

$v_o$是o光速度,$v_e$是e光垂直光轴方向速度。o光是各向同性的,e光沿平行光轴方向的速度和o光相同,e光沿所有方向的速度构成一个旋转椭球面。

+

+

正晶体:$v_o > v_e$

+

负晶体:$v_o < v_e$

+

定义主折射率:$n_o = c/v_o, n_e = c/v_e$

+

利用惠更斯作图法可以讨论单轴晶体的光传播情况:

+

以负晶体为例。

+
    +
  • 若光轴平行于晶体表面,自然光垂直入射:o和e方向相同,速度不同,仍然是双折射;
  • +
  • 光轴平行晶体表面,且垂直入射面,自然光斜入射:e光也满足折射定律,折射率为$n_e$;
  • +
  • 光轴与晶体表面斜交,自然光垂直入射:e光偏离入射方向,惠更斯波面是斜椭圆。
  • +
+

研究晶片时,o光和e光(垂直振动和平行振动)是独立的正交的分量。垂直振动不会变成平行振动,平行振动也不会变成垂直振动。

+

双折射:两个垂直方向的线偏振光的不同速度造成的。

+

旋光:两个不同旋转方向的圆偏振光的不同速度造成的。

+

量子物理

黑体辐射

热辐射

+

物体受热发出电磁辐射。热辐射是连续谱,温度升高,短波成分增加。

+

平衡热辐射:物体温度不变时产生的热辐射。单位时间内物体吸收能量等于辐射能量。

+

光谱幅出度(单色幅出度)

+

单位面积内单位频率发射的电磁波能量。

+
$$ +M_\nu = \frac{\mathrm d E_\nu(T)}{\mathrm d\nu} +$$
+ +

总幅出度

+
$$ +M(T) = \int_0^\infty M_\nu(T)\mathrm d\nu +$$
+ +

单色吸收比

+
$$ +\alpha_\nu(T) = \frac{\mathrm d E_{\nu(吸收)}}{\mathrm d E_{\nu(入射)}} +$$
+ +

黑体

+

能吸收所有频率的电磁波,没有反射。$\alpha_{\nu}=1$。

+

基尔霍夫辐射定律:

+
$$ +\frac{M_{\nu i}}{\alpha_{\nu i}} = M_{\nu 黑体} +$$
+ +

实验定律:

+

维恩位移定律:$\nu_m = C_\nu T$, $\lambda_m = b/T$

+

注:$\lambda_m \nu_m \ne c$。

+

斯特藩-玻尔兹曼定律:$M(T) = \sigma T^4$,$\sigma$为斯特藩-玻尔兹曼常量。

+

韦恩公式:低频段不符合;

+

瑞利-金斯公式:高频段不符合。

+

普朗克能量子假设:$\varepsilon = h\nu$

+

普朗克公式:

+
$$ +M_\nu(T) = \frac{2\pi h}{c^2}\cdot \frac{\nu^3}{e^{h\nu/kT} - 1} +$$
+ +

由它可以导出所有其他热辐射公式。

+

光电效应

自学。

+

光的二象性

光子理论:能量$\varepsilon = h\nu$。光强:$I = N \cdot h\nu$,N是光子数流通量。

+

解释光电效应:

+
$$ +\frac 12 mv_m^2 = h\nu - A +$$
+ +

光的粒子性:

+
$$ +p = \frac h \lambda \\ +E = h\nu \\ +m = \frac{h\nu}{c^2} +$$
+ +

解释干涉和衍射:

+

光子在某处出现的概率是由该处的光强决定的:$I \propto \frac 1 {r^2}$,光子分布概率的不同导致了光强的不同。也就是说,光子的波动性表现为概率波。

+

光子在某处出现的概率和该处光强(光振幅的平方)成正比。

+

康普顿散射

散射波出现新的波长:$\Delta \lambda = \lambda_C(1 - \cos\varphi)$

+

利用光子理论解释:光子和“静止”的“自由”电子碰撞过程动量守恒,能量守恒。

+

解得$\Delta \lambda = \frac{h}{m_0c}(1 - \cos \varphi)$

+

如果光子撞到内层电子,则能量不变,因而存在原波长。

+

自由电子只能散射光子,不能吸收光子。如果吸收了,根据能量守恒和动量守恒,解得v=c,违反了相对论。

+

光电效应不考虑动量守恒,因为可见光、紫外线的能量低,电子不能视为自由,光子-电子不能视为动量守恒的系统。也因此,可见光观察不到康普顿效应。

+

概率波和概率幅

物质波的本质:

+

德布罗意认为是引导物质运动的“导波”;(本质不明确)

+

薛定谔认为波是基本的,电子是“波包”;(波包是不稳定的,而电子是稳定的)

+

另一个观点:粒子是基本的,物质波是电子相互作用形成的(被电子双缝实验否定)

+

波恩的解释:物质波是描述粒子在空间概率分布的“概率波”。

+

量子力学的基本假设之一:微观粒子的状态用波函数描述

+

概率波波函数(概率幅):复函数$\Psi (\vec r, t)$

+

波函数没有直接的物理意义。复函数模的平方$|\Psi (\vec r, t)|^2$表示概率密度。

+

波函数需要满足标准条件:

+

有限性:$\iiint_{\Delta V}|\Psi|^2 \mathrm dV$有限

+

归一性:$\int_\Omega |\Psi(\vec r, t)|^2 \mathrm dV = 1$

+

单值性:波函数是单值函数。

+

连续性:波函数和它的一阶导数是连续的。

+

双缝的波函数:等于通过上缝和下缝的波函数的线性叠加。$\Psi_{12}=\Psi_1+\Psi_2$。(一个基本假设)

+

微观粒子波动性实质是波函数的叠加性。

+

结合测量理解。

+

态叠加原理:$\Psi = \sum_n C_n\Psi_n$。其中$|C_n|^2$是该粒子处于$\Psi_n$状态的概率。

+

一维自由粒子的波函数:

+
$$ +\Psi(x, t) = A e^{i(px-Et)/\hbar} +$$
+ +

概率密度$|\Psi|^2 = |A|^2 = \text {const.}$

+

波粒二象性:

+

粒子性:具有能量$E$和动量$\vec p$。非经典粒子!没有轨道概念。

+

波动性:具有波长$\lambda$和频率$\nu$。非经典波!非真实物理量的波动。

+

不确定关系

$$ +\left<\vec r|\Psi\right> +$$
+ +

不确定度:$\Delta A = \sqrt{\overline{(A - \bar A)^2}}$

+

坐标和动量的不确定性关系:

+
$$ +\Delta x \cdot \Delta p \ge \frac \hbar 2 +$$
+ +

因而微观粒子没有“轨道”。

+

能量和时间的不确定性关系:

+
$$ +\Delta E \cdot \Delta t \ge \frac{\hbar}{2} +$$
+ +

时间不是力学量,它只是一个参数。位置,动量,能量等都是力学量。

+

薛定谔方程

定义

+
$$ +i\hbar \frac{\partial \Psi}{\partial t} = \hat {H} \Psi +$$
+ +

哈密顿算符:$\bar {H} = -\frac{\hbar ^2}{2m}\nabla^2 + U(\vec r, t)$

+

若势函数不显含时间,则哈密顿算符$\hat H$称为能量算符。此时薛定谔方程可以通过分离变量法求解。

+

定态薛定谔方程-能量本征方程

分离变量法求解:

+

若势函数不显含t,则可设:

+
$$ +\Psi(\vec r, t) = \Phi(\vec r) \cdot T(t) +$$
+ +

得到:

+
$$ +i\hbar \frac{\mathrm dT(t)}{\mathrm d t}\frac 1{T(t)} = [\hat H\Phi (\vec r)]\frac{1}{\Phi(\vec r)} = E +$$
+ +
$$ +T(t) = Ce^{-\frac{i}{\hbar}Et}\\ +() +$$
+ +

E称为能量本征值(后面会讲什么叫本征值),对应的$\Phi_E$称为本征波函数。

+

定态:能量取确定值的状态,对应薛定谔方程的特解:$\Psi_E(\vec r, t) = \Phi e^{-\frac{i}{\hbar}Et}$.

+

对不同的势函数和能量区间,能量的本征值可能取连续的值,也可能取分立的值。设E取分立值,$\lbraceE_n, n = 1, 2, 3, \dots\rbrace$,对应的本征波函数$\Psi_E (\vec r, t) = \Phi_E(\vec r)e^{-\frac{i}{\hbar}Et}$

+

下面通过求解一维定态薛定谔方程来讨论两类问题:

+

本征值问题:给定$U(x)$,求$E_n$和$\Phi_n(x)$。

+

散射问题:$E$已知,射向势垒$U(x)$,计算粒子穿透势垒的概率。

+

无限深方势阱中的粒子

背景:长度为$a$的导体中自由移动的电子,只能在导体中自由运动,而不能离开导体。

+

$|x| > a/2$时,$U(x) \rightarrow \infty$;

+

$|x| \le a/2$时,$U(x) = 0$。

+

在$|x| > a/2$区间,$\Phi_1 = 0$。

+

在$|x| \le a/2$区间,$\frac{\mathrm d^2 \Phi_2}{\mathrm dx^2} + \frac{2mE}{\hbar^2}\Phi_2 = 0$

+

记$k = \frac{2mE}{\hbar^2}$。解得$\Phi_2 = A\sin(kx + \varphi)$。

+

求解定态的常规手法:利用波函数的三个条件,即单值、有限、连续,确定$A, k, \varphi$。

+

利用连续条件,波函数在势阱边界处连续:

+
$$ +A\sin(\frac{ka}{2} + \varphi) = 0, A\sin(-\frac{ka}{2} + \varphi) = 0.\\ + +

\Rightarrow k = \frac{n\pi}{a}, \varphi = \frac{l\pi}{2}
$$

+

从而

+
$$ +E = \frac{\pi^2\hbar^2}{2ma^2}n^2 \ (n = 1, 2, 3, \dots) +$$
+ +

最低能量$E_1$被称为零点能。

+

大量子数情况下,能量趋向于连续。

+
$$ +l = 0, \varphi = 0, \Phi_2 = A\sin \frac{n\pi}{a}x = \Phi_{on},满足边界连续需要n为偶数\\ +l = 1, \varphi =\pi /2 , \Phi_2 = A\cos \frac{n\pi}{a}x = \Phi_{en},满足边界连续需要n为奇数\\ +l \ge 2,只差个符号,不影响|\Phi|^2,不再考虑。 +$$
+ +

求$A$:

+

归一化:$\int_{-a/2}^{a/2}|\Phi_{on}|^2 \mathrm dx = 1$, 得到$A = \sqrt \frac2a$

+
$$ +\Phi_{on} = \sqrt{\frac 2a}\sin \frac{n\pi}{a}x, n = 2, 4, 6, \dots\\ +\Phi_{en} = \sqrt{\frac 2a}\cos\frac{n\pi}{a}x, n = 1, 3, 5, \dots +$$
+ +

定态:

+
$$ + +

\Psi_n (x, t) = \Phi_n(x) \cdot e^{-\frac i\hbar Et}

+

$$

+

被称为驻波解(时间项指数为纯虚数,展开可以写成三角函数)。概率密度$|\Psi_n(x, t)|^2 = |\Phi_n(x)|^2$

+

势垒穿透

粒子进入势垒

背景:金属与半导体接触处,势能隆起形成势垒。粒子以能量为$E(E < U_0)$的状态自由入射。

+
$$ +U(x) = 0, x \le 0;\\ +U(x) = U_0, x \gt 0. +$$
+ +

量子力学认为有一部分粒子会穿透势垒。不仅有反射,还有投射。

+

定态薛定谔方程:

+
$$ +\Phi^{\prime\prime}(x) + \frac{2m}{\hbar^2}(E - U(x))\Phi(x) = 0 +$$
+ +

$x \le 0$:

+
$$ +k_1 = \sqrt{2mE/\hbar^2} > 0\\ +\Psi_1^{\prime\prime} + k_1^2 \Psi_1 = 0 +$$
+ +

$x \gt 0$:

+
$$ +ik_2 = \sqrt{2m(E - U_0)/\hbar^2} (k_2 > 0)\\ +\Psi_2^{\prime\prime} + (ik_2)^2\Psi_2 = 0 +$$
+ +

通解(利用了$x\rightarrow\infty$时$\Psi_2$的有界性):

+
$$ +\Psi_1(x) = Ae^{ik_1x} + Be^{-k_1x}(表现为入射和反射波)\\ +\Psi_2(x) = Ce^{k_2x}(表现为透射波) +$$
+ +

粒子可以出现在势垒区!表现为电子溢出金属表面,形成金属表面的一层电子气。

+

势垒区的概率密度:$|\Psi_2(x)|\propto e^{-\frac{2x}{\hbar}\sqrt{U_0 - E}}$

+

波可以穿过有限宽势垒,以平面波的形式继续前进。称为量子隧穿效应。
$\Psi_3(x) = Se^{i\frac {\sqrt{2mE}}{\hbar} x}$

+

扫描隧道显微镜:原理是量子隧穿效应,可以用来观测物质表面结构。

+

+
$$ +i \propto Ue^{-C\sqrt{\varPhi}d} +$$
+ +

$\varPhi$为样品表面平均势垒高度。

+

一维谐振子

$$ +U(x) = \frac 12 kx^2 = \frac 12m\omega^2x^2, \omega = \sqrt{\frac km} +$$
+ +

求解定态薛定谔方程得到

+
$$ +E_n = (n + \frac 12)\hbar \omega = (n + \frac 12)h\nu +$$
+零点能:$\frac{h\nu}{2}$。间距:$h\nu$。能量本征函数不用记。 + +

定态概率密度:

+

经典情况下:平衡位置处$\vec v$最大,停留时间最短,出现概率最小,振幅最大的时候$\vec v$为0,出现概率最大。量子数n趋于无穷时,量子概率分布趋于经典概率分布。

+

如果$E< U$,隧穿效应仍然存在。

+

力学量算符

以位矢$\vec r$为自变量的空间,称为“坐标表象”。在坐标表象中,动量和位矢不存在对应关系$\vec p = \vec p(\vec r)$(不确定关系)。

+

量子力学将动量、角动量、能量等力学量“算符化”。力学量算符是量子力学的一个基本假设。

+

力学量算符的引入

定义能量算符$\hat {E} \equiv i\hbar \frac{\partial}{\partial t}$,与表象无关。

+

坐标表象中定义动量算符$\hat{\vec p} = -i\hbar\nabla$,坐标算符$\hat{\vec r} = r$。

+

由于坐标表象下坐标算符就是坐标,因此势能算符$\hat{U} = U(\vec r)$。动能算符$\hat{E_k} = \frac{(-i\hbar\nabla)\cdot (-i\hbar\nabla)}{2m} = -\frac{\hbar^2}{2m}\nabla^2$

+

角动量算符$\hat{\vec L} = \hat{\vec r}\times \hat{\vec p} = -i\hbar\vec r \times \nabla$。如果用球极坐标,可得$\hat{L_z} = -i\hbar \frac{\partial}{\partial \varphi}$。角动量算符的模方由极角和方位角的导数组成:$\hat{L}^2 = -\frac {\hbar^2}{\sin \theta}\frac{\partial}{\partial \theta}(\sin \theta\frac{\partial}{\partial \theta}) +\frac{\hat{L_z^2}}{\sin^2\theta}$

+

本征值和本征函数

本征方程:$\hat{A}\Psi_n = A_n\Psi_n$。其中$A_n$为本征值,$\Psi_n$是$A$取$A_n$时的本征态,称为本征函数。

+

本征值就是相应力学量的可能取值。

+

$\hat A$的本征函数系${\Psi_n}$构成正交、归一的完备函数系。一维情况的归一化:$\int_{-\infty}^{+\infty}\Psi_n^*(x)\Psi_n(x)\mathrm dx = 1$。正交性:$\int_{-\infty}^{+\infty}\Psi_m(x)\Psi_n(x)\mathrm d x = \delta_{mn}$.

+

本征函数的完备性:在相同的函数空间内,任一物理上合理的归一化波函数,都可以由力学量A的本征函数系线性展开,即$\Psi = \sum_{n}C_n(t)\Psi_n(x)$。

+

态叠加原理:

线性展开公式:

+
$$ +\Psi(x, t) = \sum_{n }C_n(t)\Psi_n(x) \ (假设是归一化的) +$$
+ +

基本假设之一。

+

力学量的测量原理

量子力学假设:在$\Psi(x,t)$态上测量$A$,则$\Psi(x, t)$一定向着$A$的某个本征态$\Psi_n$塌缩,测量结果为$A_n$。

+

特别地,如果$\Psi = \Psi_n$,则测量结果是确定的,为$A_n$。

+

测量结果中$A_n$出现的概率为$|C_n(t)|^2$。

+
$$ +\bar A = \sum_n |C_n(t)|^2A_n = \int_{-\infty}^{+\infty}\Psi^*(x, t)\hat A\Psi(x, t)\mathrm dx +$$
+ + +

Dirac符号

量子态

本征值离散的:$\ket{n}$

+

本征值是连续的:$\ket{P_x}, \ket{x}$

+

它们各自张开一个线性空间。

+

内积空间

左矢与右矢一一对应,左矢张开一个共轭线性空间。

+

$\ket{A}$和$\ket{B}$的内积(复内积):$\langle B|A\rangle$

+

左矢空间与右矢空间通过复内积练习,称为内积空间。

+

线性算符

$$ +\hat{L}\ket{A} = \ket{B} +$$
+ +

满足:

+
    +
  • $\hat L (\ket{A} + \ket {B}) = \hat L\ket{A} + \hat L\ket{B}$

    +
  • +
  • $(\hat F + \hat G)\ket{A} = \hat F \ket{A} + \hat G\ket{A}$

    +
  • +
  • $\hat F(\hat G \ket{A}) = (\hat F \cdot \hat G)\ket {A}$

    +
  • +
+

共轭算符:$\bra{A}\bar{\hat L}$与$\hat L \ket{A}$一一对应,将$\bar{\hat L}$或者$\hat L ^+$称为共轭算符。

+

厄米算符:$\bar {\hat L} = \hat L$。

+

算符是向右结合的。

+

算符本征方程

$$ +\hat L \ket{L_n} = l_n\ket{L_n}\\ + +

\hat L\ket{n} = l_n\ket{n}
$$

+

$l_n$是本征值,$L_n$是本征态。

+

由测量原理,本征值必须是实数。所以可以观测的力学量对应的算符都是厄米算符。

+

态叠加原理

离散谱:

+
$$ +\bra{m}n\rangle = \delta_{mn}\\ +\ket{\psi} = \sum_n C_n\ket{n}\\ +概率幅:\bra{m}\psi \rangle = C_m\\ +\ket{A} = \sum_{n}(\bra{n}A\rangle)\ket{n} = \left(\sum_n \ket{n}\bra{n}\right)\ket{A}\\ +\Rightarrow \sum_n \ket{n}\bra{n}=1(本征矢的完备性表示) +$$
+ +

连续谱:

+
$$ +\bra{x_0^\prime}x_0\rangle = \delta(x_0^\prime - x_0)\\ +\ket{\psi} = \int_{-\infty}^{\infty}C(x_0)\ket{x_0}\mathrm dx_0 \\ +概率幅:\bra{x_0^\prime}\psi\rangle = C(x_0^\prime)\\ +\ket{\psi} = \int_{-\infty}^{\infty}\bra{x_0}\psi\rangle\ket{x_0}\mathrm dx_0 = \left(\int_{-\infty}^{\infty}\ket{x_0}\bra{x_0}\mathrm dx_0\right)\ket{\psi}\\ +\Rightarrow \int_{-\infty}^{\infty}\ket{x_0}\bra{x_0}\mathrm dx_0 = 1(连续谱的完备性方程) +$$
+ +

注:$C(x_0) = \bra{x_0}\psi\rangle$就是波函数$\psi(x_0)$。$|\bra{x_0}\psi\rangle|^2 = |\psi(x_0)|^2 = \psi^*(x_0)\psi(x_0)$是概率密度。

+

正则量子化假设

对易关系:$[\hat A, \hat B]= \hat A\hat B - \hat B\hat A$,若$[\hat A , \hat B]=0$,则称$A$与$B$对易,否则称不对易。

+

正则量子化假设:

+
$$ +[\hat{x}, \hat{p_x}] = i\hbar, +[\hat{y}, \hat{p_y}] = i\hbar, +[\hat{z}, \hat{p_z}] = i\hbar +$$
+ +

其余$x, y, z, p_x, p_y, p_z$的组合均对易。

+

满足$\hat{\vec A}\times \hat{\vec A} = i\hbar \hat{\vec A}$的算符被称为角动量。所有的角动量算符都满足这个关系。例如$\hat L = \hat r\times \hat p$,可以利用正则量子化假设对三个坐标进行计算验证。

+

$\hat A$和$\hat B$可以同时测准的充分必要条件:

+
$$ +[\hat A, \hat{B}] = 0\Leftrightarrow 有共同本征态 +$$
+ +

简并:1个本征值对应m个量子态,称为m重简并。

+

产生简并的原因:对称性=>守恒量。

+

如果$\hat A$是m重简并的,只测量得到本征值A,无法确定对应的量子态。但是如果同时测量对易的$\hat B$,就可以确定对应的$|A, B_i\rangle$,则对应的A的量子态是$|A_i\rangle$。

+

力学量完全集:能完备描述、确定量子态的力学量算符必须包含$\hat H$。

+

$\hat H$是核心力学量。

+
$$ +[\hat A, \hat H]=0\Leftrightarrow \hat A是守恒量 +$$
+选择力学量的完全集,就是选择守恒量的完全集。 + +

原子中的电子

氢原子理论

巴耳末公式->里德伯方程->波尔氢原子理论

+

氢原子理论:

+

定态条件

+

电子绕核作圆周运动,有确定能量,不辐射能量-经典轨道+定态

+

频率条件

+

电子在定态之间跃迁满足:$\nu = (E_i - E_f)/h$

+

轨道角动量:$L_n = mv_nr_n = n\hbar$,轨道半径$r_n = n^2r_1$

+

能级公式:$E_n = -13.6eV/n^2$

+

类氢离子能级:核外只有一个电子,核电荷数大于1.例如$He^+, Li^{2+}$

+

评价:

+

波尔理论解释了氢原子和类氢离子光谱的波长和频率。

+

但是不能解释氢原子的光谱线强度,也不能解释其他原子的光谱结构。

+
    +
  • 与经典电磁理论矛盾
  • +
  • 角动量量子化条件是硬加的
  • +
  • 卢瑟福的质疑:电子知道要往$E_2$跳才能往$E_2$跳,但是又必须先跳过去才能知道要往$E_2$跳
  • +
  • 薛定谔的非难:当电子离开$E_1$态之后,进入$E_2$态之前,它在哪里,是什么状态?
  • +
+

轨道概念不再适用。定态、能级、跃迁频率条件、角动量量子化仍然被认为是正确的。

+

氢原子的量子力学处理

求解量子问题的要点之一:确定体系的力学量完全集,即力学量可以同时测准,具有共同本征态,相应量子数集可完备地描述体系状态。

+

通常选择守恒量完全集,和体系对称性有关。

+

氢原子问题的守恒量完全集:$\hat H, \hat L^2, \hat L_z$

+

角动量量子化:

+

处于中心力场的氢原子电子,角动量守恒。

+

求$\hat L_z$的本征值:

+
$$ +\hat L_z = -i\hbar \frac{\partial }{\partial \varphi}\\ + +

\hat L_z \varPhi = L_z \varPhi\Rightarrow \varPhi = Ae^{\frac{i}{\hbar}L_z\varphi}
$$

+

根据标准条件(周期性),$\varPhi(\varphi) = \varPhi(\varphi + 2\pi)$,带入解得$L_z = m_l\hbar$,$m_l = 0, \pm1, \pm2,\dots$称为磁量子数。

+

对应的本征函数:$\varPhi_{m_l}(\varphi) = Ae^{im_l\varPhi} = \frac{1}{\sqrt{2\pi}}e^{im_l\varphi}$

+

求$\hat L^2$的本征值:

+

结论:$L^2 = l(l+1)\hbar^2$,$l = 0, 1, 2, \dots$称为角量子数。

+

($\hat L^2$和$\hat L_z$具有的共同本征值为球谐函数$Y_{ml}(\theta, \varphi)$)

+

角动量的空间量子化

+

$L = \sqrt{l(l+1)}\hbar > L_z = m_l\hbar \Rightarrow m_l = 0, \pm1, \pm2,\dots, \pm l$。作矢量图可知,角动量有$2l+1$种取向。

+

能量量子化

+

(省略公式)

+

$l = 0, 1, \dots, n - 1$

+

$\hat H, \hat L^2, \hat L_z$的共同本征态就是定态。

+

能量的本征值只与主量子数n有关,因而出现了能量简并,不同的角量子数和磁量子数可以对应相同的能量本征值。同能量的本征值态称为能级简并态,包含的态数目称为能级简并度。

+

角量子数$l = 0, 1, 2…$对应的状态分别称为$s, p, d…$,从概率波图像可以看出,角量子数低的电子更容易靠近原子中心。

+

电子自旋

轨道角动量产生磁矩:

+
$$ +\hat{\vec \mu} = -\frac{e}{2m_e}\hat{\vec L} +$$
+ +

玻尔磁子:

+
$$ +\mu_B = \frac{e\hbar}{2m_e} +$$
+ +

利用本征值的定义不难推出z方向的磁矩:

+
$$ +\mu_z = -m_l \cdot \mu_B +$$
+ +

斯特恩-盖拉赫实验

+

理论分析:

+

磁矩在外磁场中有势能:$E = -\vec \mu \cdot \vec B$

+

轨道磁矩在z方向受力:

+
$$ +F_z = \frac{\partial E}{\partial z} = \mu_z\frac{\partial B_z}{\partial z} = -m_l\mu_B\frac{\partial B_z}{\partial z} +$$
+ +

由于$m_l$的$2l+1$种取值,对应的原子束应该在z方向上分裂成奇数条线。

+

+

问题:$Ag, H$等原子束($l = 0$)出现了2条线而不是一条线,矛盾。

+

电子自旋的假设:

+
    +
  • 电子不是质点,而是自旋的小球,具有固有的自旋角动量$\vec S$和自旋磁矩$\vec \mu_S$
  • +
  • $S = \sqrt{s(s+1)}\hbar$,其中$s = \frac 12$称为自旋量子数
  • +
  • $S_z = m_s\hbar$,$m_s = \pm\frac 12$,称为自旋磁量子数
  • +
  • 自旋磁矩和自旋角动量满足$\hat {\vec \mu_S} = -\frac{e}{m_e}\hat {\vec S}$,进而推出$\mu_{S,z}=\pm \mu_B$
  • +
+

“自转小球”模型仍存在缺陷:电子表面的速度会超过光速。

+

但是这些假设成功解释了原子光谱的精细结构和反常塞曼效应。

+

量子力学的解释:

+
    +
  • 自旋是与时空无关的内禀运动,一种新的自由度,一种新的角动量,无经典对应
  • +
  • 自旋、磁矩和静止质量、电荷一样,是反映微观粒子固有属性的基本量
  • +
  • 电子的自旋是一种相对论效应,被自动地包含在相对论波动方程(Dirac方程)中。
  • +
+

电子的总角动量:

+
$$ +\hat {\vec J} = \hat {\vec L} + \hat {\vec S} +$$
+ +

$\hat {\vec J}$也是量子化的,大小为:

+
$$ +J = \sqrt{j(j + 1)}\hbar +$$
+ +

前文已说过如下定义:

+
+

满足$\hat{\vec A}\times \hat{\vec A} = i\hbar \hat{\vec A}$的算符被称为角动量。所有的角动量算符都满足这个关系。例如$\hat L = \hat r\times \hat p$,可以利用正则量子化假设对三个坐标进行计算验证。

+
+

可以验证$\hat {\vec J }\times \hat {\vec J } = i\hbar \hat {\vec J }$。因此总角动量还是角动量。

+

这一角动量的合成被称为自旋——轨道耦合。$j$称为总角动量量子数。

+
$$ +l = 0: +\\ +j = s = \frac 12, m_j = -\frac 12, +\frac 12\\ +l \ne 0:\\ +j = l + s = l + \frac 12, m_j = -(l + \frac 12), \dots, l + \frac 12;\\ +j = l - s = l - \frac 12, m_j = -(l - \frac12), \dots, l - \frac12 +$$
+ +

碱金属原子光谱:

+

碱金属的原子能级既和$n$有关,又和$l$有关。

+

轨道角动量对原子的影响包括轨道贯穿和原子实极化,导致相应能级能量降低。

+

因此原来相同能级的$3s,3p,…$会分裂成不同能级的轨道。

+

碱金属原子光谱的精细结构:

+

电子的轨道运动会使得它感受到原子绕它转动的磁场$\vec B_{Nuc}$的作用。

+

电子自旋磁矩$\vec \mu_s$和$\vec B_{Nuc}$的相互作用就是自旋轨道耦合,是相对论效应。

+

于是能级在自旋轨道耦合的影响下进一步分裂,形成了能级精细结构。

+

微观粒子全同性原理

两个微观粒子的全部内禀属性相同称为全同粒子。对调全同粒子不会影响系统的状态。

+

数学上对应地表现为波函数模方相同,进而有波函数对称或者反对称。

+

对称的波函数表达式:

+
$$ +\psi(q_1, q_2) = \frac {1}{\sqrt 2}[\phi_A(q_1)\phi_B(q_2) + \phi_A(q_2)\phi_B(q_1)] +$$
+ +

反对称的波函数表达式:

+
$$ +\psi(q_1, q_2) = \frac{1}{\sqrt{2}}[\phi_A(q_1)\phi_B(q_2) - \phi_A(q_2)\phi_B(q_1)] +$$
+ +

如果$\phi_A=\phi_B$,则反对称波函数为0。

+

费米子是自旋为半整数的粒子。它是波函数反对称的粒子。由此得到泡利不相容原理:全同费米子系统不能有两个及以上的费米子占据同一单粒子态。

+

玻色子是自旋为0或者整数的粒子。它是波函数对称的粒子。玻色子不受泡利不相容原理的限制。

+

费米统计:

+
$$ +N(E) = \frac{1}{e^{(E - \mu)/kT} + 1} +$$
+ +

$\mu = \mu(T)$是粒子化学势。

+

玻色统计:

+
$$ +N(E) = \frac{1}{e^{(E - \mu)/kT} - 1} +$$
+ +

对所有温度T,$0\le N(E)\lt \infty$。

+

玻色-爱因斯坦凝聚。

+

当$E$很高时,$(E - \mu) >> kT$。退化为麦克斯韦-玻尔兹曼统计。

+

原子核外电子的排布

4个量子数$n,l,m_l,m_s$可以完备描述原子的电子运动状态。

+
\ No newline at end of file diff --git a/2022/09/28/github-command/index.html b/2022/09/28/github-command/index.html new file mode 100644 index 00000000..e4cce130 --- /dev/null +++ b/2022/09/28/github-command/index.html @@ -0,0 +1,61 @@ +github的一些命令 | Guo_Yun + + + + + + + + + + + + + +

github的一些命令

如何删除某些提交?

删除最新的提交

git reset --hard HEAD^

+

可以删除最新的一次提交。若要删除多次提交,可以在HEAD后多加几个^。

+

删除/合并中间的某次提交

git rebase -i <commit_id>

+

填写要删除的提交的之前的那次提交的id。

+

之后会打开一个vim界面,显示

+
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
pick aaa
pick bbb
pick ccc
# Rebase xxx onto xxx (xxx command)
#
# Commands:
# p, pick <commit> = use commit
# r, reword <commit> = use commit, but edit the commit message
# e, edit <commit> = use commit, but stop for amending
# s, squash <commit> = use commit, but meld into previous commit
# f, fixup [-C | -c] <commit> = like "squash" but keep only the previous
# commit's log message, unless -C is used, in which case
# keep only this commit's message; -c is same as -C but
# opens the editor
# x, exec <command> = run command (the rest of the line) using shell
# b, break = stop here (continue rebase later with 'git rebase --continue')
# d, drop <commit> = remove commit
# l, label <label> = label current HEAD with a name
# t, reset <label> = reset HEAD to a label
# m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]
# . create a merge commit using the original merge commit's
# . message (or the oneline, if no original merge commit was
# . specified); use -c <commit> to reword the commit message
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
+ +

根据提示,使用drop会弃用那次commit的修改,使用squash则会将修改融合至上一条commit。根据个人需要进行操作。

+

同步到远程仓库

上述都是针对本地提交。如果已经提交到github了怎么办?本地删除后直接git push会显示提交数低于远程仓库,不能执行。

+

git push origin HEAD --force

+

强制将当前所在的HEAD所在的提交push到远程仓库,并且使远程仓库的提交记录和本地保持同步。

+
\ No newline at end of file diff --git a/2022/10/04/PhysicsExercise/index.html b/2022/10/04/PhysicsExercise/index.html new file mode 100644 index 00000000..3b7376a5 --- /dev/null +++ b/2022/10/04/PhysicsExercise/index.html @@ -0,0 +1,57 @@ +大雾习题笔记 | Guo_Yun + + + + + + + + + + + + + + + + +

大雾习题笔记

热学

气体压强越小,理想气体状态方程就越准确。

+

+

双原子分子的压强公式是$2n\bar\varepsilon_k/5$吗

+

无论分子有多少个原子,根据统计理论推算微观压强公式都应该是$p = 2n\bar\varepsilon_t/3$。原因是微观压强公式只考虑平动动能,不考虑转动和振动动能(显然转动和振动不会对压强造成影响)。而$\bar\varepsilon_k = \bar\varepsilon_t + \bar\varepsilon_r + \bar\varepsilon_v$。

+
\ No newline at end of file diff --git a/2022/11/10/stuffs/index.html b/2022/11/10/stuffs/index.html new file mode 100644 index 00000000..4d30d8fe --- /dev/null +++ b/2022/11/10/stuffs/index.html @@ -0,0 +1,189 @@ +杂项 | Guo_Yun + + + + + + + + + + + + + + + +

杂项

批处理命令设置环境变量
set path=xxxx

+

js爬虫

1.js保存字符串到本地

+
1
2
3
4
5
6
7
8
9
10
11
12
function saveShareContent (content, fileName) {
let downLink = document.createElement('a')
downLink.download = fileName
//字符内容转换为blod地址
let blob = new Blob([content])
downLink.href = URL.createObjectURL(blob)
// 链接插入到页面
document.body.appendChild(downLink)
downLink.click()
// 移除下载链接
document.body.removeChild(downLink)
}
+ +

2. 包含iframe/#document的文档

+
1
2
3
4
5
6
7
8
9
10
var ifram = document.querySelector("#iframe")
var idoc = ifram.contentWindow.document;
//console.log(idoc);
var ifram2 = idoc.querySelector("#ext-gen1046 > iframe")
var idoc2 = ifram2.contentWindow.document;
//console.log(idoc2);
var ifram3 = idoc2.querySelector("#frame_content");
var idoc3 = ifram3.contentWindow.document;
console.log(idoc3);
text = idoc3.documentElement.innerHTML;
+ +

层层剥开,否则在iframe内部的元素会定位失败。在F12界面右键选择“复制js路径”可以获取 querySeletor语句。

+

3.滚动至最低部

+
1
2
3
4
5
  var ele = document.documentElement;
if(ele.scrollHeight > ele.clientHeight) {
//设置滚动条到最底部
ele.scrollTop = ele.scrollHeight;
}
+ +

必要时可以增加 setTimeout等待网页加载完毕。

+

4.逐步滚动

+
1
2
3
4
5
6
7
8
9
10
11
12
13
var count = 0;
pos = document.documentElement.scrollTop;
console.log(pos);
var id = setInterval(
function (){
if (count < 500) {
document.documentElement.scrollTop++;
count++;
} else {
clearInterval(id);
}
}
, 2);
+ +

electron-vue

如何引入.node文件

+

需要将.node文件放在public文件夹下,引用时可以用相对路径也可以用 __static+文件名。

+

需要安装node-loader@1.0.3。太高的版本会导致问题。

+
1
const addon = require("node-loader!../public/addon.node")
+ +

在vue中使用ipcRenderer

+

主进程中引入ipcMain没啥大问题。
在vue文件中引入ipcRenderer,需要先在vue.config.js中配置

+
1
2
3
4
5
6
nodeIntegration: true

pluginOptions: {
electronBuilder: {
// 在vue中能引入electron模块
nodeIntegration: true,
+ +

然后在各个vue文件中引入

+
1
import { ipcRenderer } from 'electron'
+ +

math

一个只跟a, b中最大的那一个有关的积分:

+
$$ +\int_{0}^{\pi}\frac{\sin \theta}{\sqrt{a^2+b^2-2ab\cos\theta}}\mathrm d\theta = \frac{1}{ab}(|a+b| - |a-b|) +$$
+ +

js 小技巧

可变定时检测

问:每隔10秒检测一次当前页面是否包含某字符串,如果包含,则 console.log,下次检测的时间变为 100 秒

+

答:为了实现这个功能,你可以使用 setInterval函数来设置一个定期执行的任务。然而,因为你想在满足特定条件时改变间隔时间,你可能需要使用 setTimeout来代替,因为 setInterval的间隔时间一旦设定就无法改变。以下是如何实现这一逻辑的示例代码:

+
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function checkContentAndAdjustInterval(searchString, initialDelay, newDelay) {
// 定义一个函数,用于检查页面内容并根据条件调整定时器
function checkAndSchedule() {
// 检查文档中是否包含特定字符串
if (document.body.textContent.includes(searchString)) {
console.log(`页面包含指定字符串: ${searchString}`);
// 如果找到字符串,设置下一次检查的延时为 newDelay
setTimeout(checkAndSchedule, newDelay);
} else {
// 如果没有找到字符串,保持原来的检查频率
setTimeout(checkAndSchedule, initialDelay);
}
}

// 启动循环检查
setTimeout(checkAndSchedule, initialDelay);
}

// 使用示例:每隔10秒检查一次页面是否包含"特定字符串",
// 如果找到,则下次检查的时间间隔变为100秒
checkContentAndAdjustInterval("特定字符串", 10000, 100000);
+ +

这段代码首先定义了一个 checkContentAndAdjustInterval函数,它接受三个参数:要搜索的字符串 searchString、初始的检查间隔时间 initialDelay(以毫秒为单位)、以及在找到字符串后新的检查间隔时间 newDelay

+

checkContentAndAdjustInterval函数内部,定义了另一个名为 checkAndSchedule的函数。checkAndSchedule函数首先检查当前页面的内容是否包含指定的字符串。如果包含,它将使用 console.log输出一个消息,并使用新的延迟时间 newDelay来安排下一次执行。如果不包含指定的字符串,它将继续使用初始的延迟时间 initialDelay来安排下一次执行。

+

最后,checkContentAndAdjustInterval函数通过调用 setTimeout并传入 checkAndSchedule函数和初始延迟时间 initialDelay来启动整个检查流程。

+

这种方法的好处是你可以灵活地控制检查的间隔时间,而且它在满足特定条件后能够自动调整这个间隔,非常适合需要根据条件动态调整检查频率的场景。

+

NFS 常用指令

主要参考:如何在 Ubuntu 20.04 上安装和配置 NFS 服务器? - 知乎 (zhihu.com)

+

服务端绑定 NFS

直接绑定:

+
1
2
sudo mount --bind /opt/backups /srv/nfs4/backups
sudo mount --bind /var/www /srv/nfs4/www
+ +

要在重新启动后使绑定挂载永久化,请打开/etc/fstab文件:

+
1
sudo nano /etc/fstab
+ +

并添加以下行:

+
1
2
3
/etc/fstab
/opt/backups /srv/nfs4/backups none bind 0 0
/var/www /srv/nfs4/www none bind 0 0
+ +

/var/www 为本地需要绑定的文件夹,/srv/nfs4/www 为 NFS 管理的文件夹,必须以 /srv/nfs4开头。

+

绑定后,服务端可以修改 /var/www 内的文件,会被自动同步到 NFS 绑定的目录下。

+

客户端绑定 NFS

为挂载点创建两个新目录:

+
1
2
sudo mkdir -p /backups
sudo mkdir -p /srv/www
+ +

您可以在任何您想要的位置创建目录。

+

使用以下命令挂载导出的文件系统mount :

+
1
2
sudo mount -t nfs -o vers=4 192.168.33.10:/backups /backups
sudo mount -t nfs -o vers=4 192.168.33.10:/www /srv/www
+ +

要在重新启动时永久挂载,请打开/etc/fstab文件并添加以下行:

+
1
2
3
4
5
sudo nano /etc/fstab

/etc/fstab
192.168.33.10:/backups /backups nfs defaults,timeo=900,retrans=5,_netdev 0 0
192.168.33.10:/www /srv/www nfs defaults,timeo=900,retrans=5,_netdev 0 0
+ +

有关挂载 NFS 文件系统时可用选项的信息,请输入man nfs您的终端。

+

IP 检测

编辑配置文件

+
1
sudo nano /etc/exports
+ +

配置文件例子:

+
1
2
3
/srv/nfs4         192.168.33.0/24(rw,sync,no_subtree_check,crossmnt,fsid=0)
/srv/nfs4/backups 192.168.33.0/24(ro,sync,no_subtree_check) 192.168.33.3(rw,sync,no_subtree_check)
/srv/nfs4/www 192.168.33.20(rw,sync,no_subtree_check)
+ +

其中,192.168.33.0/24 等为需要过滤的 ip 规则。

+

应用 ip 设置

+
1
sudo exportfs -ar
+ +

查看 ip 检测

+
1
sudo exportfs -v
+ +

重启 NFS

1
sudo /etc/init.d/nfs-kernel-server restart
+ +

WSL 相关

WSL 寄了!

可能是因为配置 nfs 的原因吧,wsl 关掉之后就打不开了。

+
    +
  • wsl 无响应。
  • +
  • 当 ubuntu 处于停止状态时,wsl --list, wsl --status 有响应;但我一旦尝试运行 wsl 以启动 ubuntu,就无响应了。
  • +
  • wsl --help 一直没问题。
  • +
+

怀疑是配置 /etc/fstab 的时候出的问题,导致 wsl 无响应。

+

后来的解决方案:

+
    +
  1. ext4.vhdx 备份了一份。
  2. +
  3. 卸载 ubuntu distro,重新安装了一遍 ubuntu 22.04。
  4. +
  5. wsl --mount --vhdext4.vhdx 挂到新安装的 ubuntu wsl 上。
  6. +
+

幸好 ext4.vhdx 还在。

+

另外,挂完 ext4.vhdx 后,我将存有 ext4.vhdx 的移动硬盘拔出,然后重新打开 wsl,发现出现了同样的问题。这样就验证了我的假说:

+
    +
  • 我设置了开机默认挂载 nfs 硬盘,连接远程的服务器。
  • +
  • nfs 服务器因为一些原因没连上。
  • +
  • wsl 文件系统因为挂载的硬盘找不到了,发生错误。
  • +
  • wsl 在启动界面无响应。
  • +
+

重启了电脑,发现之前 wsl --mount 挂载的 ext4.vhdx 已经被清空了,证明 wsl –mount 命令的效果在重启之后清空了。

+

yarn add hasura-cli 安装失败

报错:

+
1
2
3
4
5
6
7
8
9
10
11
12
13
Command: node dist/index.js
Arguments:
Directory: /home/guoyun812/eesast/hasura/node_modules/hasura-cli
Output:
hasura-cli@2.36.1
Downloading Hasura CLI binary v2.36.1 from https://github.com/hasura/graphql-engine/releases/download/v2.36.1/cli-hasura-linux-amd64


hasura-cli@2.36.1
Error! Failed to install Hasura CLI binary.
Try npm uninstall hasura-cli or yarn remove hasura-cli and then reinstall it.
If the issue occurs repeatedly, check if your network can access https://github.com as the the Hasura CLI binary file is hosted on Github.
You can report the issue on https://github.com/jjangga0214/hasura-cli/issues with error message.
+ +

解决方案:手动下载 hasura-cli 的二进制文件,并粘贴到 node_modules/hasura/

+

SSH 相关

ssh 服务器

使用 ssh-keygen 时最好设置一个口令,否则别人也能用这个密钥。

+

常用命令

ssh 反向代理(服务器端口映射到本地端口),挂在后台

+
1
ssh -CqTfnN -R <remote_port>:localhost:<local_port>  -v  username@hostname -p <ssh_port>
+ +

ssh 前向代理(本地端口映射到服务器端口)

+
1
ssh -CqTfnN -L <local_port>:localhost:<remote_port>  -v  username@hostname -p <ssh_port>
+ +

将请求转发到 github

+
1
ssh -CqTfnN -L <local_port>:github.com:22 -v  username@hostname -p <ssh_port>
+ +

ssh agent

启动 ssh agent,并查看 pid

+
1
eval $(ssh-agent -s)
+ +

查看当前 agent 有哪些密钥

+
1
2
ssh-add -l # 查看公钥的 sha256
ssh-add -L # 查看完整公钥
+ +

添加密钥

+
1
ssh-add <private_key_path>
+ +

Node.js

listen EACCES: permission denied 0.0.0.0:3000

1、先判断是否是端口占用的问题导致的 netstat -ano| findstr 3000

+

关闭相关进程(cmd)

+
1
taskkill /PID <process_id> /F
+ +

发现并没有程序在使用这个端口

+

2、改用管理员再运行一遍

+

发现仍然不行

+

3、使用管理员权限运行以下命令

+

net stop winnat

+

net start winnat

+

Pytorch

Llama 架构

1713000493686

+

使用 Tensorboard

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from torch.utils.tensorboard import SummaryWriter
from accelerate.tracking import GeneralTracker, on_main_process
import os
from typing import Union

# 0. 自定义追踪器
class MyCustomTracker(GeneralTracker):
"""
my custom `Tracker` class that supports `tensorboard`. Should be initialized at the start of your script.

Args:
run_name (`str`):
The name of the experiment run
logging_dir (`str`, `os.PathLike`):
Location for TensorBoard logs to be stored.
kwargs:
Additional key word arguments passed along to the `tensorboard.SummaryWriter.__init__` method.
"""

name = "tensorboard"
requires_logging_directory = True

@on_main_process
def __init__(self, run_name: str, logging_dir: Union[str, os.PathLike],
**kwargs):
super().__init__()
self.run_name = run_name
self.logging_dir = os.path.join(logging_dir, run_name)
self.writer = SummaryWriter(self.logging_dir, **kwargs)

@property
def tracker(self):
return self.writer

@on_main_process
def add_scalar(self, tag, scalar_value, **kwargs):
self.writer.add_scalar(tag=tag, scalar_value=scalar_value, **kwargs)

@on_main_process
def add_text(self, tag, text_string, **kwargs):
self.writer.add_text(tag=tag, text_string=text_string, **kwargs)

@on_main_process
def add_figure(self, tag, figure, **kwargs):
self.writer.add_figure(tag=tag, figure=figure, **kwargs)

@on_main_process
def add_vector(self, tag, mat, **kwargs):
self.writer.add_embedding(tag=tag, mat=mat, **kwargs)

+ +

记录神经元的激活值

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
from torch import nn
import torch

class TestForHook(nn.Module):
def __init__(self):
super().__init__()

self.linear_1 = nn.Linear(in_features=2, out_features=2)
self.linear_2 = nn.Linear(in_features=2, out_features=1)
self.relu = nn.ReLU()
self.relu6 = nn.ReLU6()

def forward(self, x):
linear_1 = self.linear_1(x)
linear_2 = self.linear_2(linear_1)
relu = self.relu(linear_2)
relu6 = self.relu6(relu)
layers_in = (x, linear_1, linear_2)
layers_out = (linear_1, linear_2, relu)
return relu6

features_in_hook = []
features_out_hook = []

def hook(module, fea_in, fea_out):
print(f"hook! module: {module}, in: {fea_in}, out: {fea_out}")
features_in_hook.append(fea_in)
features_out_hook.append(fea_out)
return None

net = TestForHook()

"""
# 第一种写法,按照类型勾,但如果有重复类型的layer比较复杂
net_chilren = net.children()
for child in net_chilren:
if not isinstance(child, nn.ReLU6):
child.register_forward_hook(hook=hook)
"""

"""
推荐下面我改的这种写法,因为我自己的网络中,在Sequential中有很多层,
这种方式可以直接先print(net)一下,找出自己所需要那个layer的名称,按名称勾出来
"""

print(net)

layer_name = 'linear_1'
for (name, module) in net.named_modules():
if name == layer_name:
module.register_forward_hook(hook=hook)

print(features_in_hook) # 勾的是指定层的输入
print(features_out_hook) # 勾的是指定层的输出

rand_x = torch.rand(1, 2)
print(f"input x: {rand_x}")
result = net(rand_x)
print(f"result: {result}")
print(f"features in: {features_in_hook}")
print(f"features out: {features_out_hook}")
+
\ No newline at end of file diff --git "a/2023/01/21/CSAPP\345\255\246\344\271\240\347\254\224\350\256\260/index.html" "b/2023/01/21/CSAPP\345\255\246\344\271\240\347\254\224\350\256\260/index.html" new file mode 100644 index 00000000..fcb91c3f --- /dev/null +++ "b/2023/01/21/CSAPP\345\255\246\344\271\240\347\254\224\350\256\260/index.html" @@ -0,0 +1,57 @@ +CSAPP学习笔记 | Guo_Yun + + + + + + + + + + + + + + + +

CSAPP学习笔记

第三章

CSAPP第三版使用的GCC版本:4.8.1

+

Compiler Explorer

+

为什么p173要执行subq $8, %rsp?

为了对齐栈指针。x86要求栈指针为16的倍数,而每次调用函数后栈指针模16都会余个8,两次push使栈指针减少16,还是余8.

+

随笔

结构体字节对齐的结论:对齐要求取决于占据空间最大的元素。可以先安排较大元素,再安排较小元素。

+

答案纠错

3.43第4问答案有误。应为movq %rdi,(%rsi)

+
\ No newline at end of file diff --git a/2023/02/20/Introduction-to-Probability/index.html b/2023/02/20/Introduction-to-Probability/index.html new file mode 100644 index 00000000..52df8741 --- /dev/null +++ b/2023/02/20/Introduction-to-Probability/index.html @@ -0,0 +1,1534 @@ +Introduction-to-Probability | Guo_Yun + + + + + + + + + + + + + + + + + + + +

Introduction-to-Probability

Introduction

Probability Space

Probability space is a triple $(\Omega, \mathcal{F}, \mathbf{P})$, comprised of the following three
elements:

+

1 Sample space $\Omega$: the set of all possible outcomes of an experiment

+

2 $\sigma$-algebra (or $\sigma$-field) $\mathcal F$: a collection of subsets of $\Omega$

+

3 Probability measure $\mathbf P$: a function that assigns a nonnegative
probability to every set in the $\sigma$-algebra $\mathcal F$

+

Sample space

Mutually exclusive: no identical element.

+

Collectively exhaustive: all results should be included.

+

$\sigma$-algegra

not unique

+

3 requirements:

+
$$ +\varnothing \in \mathcal F\\ +\forall A \in \mathcal F, A^c \in \mathcal F\\ +\forall A_k \in \mathcal F, k=1, 2, ..., +\cup_{k=1}^{\infty}A_k\in \mathcal F +$$
+ +

Borel field

used to measure intervals

+

when $\Omega$ is continuous($\R$ for example), Borel field is useful.

+

“minimum” $\sigma$-algebra means deleting any element in the $\mathcal B (\mathbf R)$ will miss the requirements.

+

+

Uncountable

decimal numbers between 0 and 1 are uncountable.

+

Probability measures

$$ +P:\mathcal F \rightarrow [0, 1] +$$
+ +

Nonnegativity $P(A)\ge0, \forall A \in \mathcal{ F}$

+

Normalization $P(\empty)=0, P(\Omega)=1$

+

Countable additivity $A_1, A_2, … \text { is disjoint in }\mathcal F, P(A_1\cup A_2\cup …)=P(A_1)+P(A_2)+…$

+
    +
  • They are the axioms of probability.
  • +
  • Probability is a mapping from $\sigma$-algebra to a real number betwenn 0 and 1, which intuitively specifies the “likelihood” of any event.
  • +
  • There exist non-measurable sets, on which we cannot define a probability measure.
  • +
+

Discrete models

$$ +P(\lbraces_1, ..., s_n\rbrace)=P(s_1)+...+P(s_n)\\ +P(A) = \frac{\text{\# of elements of }A}{\text{total \# of elements of sample points}} +$$
+ + +

Continuous Models

Probability = Area

+

Some properties of Probability measure

$$ +A\sub B\Rightarrow P(A)\le P(B)\\ +P(A\cup B)=P(A)+P(B)-P(A\cap B)\\ +P(A\cup B) \le P(A) + P(B)\\ +P(A\cup B \cup C)=P(A) + P(A^C\cap B) + P(A^C\cap B^C\cap C) +$$
+ +

Conditional Probability

$$ +P(A|B)=\frac{P(A\cap B)}{P(B)} +$$
+ +
    +
  • If $P(B)=0$, $P(A|B)$ is undefined.
  • +
  • For a fixed event $B$, $P(A|B)$ can be verified as a legitimate probability measure on the new universe. $P(A, B)\ge 0$, $P(\Omega|B)=1$, $P(A_1\cup A_2\cup…|B)=P(A_1|B)+P(A_2|B)+…$
  • +
  • $P(A|B)=\frac{\text{ \# of elements of }A\cap B}{\text{total \# of elements of }B}$
  • +
+

Total probability theorem

Let $A_1, …, A_n$ be disjoint events that form a partition of the sample space and assume that $P(A_i)>0$ for all $i$. Then for any event B, we have

+
$$ +P(B) = \sum_{i=1}^n P(A_i\cap B) = \sum_{i=1}^nP(A_i)P(B|A_i) +$$
+ +

Remark

+
    +
  • The definition of partition is that $\cup_{i=1}^n A_i = \Omega, A_i\cap A_j = \emptyset, \forall i\ne j$
  • +
  • The probability of B is a weighted average of its conditional probability under each scenario
  • +
  • Each scenario is weighted according to its prior probability
  • +
  • Useful when $P(B|A_i)$ is known or easy to derive
  • +
+

Inference and Bayes’ rule

Let $A_1, …, A_2$ be disjoint events that from a partition of the sample space and assume that $P(A_i) \gt 0$ for all $i$. Then for any event $B$ such that $P(B)\gt 0$, we have

+
$$ +P(A_i|B) = \frac{P(A_i)P(B|A_i)}{P(B)} = \frac{P(A_i)P(B|A_i)}{\sum_{j=1}^nP(A_j)P(B|A_j)} +$$
+ +

Remarks

+
    +
  • Relates conditional probabilities of the form $P(A_i|B)$ with conditional probabilities of the form $P(B|A_i)$
  • +
  • often used in inference: effect $B$ $\lrarr$ cause $A_i$
  • +
+

The meaning of $P(A_i|B)$ in the view of Bayes: the belief of $A_i$ is revised if we observed effect $B$. If the cause and the effect are closely binded($P(B|A_i) > P(B|A_i^c)$), then the belief $A_i$ is enhanced by the observation of effect $B$($P(A_i|B) > P(A)$). This can be derived from the Bayes’ rule through simple calculation. If $P(A_i|B)=P(A_i)$, then $B$ provides no information on $A_i$.

+

Independence

Independence of two disjoint events

Events A and B are called independent if

+
$$ +P(A\cap B) = P(A)\cdot P(B) +$$
+or equivalently, when $P(B) > 0$, + +
$$ +P(A|B) = P(A) +$$
+ +

Remarks

+
    +
  • Occurrence of B provides no information about A’s occurrence
  • +
  • Equivalence due to $P(A\cap B) = P(B)\cdot P(A|B)$
  • +
  • Symmetric with respect to $A$ and $B$.
  • +
    • +
    • applies even if $P(B) = 0$
    • +
    +
  • +
    • +
    • implies $P(B|A) = P(B)$ and $P(A|B^c) = P(A)$
    • +
    +
  • +
  • Does not imply that A and B are disjoint, indeed opposite!
  • +
    • +
    • Two disjoint events are never independent!($P(A\cap B) = 0$, but $P(A)\cdot P(B)\ne 0$)
    • +
    +
  • +
+

Conditional independence

$$ +P(A\cap B | C) = P(A| C) \cdot P(B|C) +$$
+ +

Definition

+

Event $A_1, A_2, …, A_n$ are called independent if:

+
$$ +P(A_i\cap A_j\cap ...\cap A_q) = P(A_1)P(A_j)...P(A_q) +$$
+ +

for any distinct indices $i, j, \dots q$ chosen from ${1, \dots n}$.

+

Pairwise is independence does not imply independence.

+

Discrete Random Variables

Random Variable is neither random, nor variable.

+

Definition

We care about the probability that $X \le x$ instead $X = x$ in the consideration of generality.

+

Random variables

+

Given a probability space $(\Omega, F, P)$, a random variable is a function $X: \Omega \rightarrow \R$ with the probability that ${\omega \in \Omega: X(\omega) \le x} \in \mathcal F$ for each $x\in \R$. Such a function $X$ is said to be $\mathcal F$-measurable.

+

Probability Mass Function(PMF)

+
$$ +p_X(x)=P(X=x)=P(\{\omega \in \Omega \text{ s.t. } X(\omega)=x\}) +$$
+ +

Bonulli PMF:

+
$$ +p_X(k) = \begin{cases} + p, &\text{if } k = 1\\ + 1-p, &\text{if }k=0 +\end{cases} +$$
+ +

Binomial PMF: $p_X(k)=\binom{n}{k}p^k(1-p)^{n-k}$

+

Geometric PMF: $p_X(k)=(1-p)^{k-1}p$

+

Poisson PMF: $p_X(k)=e^{-\lambda}\frac{\lambda^k}{k!}$. Note: $\sum_{k=0}^\infty e^{-\lambda}\frac{\lambda^k}{k!}=e^{-\lambda}e^\lambda=1$

+

If $y=g(x)$, $p_Y(y)=\sum_{\lbrace x|g(x)=y \rbrace} p(x)$.

+

Expectation and Variance

Expectation

+
$$ +E[X] = \sum_x xp_X(x) +$$
+ +

Note: we assume that the sum converges.

+

Properties:

+
$$ +E[Y]=\sum_x g(x)p_X(x)\\ +E[\alpha X + \beta] = \alpha E[X] + \beta +$$
+ +

Variance

+
$$ +\text{var}(X) = E \left[(X-E[X])^2\right]=\sum_x (x-E[X])^2 p_X(x) +$$
+ +

Standard deviation: $\sigma_X=\sqrt{\text{var}(X)}$

+

Properties:

+
$$ +\text{var}(X) = E[X^2] -(E[X])^2\\ +\text{var}(X)\ge 0\\ +\text{var}(\alpha X + \beta) = \alpha^2\text{var} (X) +$$
+ +

Bernoulli RV

+
$$ +p_X(k) = \begin{cases} + p, &\text{if } k = 1\\ + 1-p, &\text{if }k=0 +\end{cases}\\ +E[X] = p\\ +E[X^2] = p\\ +\text{var}(X) = p(1-p) +$$
+ +

Discrete Uniform RV

+
$$ +p_X(k) = \begin{cases} + \frac {1}{b-a+1}, &\text{if } k = a, a+1, ..., b\\ + 0, &\text{otherwise} +\end{cases}\\ +E[X] = \frac{a+b}{2}\\ +\text{var}(X) = \frac{(b-a)(b-a+2)}{12} +$$
+ +

Poisson RV

+
$$ +p_X(k)=e^{-\lambda}\frac{\lambda^k}{k!}\\ +E[X] = \lambda\\ +\text{var}(X)=\lambda +$$
+ +

Conditional

$$ +p_{X|A(x)} = P(X=x|A) = \frac{P(\{X=x\}\cap A)}{P(A)} +$$
+ +
$$ +\sum_x p_{X|A}(x) = 1 +$$
+ +
$$ +E[X|Y=y] = \sum_x xp_{X|Y}(x|y)\\ +E[g(X)|Y=y] = \sum_x g(x)p_{X|Y}(x|y) +$$
+ +

Total expectation theorem

+

$A_1, \dots, A_n$ is a partition of sample space

+
$$ +P(B) = P(A_1)P(B|A_1) + \dotsb + P(A_n)P(B|A_n)\\ +p_X(x) = P(A_1)p_{X|A_1}(x) + \dotsb + P(A_n)p_{X|A_n}(x)\\ +E[X] = P(A_1)E[X|A_1] + \dotsb + P(A_n)E[X|A_n] +$$
+ +

We derive the expectation and variance use the theories above.

+

Geometric PMF example

+
$$ +p_X(k) = (1-p)^{k-1}p, k = 1, 2, \dots\\ +E[X] = \sum_{k=1}^\infty kp_X(k) = \sum_{k=1}^\infty k(1-p)^{k-1}p\\ +E[X^2] = \sum_{k=1}^\infty k^2p_X(k) = \sum_{k=1}^\infty k^2(1-p)^{k-1}p\\ +\text {var}(X) = E[X^2] - (E[X])^2 +$$
+ +

However, the Geometric has a memoryless property.

+
$$ +p_{X|X>1}(k) = \frac{P(\{X>1\}\cap \{X=k\})}{P(X>1)} = \frac{(1-p)^{k-1}p}{1-p} = (1-p)^{k-2}p +$$
+ +

Thus,

+
$$ +E[X] = P(X=1)E[X|X=1] + P(X>1)E[X|X>1]=p+(1-p)(E[1 + X])\\ +\Rightarrow E[X] = 1/p\\ +E[X^2] = P(X=1)E[X^2|X=1] + P(X>1)E[X^2|X>1] = p + (1-p)E[(1+X)^2]=p + (1-p)(1+2E[X]+E[X^2])\\ +\Rightarrow E[X^2] = \frac{2-p}{p^2}\\ +\Rightarrow\text{var} (X) = \frac{1-p}{p^2} +$$
+ +

Multiple discrete random variables

Joint PMFs

+
$$ +p_{X, Y}(x, y) = P(X = x, Y= y) = P(\{X(\omega) = x\}\cap \{Y(\omega) = y\}) +$$
+ +
$$ +\sum_x\sum_y p_{X, Y}(x, y) = 1 +$$
+ +

Marginal PMF

+
$$ +p_X(x) = \sum_y P(X=x, Y=y) = \sum_y p_{X, Y}(x, y) +$$
+ +

Conditional PMF

+
$$ +p_{X|Y}(x|y) = P(X = x | Y = y) = \frac{p_{X, Y}(x, y)}{p_Y(y)} +$$
+ +
$$ +\sum_x p_{X|Y}(x|y) = 1 +$$
+ +

Funcitons of multiple RVs

+
$$ +Z = g(X, Y)\\ +p_Z(z) = \sum_{\lbrace (x, y)|g(x, y)=z \rbrace } p_{X, Y}(x, y) +$$
+ +

Expectations

+
$$ +E[g(X, Y)] = \sum_x\sum_y g(x, y)p(X, Y)(x, y)\\ +E[g(X, Y, Z)] = \sum_x\sum_y\sum_z g(x, y, z)p(X, Y, Z)(x, y, z) +$$
+ +
$$ +E[g(X, Y)] \not\equiv g(E[X], E[Y]) +$$
+ +

linearity

+
$$ +E[\alpha X + \beta] = \alpha E[X] + \beta\\ +E[X + Y + Z] = E[X] + E[Y] + E[Z] +$$
+ +

Let’s calculate the Mean of Binominal RV.

+
$$ +X_i= +\begin{cases} + 1, &\text{if success in trial } i,\\ + 0, & \text{otherwise.} +\end{cases}\\ +X = X_1 + X_2 + \dotsb X_n\\ +E[X] = \sum_{i = 1}^n E[X_i] = np\\ +\text{var}(X) = np(1-p) +$$
+ +

Independence

Independence

+
$$ +p_{X, Y}(x, y) = p_X(x) \cdot p_Y(y) +$$
+ +

if $X$ and $Y$ are independent:

+
$$ +E[XY] = E[X]E[Y]\\ +E[g(X)h(Y)] = E[g(X)]E[h(Y)]\\ +\text{var}(X + Y) = \text{var}(X) + \text{var}(Y) +$$
+ +

Conditional independence

+
$$ +p_{X, Y|A}(X, Y) = p_{X|A}(x) \cdot p_{Y|A}(y) +$$
+ +

Continuous Random Variables

Probability Density Function

    +
  • $f_X(x)\ge 0\text{ for all }x$
  • +
  • $\int_{-\infty}^\infty f_X(x)\mathrm dx = 1$
  • +
  • If $\delta$ is very small, then $P([x, x+\delta])\approx f_X(x) \cdot \delta$
  • +
  • For any subset $B$ of the real line, $P(X\in B) = \int_B f_X(x)\mathrm d x$.
  • +
+

Expectation

+
$$ +E[X] = \int_{-\infty}^\infty xf_X(x)\mathrm dx\\ +E[g(x)] = \int_{-\infty}^\infty g(x)f_X(x)\mathrm dx +$$
+ +

Assuming that the integration is well-defined. The Cauchy distribution ($\frac{1}{1+x^2}$)doesn’t have expectation since $\frac{x}{1+x^2}$ is not absolutely integrably.

+

Variance

+
$$ +\text{var}(X) = E[(X - E[X])^2] = \int_{-\infty}^\infty(x - E[x])^2 f_X(x)\mathrm dx\\ +0\le \text{var}(x) = E[X^2] - (E[X])^2 +$$
+ +

Uniform RV

+
$$ +f_X(x) = \begin{cases} + \frac{1}{b-a}, &\text{if }a\le x\le b,\\ + 0, &\text{otherwise.} +\end{cases} +$$
+ +
$$ +E[X] = \frac{a+b}{2}\\ +E[X^2] = \frac{a^2+b^2 + ab}{3}\\ +\text{var}(X) = \frac{(b-a)^2}{12} +$$
+ + +

Properties:

+
$$ +E[aX+b] = aE[X] + b\\ +\text{var}(aX+b) = a^2\text{var}(X) +$$
+ +

Common Example for PDF

Exponential Random Variable

+
$$ +f_X(x) = \begin{cases} + \lambda e^{-\lambda x}, &\text{if }x \ge 0,\\ + 0, &\text{otherwise.} +\end{cases} +$$
+ +
$$ +P(X\ge a) = e^{-\lambda a}\\ +E[X] = \frac{1}{\lambda}\\ +\text{var}(X) = \frac{1}{\lambda^2} +$$
+ +

Cumulative Distribution Functions

$$ +F_X(x) = P(X\le x) = \begin{cases} + \sum_{k\le x}p_X(k), &\text{if } X \text{ is discrete,}\\ + \int_{-\infty}^x f_X(t)\mathrm dt, &\text{if } X \text{ is continuous.} +\end{cases} +$$
+ +

Properties

+
$$ +\text{if } x \le y, \text{then } F_X(x)\le F_X(y).\\ +F_X(x)\text{ tends to 0 as } x \rightarrow -\infty, \text{and to 1 as} x \rightarrow \infty\\ +\text{If } X \text{ is discrete, then } F_X(x) \text{ is a piecewise constant function of }x.\\ +\text{If } X \text{ is continuous, then } F_X(x) \text{is a continuous funciton of }x.\\ +\text{If } X \text{ is discrete and takes integer values, the PMF and the CDF can be obtained from each other by summing or differcing: }\\ +F_X(k) = \sum_{i = -\infty}^k p_X(i),\\ +p_X(k) = P(X\le k) - P(X \le k -1) = F_X(k) - F_X(k - 1),\\ +\text{ for all integers }k.\\ +\text{If } X \text{ is continuous, the PDF and the CDF can be obtained from each other by integration or differentiation: }\\ +F_X(x) = \int_{-\infty}^x f_X(t)\mathrm dt, f_X(x) = \frac{\mathrm dF_X}{\mathrm dx}(x) +$$
+ +

Examples for CDF

Geometric CDF

+
$$ +F_{\text{geo}}(n) = \sum_{k = 1}^n p(1-p)^{k-1} = 1-(1-p)^n, \text{for } n = 1, 2, \dots +$$
+ +

Exponential CDF

+
$$ +F_{\text{exp}}(x) = P(X\le x) = 0, \text{ for } x\le0,\\ +F_{\text{exp}}(x) = \int_{0}^x \lambda e^{-\lambda t}\mathrm dt = 1 - e^{-\lambda x}, \text{for }x\ge 0. +$$
+ +

Exponential Distribution is Memoriless, like Geometric:

+
$$ +P(X \ge c + x| X \ge c) = e^{-\lambda x} = P(X \ge x)\\ +$$
+ +

The relationship:

+

+

Normal Random Variables

$$ +f_X(x) = \frac{1}{\sqrt{2\pi}\sigma}e^{-(x-\mu)^2/2\sigma^2}\\ +E[X] =\mu\\ +\text{var}(X) = \sigma^2 +$$
+ +

Gaussian is good, since adding two Gaussian functions resulting in a new Gaussian functions. And with a huge mount of samples, the distribution is close to Gaussian(Central limit theorem).

+

The Standard Normal Random Variable

+

Normal(Gaussian)

+
$$ +Y = \frac{X - \mu}{\sigma}\\ +f_Y(y) = \frac{1}{\sqrt{2\pi}}e^{-y^2/2}\\ +E[Y] = 0\\ +\text{var}(Y) = 1\\ +$$
+ +

The CDF of Normal Random Variable $\Phi(y)$ can not be derived directly, we can use the standard normal table to get the value.

+
$$ +\Phi(-y) = 1 - \Phi(y) +$$
+ +

Multiple Continuous Random Variables

Joint PDFs

+

The two continuous RVs X and Y, with the same experiment, are jointly continuous if they can be described by a joint PDF $f_{X, Y}$, where $f_{X, Y}$ is a nonnegative function that satisfies

+
$$ +P((X, Y) \in B) = \iint_{(x, y)\in B} f(X, Y)\mathrm d x\mathrm dy +$$
+ +

for every subset B of the two-dimensional plane. In particular, when B is the form $B = {(x, y)|a\le x \le b, c\le y \le d}$, we have

+
$$ +P(a\le X \le b, c \le Y \le d) = \int_c^d\int_a^bf_{X, Y}(x, y)\mathrm dx\mathrm dy +$$
+ +

Normalization

+
$$ +\int_{-\infty}^\infty\int_{-\infty}^\infty f_{X, Y}(x, y)\mathrm dx\mathrm dy = 1 +$$
+ +

Interpretation(Small rectangle)

+
$$ +P(a\le X \le a + \delta, c \le Y \le c + \delta) \approx f_{X, Y}(a, c)\cdot\delta^2 +$$
+ +

Marginal PDF

+
$$ +P(X\in A) = P(X \in A, Y \in (-\infty, \infty)) = \int_A \int_{-\infty}^\infty f_{X, Y}(x, y)\mathrm dy\mathrm dx +$$
+ +
$$ +f_X(x) = \int_{-\infty}^\infty f_{X, Y}(x, y)\mathrm dy\\ +f_Y(y) = \int_{-\infty}^\infty f_{X, Y}(x, y)\mathrm dx +$$
+ +

Joint CDF

+

If X and Y are two RVs asscociated with the same experiment, then the joint CDF of X and Y is the function

+
$$ +F_{X, Y}(x, y) = P(X\le x, Y\le y) = P(X\le x|Y\le y)P(Y\le y) = \int_{-\infty}^y\int_{-\infty}^x f_{X, Y}(u, v)\mathrm du\mathrm dv +$$
+ +

Conversely

+
$$ +f_{X, Y}(x, y) = \frac{\partial^2F_{X, Y}}{\partial x\partial y}(x, y) +$$
+ +

Expectations

+
$$ +E[g(X, Y)] = \int_{-\infty}^\infty\int_{-\infty}^\infty g(x, y)f_{X, Y}(x, y)\mathrm dx\mathrm dy +$$
+ +

If g is linear, of the form of $g(x, y) = ax + by + c$, then

+
$$ +E[g(X, Y)] = aE[X] + bE[Y] + c +$$
+ +

X and Y are called independent if

+
$$ +f_{X, Y}(x, y) = f_X(x)f_Y(y) +$$
+ +

Conditional and Independence

Conditional PDFs

+

Let X and Y be continuous RVs with joint PDF $f_{X, Y}$. For any $f_Y(y) \gt 0$, the conditional PDF of X given Y = y is defined by

+
$$ +f_{X|Y}(x|y) = \frac{f_{X, Y}(x, y)}{f_Y(y)} +$$
+ +

Discrete case:

+
$$ +p_{X|Y}(x|y) = \frac{p_{X, Y}(x, y)}{p_Y(y)} +$$
+ +

By analogy, for fixed y would like:

+
$$ +P(x \le X \le x + \delta|Y = y) \approx f_{X|Y}(x|y)\cdot\delta +$$
+ +

But {Y = y} is a zero-probability event.

+

Let $B = {y\le Y \le y + \epsilon}$, for small $\epsilon > 0$. Then

+
$$ +P(x \le X \le x + \delta|Y \in B) \approx \frac{P(x \le X \le x + \delta)}{P(y \le Y \le y + \epsilon)} \approx \frac{f_{X, Y}(x, y)\cdot\epsilon\delta}{f_Y(y)\cdot\epsilon} \approx f_{X|Y}(x|y)\cdot\delta +$$
+ +

Limiting case when $\epsilon \rightarrow 0$, to define conditional PDF where the denominator is a zero-probability event.

+

Conditional Expectation

+

The conditional expectation of X given that A has happened is defined by

+
$$ +E[X|A] = \int_{-\infty}^\infty xf_{X|A}(x)\mathrm dx +$$
+ +

For a function g, we have

+
$$ +E[g(X)|A] = \int_{-\infty}^\infty g(x)f_{X|A}(x)\mathrm dx +$$
+ +

Total expectation theorem

+

Le $A_1, A_2, \dots A_n$ be disjoint events that form a partition of the sample space $\Omega$. And $P(A_i)\gt 0$ for all $i$. Then

+
$$ +E[g(X)] = \sum_{i=1}^n P(A_i)E[g(X)|A_i] +$$
+ +

Conditional Expectation

+

The conditional expectation of X given that $Y = y$ has happened is defined by

+
$$ +E[X|Y=y] = \int_{-\infty}^\infty xf_{X|Y}(x|y)\mathrm dx +$$
+ +

For a function g, we have

+
$$ +E[g(X)|Y=y] = \int_{-\infty}^\infty g(x)f_{X|Y}(x|y)\mathrm dx +$$
+ +

Total expectation theorem

+
$$ +E[X] = E_{Y}\left[E_{X|Y}[X|Y]\right] = \int_{-\infty}^\infty E[X|Y = y]f_Y(y)\mathrm dy +$$
+ +

Independence

+

Two continuous RVs $X$ and $Y$ are independent if and only if

+
$$ +f_{X, Y}(x, y) = f_X(x)f_Y(y) +$$
+ +

Independence is the same as the condition

+
$$ +f_{X|Y}(x|y) = f_X(x) +$$
+ +

If $X$ and $Y$ are independent, then

+
$$ +E[XY] = E[X]E[Y]\\ +E[g(x)h(y)] = E[g(x)]E[h(y)], \forall g, h\\ +\text{var}(X + Y) = \text{var}(X) + \text{var}(Y)\\ +$$
+ +

The continuous Bayes’s rule

$$ +f_{Y|X}(y|x) = \frac{f_Y(y)f_{X|Y}(x|y)}{f_Y(y)} +$$
+ +

Based on the normalization property $\int_{-\infty}^\infty f_{X|Y}(x|y)\mathrm dx = 1$,

+
$$ +f_{Y|X}(y|x) = \frac{f_Y(y)f_{X|Y}(x|y)}{\int_{-\infty}^\infty f_X(t)f_{Y|X}(y|t)\mathrm dt} +$$
+ +

Derived distributions and Entropy

Derived Distribution

If we want to calculate the expectation $E[g(X)]$, there’s no need to calculate the PDF $f_X$ of $X$.

+

But sometimes we want the PDF $f_Y$ of $Y = g(X)$, where $Y$ is a new RV.

+

Principal Method

+

Two-step procedure for the calculation of the PDF of a function $Y=g(X)$ of a continuous RV $X$

+
    +
  1. Calcualte the CDF $F_Y$ of $Y$: $F_Y(y) = P(Y \le y)$
  2. +
  3. Differentiate $F_Y$ to obtain the PDF $f_Y$ of $Y$: $f_Y(y) = \frac{\mathrm d F_Y}{\mathrm d y}(y)$
  4. +
+

The PDF of $Y=aX + b$

+

Suppose $a>0$ and $b$ are constants.

+
$$ +f_Y(y) = \frac{\mathrm d F_Y}{\mathrm d y}(y) = \frac{\mathrm d}{\mathrm d y} F_X(\frac{y-b}{a}) = \frac{1}{a}f_X(\frac{y-b}{a}) +$$
+ +

If $X$ is Normal, then $Y = aX + b$ is also Normal.

+

Suppose X is normal with mean $\mu$ and variance $\sigma^2$. Then

+
$$ +f_Y(y) = \frac{1}{a\sqrt{2\pi\sigma^2}}\exp\left(-\frac{(y-b-a\mu)^2}{2a^2\sigma^2}\right) +$$
+ +
$$ +Y = aX + b \sim N(a\mu + b, a^2\sigma^2) +$$
+ +

The PDF of a strictly monotonic function

+

Suppose $g$ is a strictly monotonic function and that for some function $h$ and all $x$ in the range of $X$ we have

+
$$ +y = g(x) \text{ if and only if } x = h(y) +$$
+ +

Assume that $h$ is differentiable.

+

Then the PDF of $Y = g(X)$ is given by

+
$$ +f_Y(y) = \frac{\mathrm d F_Y}{\mathrm d y}(y) = \frac{\mathrm d}{\mathrm d y} F_X(h(y)) = f_X(h(y))\left|\frac{\mathrm d h}{\mathrm d y}(y)\right| +$$
+ +

Entropy

Defintion

+

Discrete case

+

Let $X$ be a discrete RV defined on probability space $(\Omega, \mathcal F, P)$. The entropy of $X$ is defined by

+
$$ +H(X) = -E[\ln p_X(X)] = -\sum_{k} p_X(x_k)\ln p_X(x_k) +$$
+ +

Continuous case

+

Let $X$ be a continuous RV defined on probability space $(\Omega, \mathcal F, P)$. The differential entropy of $X$ is defined by

+
$$ +H(X) = -E[\ln f_X(X)] = -\int_{-\infty}^\infty f_X(x)\ln f_X(x)\mathrm dx +$$
+ + +

Remarks

+
    +
  • a special expectation of a random variable
  • +
  • a measure of uncertainty in a random experiment
  • +
    • +
    • the larger the entropy, the more uncertain the experiment
    • +
    +
  • +
    • +
    • For a deterministic event, the entropy is zero
    • +
    +
  • +
  • The base of logarithm can be different. Changing the base od the logarithm is equivalent to multiplying the entropy by a constant.
  • +
    • +
    • With base 2, we say that the entropy is in units of bits
    • +
    +
  • +
    • +
    • With base e, we say that the entropy is in units of nats
    • +
    +
  • +
  • The basis of information theory
  • +
+

Maximum entropy distributions

• Maximum entropy distributions

+

− Distributions with maximum entropy under some constraints

+

− Gaussian, exponential, and uniform distributions are all maximum entropy distributions under certain conditions

+

• Why studying maximum entropy distributions?

+

− The most random distribution, reflecting the maximum uncertainty about the quantity of interest

+

Definition

+

Discrete Case

+

X can be a finite number of values $x_1, x_2, \dots, x_n$, satisfying $p_X(x_k) = p_k.$

+

We have the following optimization problem:

+
$$ +\max_{X} H(X) = \max_{p_1, p_2, \dots, p_n} \left(-\sum_{k=1}^n p_k\ln p_k\right)\\ +\text{s.t.} \sum_{k=1}^n p_k = 1, p_k \ge 0 \text{ for } k = 1, 2, \dots, n +$$
+ +

Solution

+

Applying the Lagrange multiplier method, we have

+
$$ +L(p_1, p_2, \dots, p_n;\lambda) = -\sum_{k=1}^n p_k\ln p_k + \lambda\left(\sum_{k=1}^n p_k - 1\right)\\ +\frac{\partial L}{\partial p_k} = -\ln p_k - 1 + \lambda = 0\\ +\Rightarrow p_k = e^{\lambda - 1}\\ +$$
+ +

Note that the above is true for all $k$. So we have

+
$$ +p_k = e^{\lambda - 1} = \frac1{n}\text{ for } k = 1, 2, \dots, n. +$$
+ +

Continuous Case 1

+

$X \in [-\infty, \infty]$.

+

Constrain on mean and variance,
we have the following optimization problem:

+
$$ +\max_{X}h(X), \\ +\text{s.t. }E[X] = \mu, \quad Var(X) = \sigma^2 +$$
+ +

In detail,

+
$$ +\max_{X} H(X) = \max_{\mu, \sigma^2} \left(-\int_{-\infty}^\infty f_X(x)\ln f_X(x)\mathrm dx\right)\\ +\text{s.t. }\int_{-\infty}^\infty f(x)\mathrm dx = 1, \quad \int_{-\infty}^\infty xf(x)\mathrm dx = \mu, \quad \int_{-\infty}^\infty x^2f(x)\mathrm dx = \sigma^2 + \mu^2 +$$
+ +

Solving the above problem, we have Gaussian distribution with mean $\mu$ and variance $\sigma^2$.

+
$$ +f(x) = \frac{1}{\sqrt{2\pi\sigma^2}}\exp\left(-\frac{(x-\mu)^2}{2\sigma^2}\right) +$$
+ +

Solution

+

For all measurable functions $g$, we have

+
$$ +G(t) = h(f + tg) = -\int_{\infty}^\infty (f(x) + tg(x))\ln (f(x) + tg(x))\mathrm dx +$$
+ +

Therefore,

+
$$ +h(f_{opt})\ge h(f_{opt} + tg)\\ +\Rightarrow G(0)\ge G(t), \forall t \in \R +$$
+ +

$G(t)$ reaches its maximum at $t = 0$.

+

Then apply the Lagrange multiplier method, we have

+
$$ +\overline{G}(t) = G(t) + c_0h_0(t) + c_1h_1(t) + c_2h_2(t)\\ +$$
+ +

Get the derivative of $\overline{G}(t)$ with regard to $t$, and let the derivative equal to zero.

+

Continuous Case 2

+

$X \in [0, \infty)$.

+

Constrain on mean only, we have the following optimization problem:

+
$$ +\max_{X}h(X), \\ +\text{s.t. }E[X] = \mu +$$
+ +

In detail,

+
$$ +\max_{X} H(X) = \max_{\mu} \left(-\int_{0}^\infty f_X(x)\ln f_X(x)\mathrm dx\right)\\ +\text{s.t. }\int_{0}^\infty f(x)\mathrm dx = 1, \quad \int_{0}^\infty xf(x)\mathrm dx = \mu +$$
+ +

Solving the above problem, we have exponential distribution with parameter $\lambda$.

+
$$ +f(x) = \lambda e^{-\lambda x}, x \in [0, \infty) +$$
+ +

Continuous Case 3

+

$X \in [a, b]$.

+

No constrain, we have the unconstrained optimization problem:

+
$$ +\max_{X}h(X) +$$
+ +

In detail,

+
$$ +\max_{X} H(X) = \max_{a, b} \left(-\int_{a}^b f_X(x)\ln f_X(x)\mathrm dx\right)\\ +\text{s.t. }\int_{a}^b f(x)\mathrm dx = 1 +$$
+ +

Solving the above problem, we have uniform distribution within $[a, b]$.

+
$$ +f(x) = \frac{1}{b-a}, x \in [a, b] +$$
+ +

Convolution, covariance, correlation, and conditional expectation

Convolution

Discrete case

+
$$ +\begin{align*} +p_W(w) &= P(X+Y=w)\\ +&= \sum_{x}P(X=x, Y=w-x)\\ +&= \sum_{x}P(X=x)P(Y=w-x)\\ +&= \sum_{x}p_X(x)p_Y(w-x)\\ +\end{align*} +$$
+ +

PMF $p_W$ is the convolution of PMFs $p_X$ and $p_Y$.

+

The distribution of $X+Y$

+

Mechanics:

+
    +
  • Put the PMF’s on top of each other
  • +
  • Flip the PMF of $Y$
  • +
  • Shift the flipped PMF by $w$ (to the right if $w>0$)
  • +
  • Cross-multiply and add
  • +
+

Continuous Case

+
$$ +\begin{align*} +&W = X+Y, X, Y \text{ are independent}\\ +&P(W\le w|X=x) = P(Y\le w-x)\\ +&f_{W|X}(w|x) = f_Y(w-x)\\ +&f_{W, X}(w, x) = f_X(x)f_Y(w-x)\\ +&f_W(w) = \int_{-\infty}^\infty f_X(x)f_Y(w-x)\mathrm dx\\ +\end{align*} +$$
+ +

Sum of 2 independent normal RVs

+
$$ +\begin{align*} + & X\sim N(\mu_1, \sigma_1^2), Y\sim N(\mu_2, \sigma_2^2)\\ + &f_{X,Y}(x, y) = \frac{1}{2\pi \sigma_x\sigma_y}\text{exp}\left\lbrace-\frac{(x-\mu_x)^2}{2\sigma_x^2} - \frac{(y-\mu_y)^2}{2\sigma_y^2}\right\rbrace +\end{align*} +$$
+ +

which is constant on the ellipse(circle if $\sigma_x = \sigma_y$).

+
$$ +\begin{align*} + X\sim N(0, \sigma_x), &Y\sim N(0, \sigma_y)\\ + W &= X+Y\\ + f_W(w) &= \int_{-\infty}^\infty f_{X,Y}(x, w-x)\mathrm dx\\ + &= \int_{-\infty}^\infty \frac{1}{2\pi \sigma_x\sigma_y}\text{exp}\left\lbrace-\frac{x^2}{2\sigma_x^2} - \frac{(w-x)^2}{2\sigma_y^2}\right\rbrace\mathrm dx\\ + =ce^{-\gamma \omega^2} +\end{align*} +$$
+ +

$W$ is Normal.

+

Mean = 0, Variance = $\sigma_x^2 + \sigma_y^2$

+

Same argument for nonzero mean case.

+

The difference of two independent RVs

+

$X$ and $Y$ are independent exponential RVs with parameter $\lambda$.

+

Fix some $z\ge 0$ and note that $f_Y(x-z)$ is non zero when $x\ge z$.

+
$$ +\begin{align*} + Z &= X - Y\\ + f_Z(z) &= \int_{-\infty}^\infty f_X(x)f_{-Y}(z - x)\mathrm dx\\ + &= \int_{-\infty}^\infty f_X(x)f_{Y}(x - z)\mathrm dx\\ + &= \int_{z}^\infty \lambda e^{-\lambda x}\lambda e^{-\lambda(x-z)}\mathrm dx\\ + &= \frac{\lambda}{2}e^{-\lambda z} +\end{align*} +$$
+ +

The answer for the case $z\le 0$

+
$$ +f_{X-Y}(z) = f_{Y-X}(z) = f_Z(-z) +$$
+ +

The first quality holds by symmetry.

+

Covariance and Correlation

Definition

+

The covariance of two RVs $X$ and $Y$, denoted by $\text{cov}(X, Y)$, is defined by

+
$$ +\text{cov}(X, Y) = E\left[(X - E[X])(Y - E[Y])\right] +$$
+ +

or,

+
$$ +\text{cov}(X, Y) = E[XY] - E[X]E[Y] +$$
+ +

$X$ and $Y$ are uncorrelated if $\text{cov}(X, Y) = 0$.

+

Zero mean case $\text{cov}(X, Y) = E[XY]$

+

Properties

+
$$ +\text{cov}(X, Y) = \text{var}(X, Y)\\ +\text{cov}(X, aY+b) = a\cdot\text{cov}(X, Y)\\ +\text{cov}(X, Y+Z) = \text{cov}(X, Y) + \text{cov}(X, Z)\\ +\text{independent} \Rightarrow \text{cov}(X, Y) = 0(\text{converse is not true}) +$$
+ +

Variance of the sum of RVs

+
$$ +\text{var}\left(\sum_{i = 1}^nX_i\right) = \sum_{i = 1}^n\text{var}(X_i) + \sum_{\lbrace(i, j)|i\ne j\rbrace}\text{cov}(X_i, X_j) +$$
+ +

In particular,

+
$$ +\text{var}(X_1 + X_2) = \text{var}(X_1) + \text{var}(X_2) + 2\text{cov}(X_1, X_2) +$$
+ +

Correlation coefficient

+

The correlation coefficient $\rho(X, Y)$ of two RVs $X$ and $Y$ that have nonzero variance is defined as

+
$$ +\begin{align*} +\rho &= E\left[\frac{(X - E[X])}{\sigma_X} \cdot \frac{(Y - E[Y])}{\sigma_Y}\right]\\ +&= \frac{\text{cov}(X, Y)}{\sigma_X\sigma_Y} +\end{align*} +$$
+ +
    +
  • $-1 \le \rho \le 1$
  • +
  • $|\rho| = 1 \Leftrightarrow (X-E[X]) = c(Y-E[Y])$
  • +
  • Independent $\Rightarrow \rho = 0(\text{converse is not true})$
  • +
+

Conditional expected value

+
$$ +E[X|Y = y] = \sum_x xp_{X|Y}(x|y) +$$
+ +

Conditional expectation

Definition

+
$$ +E[X|Y = y] = \begin{cases} + \sum_x xp_{X|Y}(x|y), & X \text{discrete},\\ + \int_{-\infty}^\infty xf_{X|Y}(x|y)\mathrm dx, & X \text{continuous}. +\end{cases} +$$
+ +

$E[X|Y=y]$ is a function of $y$.

+
$$ +E[X|Y = y] = \frac{y}{2}(\text{number})\\ +E[X|Y] = \frac{Y}{2}(\text{RV}) +$$
+ +

Law of iterated expectations

+
$$ +E[X] = E[E[X|Y]] = \begin{cases} + \sum_y E[X | Y = y]p_Y(y), & Y \text{discrete},\\ + \int_{-\infty}^\infty E[X|Y = y]f_Y(y)\mathrm dy, & Y \text{continuous}. +\end{cases} +$$
+ +

Conditional expectation as an estimator

Denote the conditional expectation

+
$$ +\hat{X} = E[X|Y] +$$
+ +

as an estimator of $X$ given $Y$, and the estimation error

+
$$ +\tilde{X} = X - \hat{X} +$$
+ +

is a RV.

+

Properties of the estimator:

+

Unbiased

+

For any possible $Y=y$:

+
$$ +E[\tilde{X}|Y] = E[X - \hat{X} | Y] = E[X | Y] - E[\hat{X}|Y] = \hat{X} - \hat{X} = 0 +$$
+ +

By the law of iterated expectations

+
$$ +E[\tilde{X}] = E[E[\tilde{X}|Y]] = 0 +$$
+ +

Uncorrelated

+
$$ +E[\hat{X}\tilde{X}] = E[E[\hat{X}\tilde{X}|Y]] = E[\hat{X}E[\tilde{X}|Y]] = 0 +$$
+ +
$$ +\text{cov}(\hat{X}, \tilde{X}) = E[\hat{X}\tilde{X}] - E[\hat{X}]E[\tilde{X}] = 0 +$$
+ +

Since $X = \hat{X} + \tilde{X}$, the variance of X can be decomposed as

+
$$ +\text{var}(X) = \text{var}(\hat{X}) + \text{var}(\tilde{X}) +$$
+ +
$$ +\text{var}(\tilde{X}) = \text{var}(E[X|Y]) +$$
+ +

Conditional variance

+
$$ +\text{var}(X|Y) = E[(X - E[X|Y])^2|Y] = E[\tilde{X}^2|Y] +$$
+ +

here comes the law of total variance:

+
$$ +\text{var}(X) = \text{var}(E[X|Y]) + E[\text{var}(X|Y)] +$$
+ +

The total variability is avarage variability within sections + variability between sections.

+

Law of iterated expectations

+
$$ +E[X] = E[E[X|Y]] = \sum_y E[X|Y = y]p_Y(y) +$$
+ + +

Conditional variance

+
$$ +\text{var}(X|Y) = E[(X - E[X|Y])^2|Y] = E[\tilde{X}^2|Y] +$$
+ +

Law of total variance

+
$$ +\text{var}(X) = \text{var}(E[X|Y]) + E[\text{var}(X|Y)] +$$
+ + +

Transforms and sum of a random number of random variables

The transform associated with a RV $X$ is a function $M_X(s)$ of a scalar parameter $s$, defined by

+
$$ +M_X(s) = E[e^{sX}] = \begin{cases} + \sum_x e^{sx}p_X(x), & X \text{discrete},\\ + \int_{-\infty}^\infty e^{sx}f_X(x)\mathrm dx, & X \text{continuous}. +\end{cases} +$$
+ +

Remarks

+
    +
  • a function of $s$, rather than a number
  • +
  • not necessarily defined for all (complex) s
  • +
  • always well defined for $\Re(s)=0$
  • +
  • compared with Laplace transform
  • +
+

Properties

Sanity Checks

+
$$ +M_X(0) = 1\\ +|M_X(s)| \le 1 \text{ for } \Re(s) = 0 +$$
+ +

Linear operation

+
$$ +M_{aX + b}(s) = e^{bs}M_X(as)\\ +M_{X + Y}(s) = M_X(s)M_Y(s) (\text{if X, Y independent}) +$$
+ +

Expected Values

+
$$ +E[X^n] = \frac{\partial^n M_X(s)}{\partial s^n}\bigg|_{s=0} +$$
+ +
$$ +P(X = c) = \lim_{N\rightarrow \infty}\frac 1N\sum_{k = 1}^N M_X(jk)e^{-jkc} +$$
+ +

since

+
$$ +\lim_{N\rightarrow \infty}\frac 1N\sum_{k = 1}^N M_X(jk)e^{-jkc} = \sum_{x = 1}^\infty p_X(x)\lim_{N\rightarrow \infty}\frac 1N\sum_{k = 1}^N e^{-jc(k - x)} = \sum_{x = 1}^\infty p_X(x)\lim_{N\rightarrow \infty}\frac{1}{N} \frac{e^{j(x-c)} - e^{Nj(x - c)}}{1-e^{j(x-c)}} = p_X(c) +$$
+ +

Example

+

$X$ is a Poisson RV with parameter $\lambda$

+
$$ +p_X(x) = \frac{\lambda^x}{x!}e^{-\lambda} +$$
+ +
$$ +M(s) = \sum_{x = 0}^\infty e^{sx}\frac{\lambda^x}{x!}e^{-\lambda} = e^{-\lambda}\sum_{x = 0}^\infty \frac{(e^s\lambda)^x}{x!} = e^{-\lambda}e^{e^s\lambda} = e^{\lambda(e^s - 1)} +$$
+ +

$X$ is an exponential RV with parameter $\lambda$

+
$$ +f_X(x) = \lambda e^{-\lambda x} +$$
+ +
$$ +M(s) = \int_0^\infty e^{sx}\lambda e^{-\lambda x}\mathrm dx = \frac{\lambda}{\lambda - s} +$$
+ +

$Y$ is a standard normal RV,

+
$$ +M_Y(s) = \int_{-\infty}^\infty \frac{1}{\sqrt{2\pi}}e^{-(y^2/2)}e^{sy}\mathrm dy = e^{s^2/2} +$$
+ +

Consider $X = \sigma Y + \mu$

+
$$ +M_X(s) = e^{s^2\sigma^2/2 + \mu s} +$$
+ +

Inversion of transforms

Inversion Property

+

The transform $M_X(s)$ associated with a RV $X$ uniquely determines the CDF of $X$, assuming that $M_X(s)$ is finite for all $s$ in some interval $[-a, a]$, where $a$ is a positive number.

+

Example:

+
$$ +\begin{align*} +M(s) &= \frac{pe^s}{1 - (1 - p)e^s}\\ +&= pe^s(1 + (1-p)e^s + (1-p)^2e^{2s} + \dotsb)\\ +&= \sum_{k = 1}^\infty p(1-p)^{k - 1}e^{ks} +\end{align*} +$$
+ +

The probability $P(X = k)$ is found by reading the coefficient of the term $e^{ks}$:

+
$$ +P(X = k) = p(1-p)^{k-1} +$$
+ +

Transform of Mixture of Distributions

Let $X_1,\dotsb, X_n$ be continuous RVs with PDFs $f_{X_1}, \dotsb, f_{X_n}$.

+

The value $y$ of RV $Y$ is generated as follows: an index $i$ is chosen with a corresponding probability $p_i$, and $y$ is taken to be equal to the value $X_i$. Then,

+
$$ +f_Y(y) = p_1f_{X_1}(y) + \dotsb + p_nf_{X_n}(y)\\ +M_Y(s) = p_1M_{X_1}(s) + \dotsb + p_nM_{X_n}(s) +$$
+ +

Sum of independend RVs

Let $X$ and $Y$ be independent RVs, and let $Z = X + Y$. The transform associated with $Z$ is

+
$$ +M_Z(s) = M_X(s)M_Y(s) +$$
+ +

Since

+
$$ +M_Z(s) = E[e^{sZ}] = E[e^{s(X + Y)}] = E[e^{sX}e^{sY}] = E[e^{sX}]E[e^{sY}] = M_X(s)M_Y(s) +$$
+ +

Generalization:

+

A collection of independent RVs: $X_1, \dotsb, X_n$, $Z = X_1 + \dotsb + X_n$ ,

+
$$ +M_Z(s) = M_{X_1}(s)\dotsb M_{X_n}(s) +$$
+ +

Example

+

Let $X_1, \dotsb, X_n$ be independent Bernoulli RVs with a common parameter $p$:

+
$$ +M_{X_i}(s) = 1 - p + pe^s +$$
+ +

$Z = X_1 + \dotsb + X_n$ is binomial with parameters n and p:

+
$$ +M_z(s) = (1 - p + pe^s)^n +$$
+ +

Let $X$ and $Y$ be independent Poisson RVs with means $\lambda$ and $\mu$, and let $Z = X + Y$. Then $Z$ is still Poisson with mean $\lambda + \mu$.

+
$$ +M_Z(s) = M_X(s)M_Y(s) = e^{(\lambda +\mu)(e^s - 1)} +$$
+ +

Let $X$ and $Y$ be independent Gaussian RVs with means $\mu_x$ and $\mu_y$, and variances $\sigma_x^2, \sigma_y^2$. And let $Z = X + Y$. Then $Z$ is still Gaussian with mean $\mu_x + \mu_y$ and variance $\sigma_x^2 + \sigma_y^2$

+
$$ +M_X(s) = \exp\bigg\lbrace\frac{\sigma_x^2s^2}{2} + \mu_x s\bigg\rbrace\\ +M_Y(s) = \exp\bigg\lbrace\frac{\sigma_y^2s^2}{2} + \mu_y s\bigg\rbrace\\ +M_Z(s) = M_X(s)M_Y(s) = \exp\bigg\lbrace\frac{(\sigma_x^2 + \sigma_y^2)s^2}{2} + (\mu_x + \mu_y)s\bigg\rbrace +$$
+ +

Consider

+
$$ +Y = X_1 + \dotsb + X_N +$$
+ +

where $N$ is a RV that takes integer values, and $X_1, \dotsb, X_N$ are identically distributed RVs.

+

Assume that $N, X_1, \dotsb$ are independent.

+
$$ +E[Y|N = n] = E[X_1 + X_2 + \dotsb + X_n|N = n] = nE[X]\\ +E[Y|N] = NE[X]\\ +E[Y] = E[E[Y|N]] = E[NE[X]] = E[N]E[X] +$$
+ +

For the variance,

+
$$ +E[Y|N] = NE[X]\\ +\text{var}(E[Y|N]) = (E[X])^2\text{var}(N)\\ +\text{var}(Y|N=n) = n\text{var}(X)\\ +\text{var}(Y|N) = N \text{var}(X)\\ +E[\text{var}(Y|N)] = E[N]\text{var}(X)\\ +$$
+ +

So,

+
$$ +\text{var}(Y) = E[\text{var}(Y|N)] + \text{var}(E[Y|N]) = E[N]\text{var}(X) + (E[X])^2\text{var}(N) +$$
+ +

For transform,

+
$$ +E[e^{sY}|N = n] = E[e^{sX_1}\dotsb e^{sX_n}|N = n] = E[e^{sX}]^n = (M_X(s))^n\\ +M_Y(s) = E[e^{sY}] = E[E[e^{sY}|N]] = E[(M_X(s))^N] = \sum_{n = 0}^\infty (M_X(s))^n p_N(n) = \sum_{n = 0}^\infty e^{n\log M_X(s)}p_N(n) = M_N(\log M_X(s)) +$$
+ +

Summary on Properties

+

Consider the sum

+
$$ +Y = X_1 + \dotsb + X_N +$$
+ +

where $N$ is a RV that takes integer values, and $X_1, X_2, \dotsb$ are identically distributed RVs. Assume that $N$, $X_1, X_2, \dotsb$ are independent.

+
$$ +E[Y] = E[N]E[X]\\ +\text{var}(Y) = E[N]\text{var}(X) + (E[X])^2\text{var}(N)\\ +M_Y(s) = M_N(\log M_X(s)) +$$
+ +

Example

+

Assume that $N$ and $X_i$ are both geometrically distributed with parameters $p$ and $q$ respectively. All of these RVs are independent. $Y = X_1 + \dotsb + X_N$

+
$$ +M_N(s) = \frac{pe^s}{1 - (1-p)e^s}\\ +M_X(s) = \frac{qe^s}{1 - (1-q)e^s}\\ +M_Y(s) = M_N(\log M_X(s)) = \frac{pqe^s}{1 - (1-pq)e^s} +$$
+ +

$Y$ is also geometrically distributed, with parameter $pq$.

+

Weak law of large numbers

Markov inequality

If a RV $X$ can only take nonnegative values, then

+
$$ +P(X \ge a) \le \frac{E[X]}{a}, \text{ for all } a \gt 0. +$$
+ +

Intuition: If a nonnegative RV has a small mean, then the probability that it takes a large value must be small。

+

Fix a positive number $a$,

+
$$ +E[X] = \int_0^\infty xf_X(x)dx = \int_0^a xf_X(x)dx + \int_a^\infty xf_X(x)dx \ge 0 + \int_a^\infty xf(x)dx \ge \int_a^\infty af_X(x)dx = aP(X \ge a) +$$
+ +

Chebyshev’s Inequality

If $X$ is a RV with mean $\mu$ and variance $\sigma^2$, then

+
$$ +P(|X - \mu| \ge c) \le \frac{\sigma^2}{c^2} +$$
+ +

Intuition: If a RV has small variance, then the probability that it takes a value far from its mean is also small.

+
$$ +\begin{align*} +\sigma^2 &= \int (x - \mu)^2f_X(x)\mathrm dx\\ +&\ge \int_{-\infty}^{\mu - c} (x - \mu)^2f_X(x)\mathrm dx + \int_{ \mu + c}^\infty (x - \mu)^2f_X(x)\mathrm dx\\ +&\ge \int_{-\infty}^{\mu - c} c^2f_X(x)\mathrm dx + \int_{ \mu + c}^\infty c^2f_X(x)\mathrm dx\\ +&= \int_{|x - \mu| \ge c} c^2f_X(x)\mathrm dx\\ +&=c^2P(|X - \mu| \ge c) +\end{align*} +$$
+ +

The upperbounds of $\sigma^2$:

+
$$ +X \in [a, b]\\ +\sigma^2 \le (b - a)^2/4 +$$
+ +

Chernoff inequality

+

If a RV $X$ has MGF $M_X(s)$, then

+
$$ +P(X \ge a) \le e^{-\max_{s\ge 0}\left(sa - \ln M_X(s)\right)} +$$
+ +

or, for $s \ge 0$

+
$$ +P(X\ge a) \le e^{-sa}M_X(s) +$$
+ +

for $s \lt 0$

+
$$ +P(X \le a) \le e^{-sa}M_X(s) +$$
+ +

proof: for $s \ge 0$

+
$$ +M_X(s) = \int_{-\infty}^a e^{sx}f_X(x)\mathrm dx + \int_a^{\infty} e^{sx}f_X(x)\mathrm dx\\ +\ge 0 + e^{sa}\int_a^{\infty} f_X(x)\mathrm dx = e^{sa}P(X \ge a) +$$
+ +

Weak law of large numbers

Let $X_1, X_2, \dots$ be independent identically distributed (i.i.d.) RVs with finite mean $\mu$ and variance $\sigma^2$

+
$$ +M_n = \frac{X_1 + X_2 + \dotsb + X_n}{n}\\ +E[M_n] = \mu\\ +\text{var}(M_n) = \frac{\sigma^2}{n} +$$
+ +

Applying the Chebyshev inequality and we get:

+
$$ +P(|M_n - \mu| \ge \epsilon) \le \frac{\text{var}(M_n)}{\epsilon^2} = \frac{\sigma^2}{n\epsilon^2} +$$
+ +

For large $n$, the bulk of the distribution of $M_n$ is concentrated near $\mu$

+

Theorem

+

Let $X_1, X_2, \dots$ be independent identically distributed (i.i.d.) RVs with finite mean $\mu$ and variance $\sigma^2$. For every $\epsilon \gt 0$, we have

+
$$ +P(|M_n - \mu| \ge \epsilon) = P\left(\left|\frac{X_1 + \dotsb + X_n}{n} - \mu\right|\ge \epsilon\right) \rightarrow 0, \text{ as } n \rightarrow \infty +$$
+ +

$M_n$ converges in probability to $\mu$.

+

Convergence “in Probability”

Theorem: Convergence in Probability

+

Let $\lbrace Y_n\rbrace$(or $Y_1, Y_2, \dots$) be a sequence of RVs(not necessarily independent), and let $a$ be a real number. We say that the sequence $Y_n$ converges to $a$ in probability, if for every $\epsilon \gt 0$, we have

+
$$ +\lim_{n \rightarrow \infty} P(|Y_n - a| \ge \epsilon) = 0 +$$
+ +

(almost all) of the PMF/PDF of $Y_n$, eventually gets concentrated (arbitrarily) close to $a$.

+

Many types of convergence

Deterministic limits: $\lim_{n\rightarrow \infty} a_n = a$

+
$$ +|a_n - a|\le \epsilon, \forall n \ge N, \epsilon \gt 0 +$$
+ +

Convergence in probability: $X_n\stackrel P{\rightarrow} X$

+
$$ +\lim_{n \rightarrow \infty}P(|X_n - X|\ge \epsilon) = 0, \forall \epsilon \gt 0 +$$
+ +

(WLLN)

+

Convergence in Distribution: $X_n \stackrel{D}{\rightarrow} X$

+
$$ +\lim_{n \rightarrow \infty} P(X_n \le x) = P(X \le x), \forall x +$$
+ +

For all points of $x$ at which the function $F_X(x) = P(X\le x)$is continuous.

+

(CLT)

+

Convergence with probability $1$(almost surely): $X_n \stackrel{\text{a.s.}}{\rightarrow} X$

+
$$ +P\left(\lbrace\omega\in \Omega: \lim_{n\rightarrow\infty}X_n(\omega) =X(\omega)\rbrace\right) = 1 +$$
+ +

or

+
$$ +P\left(\lim_{n\rightarrow\infty}X_n(\omega) =X(\omega)\right) = 1 +$$
+ +

Lemma:

+
$$ +X_n \stackrel{\text{a.s.}}{\rightarrow} X \Leftrightarrow \lim_{m \rightarrow\infty}P(|X_n - X|\le \epsilon, \forall n \gt m) = 1, \forall \epsilon \gt 0\\ +\Leftrightarrow P(|X_n - X|\gt \epsilon, \text{i.o.}) = 0, \forall \epsilon \gt 0 +$$
+ +

i.o. stand for infinitely often

+

(SLLN)

+

Convergence in Mean/in Norm: $X_n \stackrel{r}{\rightarrow}X$

+

if $E[X_n^r] \lt \infty$ for all $n$ and

+
$$ +\lim_{n \rightarrow \infty}E[|X_n - X|^r] = 0 +$$
+ +

Relations:

+
$$ +\left(X_n\stackrel {\text{a.s.}}{\rightarrow} X\right) \Rightarrow\left(X_n\stackrel P{\rightarrow} X\right) \Rightarrow \left(X_n\stackrel D{\rightarrow} X\right) \\ +\left(X_n\stackrel {r}{\rightarrow} X\right) \Rightarrow\left(X_n\stackrel P{\rightarrow} X\right) \Rightarrow \left(X_n\stackrel D{\rightarrow} X\right) \\ +\forall r\ge s\ge 1, \left(X_n\stackrel {r}{\rightarrow} X\right) \Rightarrow\left(X_n\stackrel s{\rightarrow} X\right) +$$
+ +

The converse assertions fail in general!

+

The relation between “almost surely” and “in r-th mean” is complicated. There exist sequences which converge almost surely but
not in mean, and which converge in mean but not almost surely!

+

Central Limit Theorem

Theorem

Let $X_1, X_2, \dots$ be i.i.d. RVs with mean $\mu$ and variance $\sigma^2$. Let

+
$$ +Z_n = \frac{X_1 + X_2 + \dotsb + X_n - n\mu}{\sigma\sqrt{n}} +$$
+ +

Then

+
$$ +\lim_{n\rightarrow \infty}P(Z_n\le z) = \Phi (z) = \frac{1}{\sqrt{2\pi}}\int_{-\infty}^z e^{-\frac{x^2}{2}}\mathrm dx +$$
+ +

CDF of $Z_n$ converges to normal CDF(converge in distribution)

+

Normal Approximation Based on the Central Limit Theorem

Let $S_n = X_1 + \dotsb + X_n$, where $X_i$ are $\text{i.i.d.}$ RVs with mean $\mu$ and variance $\sigma^2$. If $n$ is large, the probability $P(S_n ≤ c)$ can be approximated by
treating $S_n$ as if it were normal, according to the following procedure.

+
    +
  1. Calculate the mean $n\mu$ and the variance $n\sigma^2$ of $S_n$
  2. +
  3. Calculate the normalinzd value $z = (c - n\mu)/(\sigma\sqrt{n})$
  4. +
  5. Use the approxmation
  6. +
+
$$ + P(S_n \le c) \approx \Phi(z) +$$
+ +

where $\Phi(z)$ is available from the standard normal CDF.

+

Proof

Suppose that $X_1, X_2, \dots$ has mean zero.

+
$$ +\begin{align*} +M_{Z_n}(s) &= E[e^{sZ_n}]\\ +&=E\left[\exp\left(\frac{s}{\sigma\sqrt{n}}\sum_{i = 1}^n X_i\right)\right]\\ +&=\prod_{i = 1}^n E[e^{\frac{s}{\sigma\sqrt{n}}X_i}]\\ +&=\prod_{i = 1}^n M_{X_i}\left(\frac{s}{\sigma\sqrt{n}}\right)\\ +&=\left(M_{X}\left(\frac{s}{\sigma\sqrt{n}}\right)\right)^n\\ +\end{align*} +$$
+ +

Suppose that the transform $M_X(s)$ has a second order Taylor series expansion around $s=0$,

+
$$ +M_X(s) = a + bs + cs^2 + o(s^2) +$$
+ +

where $a = M_X(0) = 1, b = M_X’(0) = E[X] = 0, c = \frac{1}{2}M_X’’(0) = \frac{\sigma^2}{2}$

+

Then

+
$$ +M_{Z_n}(s) = \left(1 + \frac{s^2}{2n} + o\left(\frac{s^2}{n}\right)\right)^n +$$
+ +

As $n\rightarrow \infty$,

+
$$ +\lim_{n\rightarrow \infty}M_{Z_n}(s) = \lim_{n\rightarrow \infty}\left(1 + \frac{s^2}{2n} + o\left(\frac{s^2}{n}\right)\right)^n = e^{\frac{s^2}{2}} +$$
+ +

Approxmation on binomial:

+

(De Moivre-Laplace Approxmation to the Binomial)

+
$$ +P(k \le S_n \le l) = P\left(\frac{k - np}{\sqrt{np(1-p)}} \le \frac{S_n - np}{\sqrt{np(1 - p)}} \le \frac{l - np}{\sqrt{np(1 - p)}}\right)\\ +\approx \Phi\left(\frac{l - np}{\sqrt{np(1 - p)}}\right) - \Phi\left(\frac{k - np}{\sqrt{np(1 - p)}}\right) +$$
+ +

The Strong Law of Large Numbers

Theorem

Let $X_1, X_2, \dots$ be i.i.d. RVs with mean $\mu$.

+
$$ +P(\lim_{n \rightarrow\infty}\frac{X_1 + \dots + X_n}{n} = \mu) = 1. +$$
+ +

Borel-Cantelli lemma & Bernoulli Process

Limit of set sequence

$$ +\limsup_n A_n = \bigcap_{n = 1}^\infty \bigcup_{k = n}^\infty A_k\\ +\liminf_n A_n = \bigcup_{n = 1}^\infty \bigcap_{k = n}^\infty A_k +$$
+ +

If upper limit equals to lower limit, the limit of set sequence exists.

+
$$ +\limsup_n A_n \supseteq \liminf_n A_n\\ +\limsup_n A_n = \liminf_n A_n = \lim_n A_n +$$
+ +

Upper limit can also be denoted as

+
$$ +\limsup_n A_n = \{\omega: \omega \in A_n, \text{i.o.}\} = \lbrace A_n, \text{i.o.}\rbrace +$$
+ +

Borel-Cantelli Lemma

Let $\lbrace A_n, n = 1, 2, \dotsb\rbrace$ be a sequence of events, then

+
$$ +\sum_{n = 1}^\infty P(A_n)\lt \infty \xRightarrow{} P(A_n, \text{i.o.}) = 0 +$$
+ +

Let $\lbrace A_n, n = 1, 2, \dotsb\rbrace$ be a sequence of independent events, then

+
$$ +\sum_{n = 1}^\infty P(A_n) = \infty \xRightarrow{} P(A_n, \text{i.o.}) = 1 +$$
+ +

Stochastic process

A stochastic process is a mathematical model of a probabilistic experiment that evolves in time and generates a sequence of
numerical values.

+
    +
  • Bernoulli process(memoryless, discrete time)
  • +
  • Poisson process(memoryless, continuous time)
  • +
+

The Bernoulli Process

is a sequence of independent Bernoulli trials, each with probability of success $p$.

+
$$ +P(\text{success}) = P(X_i = 1) = p\\ +P(\text{failure}) = P(X_i = 0) = 1 - p +$$
+ +

Independence property: For any given time $n$, the sequence of $X_{n + 1}, X_{n + 2}, \dots$ is also a Bernoulli process, and is independent from $X_1, \dots, X_n$

+

Memoryless property: Let $n$ be a given time and let $\overline T$ be the time of the first success after
time $n$. Then $\overline T − n$ has a geometric distribution with parameter $p$,
and is independent of the RVs $X_1, \dots , X_n$.

+
$$ +P(\overline T - n = t | \overline T \gt n) = (1 - p)^{t - 1}p = P(T = t) +$$
+ +

Interarrival times

+

Denote the $k$th success as $Y_k$, the $k$th interarrival time as $T_k$.

+
$$ +T_1 = Y_1, T_k = Y_k - Y_{k - 1}, k = 2, 3, \dots +$$
+ +

represents the number of trials following the $(k - 1)$th success until the next success.

+

Note that

+
$$ +Y_k = T_1 + T_2 + \dotsb + T_k +$$
+ +

Alternative description of the Bernoulli process:

+
    +
  • Start with a sequence of independent geometric RVs $T_1, T_2, \dots$ with common parameter p, and let these stand for the interarrival times.
  • +
  • Record a success at times $T_1$, $T_1 + T_2$, etc.
  • +
+
$$ +E[Y_k] = \frac{k}{p}\\ +\text{var}(Y_k) = \frac{k(1 - p)}{p^2} +$$
+ +
$$ +p_{Y_k}(t) = \binom{t - 1}{k - 1}p^k(1 - p)^{t - k} +$$
+ +

Splitting of a Bernoulli process

+

Whenever there is an arrival, we choose to either keep it (with probability $q$), or to discard it (with probability $1 − q$).

+

Both the process of arrivals that are kept and the process of discarded arrivals are Bernoulli processes, with success probability $pq$ and $p(1 − q)$, respectively, at each time.

+

Merging of a Bernoulli process

+

In a reverse situation, we start with two independent Bernoulli processes (with parameters $p$ and $q$ respectively). An arrival is
recorded in the merged process if and only if there is an arrival in at least one of the two original processes.

+

The merged process is Bernoulli, with success probability $p+q−pq$ at each time step.

+

The Poisson Process

Definition

An arrival process is called a Poisson process with rate $λ$ if it has the following properties:

+

Time homogenity

+
$$ +P(k, \tau) = P(k \text{ arrivals in interval of duration }\tau) +$$
+ +

Independence

+

Numbers of arrivals in disjoint time intervals are independent.

+

Small interval probabilities

+
$$ +\begin{cases} + 1 - \lambda\tau + o(\tau), & \text{if } k = 0,\\ + \lambda\tau + o_1(\tau), & \text{if } k = 1,\\ + o_k(\tau), & \text{if } k > 1. +\end{cases} +$$
+ +

Bernoulli/Poisson Relation

In a short time interval $\delta$

+
$$ +n = t / \delta\\ +p = \lambda\delta\\ +np = \lambda t +$$
+ +

For binomial PMF $p_S(k;n,p)$,

+
$$ +\lim_{n\rightarrow \infty}p_S(k;n, p) = \lim_{n\rightarrow\infty}\frac{n!}{(n - k)!k!}p^k(1 - p)^{n - k} = \frac{(\lambda t)^k}{k!}e^{-\lambda t} = P(k, t) +$$
+ +

PMF of Number of Arrivals $N$

$$ +P(k, \tau) = \frac{(\lambda\tau)^ke^{-\lambda\tau}}{k!} +$$
+ +
$$ +E[N_t] = \lambda t\\ +\text{var}(N_t) = \lambda t +$$
+ +

Time $T$ of the first arrival

$$ +F_T(t) = P(T \le t) = 1 - P(T \gt t) = 1 - e^{-\lambda t}, t\ge 0\\ +f_T(t) = \lambda e^{-\lambda t}, t\ge 0 +$$
+ +

Memoryless property The time to next arrival is independent of the past.

+

Interarrival times

We also denote the time of the kth success as $Y_k$, and denote the
kth interarrival time as $T_k$. That is,

+
$$ +T_1 = Y_1, T_k = Y_k - Y_{k - 1}, k = 2, 3, \dots +$$
+ +

Note that

+
$$ +Y_k = T_1 + T_2 + \dotsb + T_k +$$
+ +
$$ +f_{Y_k}(y) = \frac{\lambda^ky^{k-1}e^{-\lambda y}}{(k - 1)!}, y\ge 0 +$$
+ +

Merging Poisson Processes

+
$$ +P(\text{Arrival is red} | \text{1 arrival})\approx \frac{\lambda_1\delta}{(\lambda_1 + \lambda_2) \delta} +$$
+ +

+
\ No newline at end of file diff --git a/2023/02/22/Signal-and-Systems/index.html b/2023/02/22/Signal-and-Systems/index.html new file mode 100644 index 00000000..8d8aeae3 --- /dev/null +++ b/2023/02/22/Signal-and-Systems/index.html @@ -0,0 +1,2187 @@ +Signals and Systems | Guo_Yun + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Signals and Systems

March 15

+

Basic

Classification

Deterministic & random

+

Periodic/non-periodic

+

Continuous/Discrete(time)

+

Analog/Digital(Amplitude & time)

+

Operations

Shifting

+

Reflection

+

Scaling

+

Diffrential

+

Integral

+

Addition

+

Multiplication

+

Convolution

+
$$ +f_1(t) * f_2(t) = \int_{-\infty}^{\infty}f_1(\tau)f_2(t-\tau)\mathrm d\tau +$$
+ +

Singularity Signals

Unit ramp function

$$ +R(t) = 0, t\lt 0; t, t>0 +$$
+ +

Unit step function

$$ +u(t) = 0, t<0;1/2, t=0;1, t>0 +$$
+ +

Rectangular pulse

$$ +u(t) - u(t-t_0) +$$
+ +

Sign function

$$ +sgn(t) = 1, t>0;-1, t<0 +$$
+define $sgn(0)=0$, then $sgn(t)=2u(t)-1$ + +

Unit impulse function

Dirac definition

+
$$ +\int_{-\infty}^{\infty}\delta(t)\mathrm dt=1\\ +\delta(t)=0(t\ne 0) +$$
+
$$ +\delta(t)=\lim_{\tau \rightarrow0}\left[U(t+\frac\tau2)-U(t-\frac \tau 2)\right] +$$
+ +
$$ +\int_{-\infty}^{\infty}\delta(t)f(t)=f(0)\\ +\int_{-\infty}^{\infty}\delta(t - t_0)f(t)=f(t_0)\\ +\delta(t)=\delta(-t)\\ +\frac{d}{dt}u(t)=\delta(t) +$$
+ +

Impulse doublet function

$\delta^\prime(t)$
Double impulses at t=0 which are mirror-imaged with their amplitude of infinite.

+
$$ +\int^{\infty}_{-\infty}\delta^\prime(t)\mathrm dt=0\\ +\int^{\infty}_{-\infty}f(t)\delta^\prime(t)\mathrm dt=-f^{\prime}(0)\\ +\text{shifted:}\int^{\infty}_{-\infty}f(t)\delta^\prime(t-t_0)\mathrm dt=-f^{\prime}(t_0)\\ +$$
+![](../images/ss/lec2_.jpg) + +

Signal Decomposition

$$ +f(t) = f_D+f_A(t)\\ +f(t)=f_e(t)+f_o(t)\\ +f(t)=f_r(t)+jf_i(t)\\ +f_r(t)=\frac{1}{2}\left[f(t)+f^*(t)\right]\\ +f_i(t)=\frac{1}{2}\left[f(t)-f^*(t)\right] +$$
+ +

Pulse Component

$$ +f(t)=\int_{-\infty}^{\infty}f(t_1)\delta(t-t_1)\mathrm dt_1 +$$
+ +

We also have orthogonal function decomposition(Chap.3, Chap.6).

+

System modeling and Classification

System model can be represented by math equation(including input-output description and state variables or state equation) graphic symbol and block diagrams.

+

We use the input-output description mostly. If controling something internal is needed, state euqtion is useful.

+

Block diagram:

+


+

System classification

Linear or Non-linear

$$ +e_1(t)\rightarrow r_1(t), +e_2(t)\rightarrow r_2(t)\Rightarrow\\ +a_1e_1(t)+a_2e_2(t)\rightarrow a_1r_1(t)+a_2r_2(t) +$$
+ +

Time-variant or Time-invariant

Memory or Memoryless

with memory: dynamic system, differential equation

+

without memory: instant system, algebraic equation

+

Continuous or Discrete

Continuous Differential equation

+

Discrete Difference equation

+

Lumped- or Distributed-Parameter

Lumped: constant coefficient differential equation

+

Distributed: partial equation

+

Causal or Non-Causal

when $t<0, e(t)=0 \Rightarrow t<0, r(t)=0$ Generic definition?

+

the future state cannot have effect on now state. The state of causal system can only be determined by now and past states.

+

Reversible or irreversible

different input to different output, otherwise irreversible.

+

LTI System

Linearity

Linearity leads to superposition and homogeneity.

+

Time-Invariant

a time shift in the input results in a same time shift in the output.

+
$$ +e(t)\rightarrow r(t)\Rightarrow e(t-t_0)\rightarrow r(t-t_0)\\ +\lim_{\Delta t\rightarrow 0}\frac{e(t)-e(t-\Delta t)}{\Delta t}\rightarrow \lim_{\Delta t\rightarrow 0}\frac{r(t)-r(t-\Delta t)}{\Delta t}\\ +\frac{\mathrm de(t)}{dt}\rightarrow \frac{\mathrm dr(t)}{dt} +$$
+ +

If every coefficient is time independent, the system is time invariant.

+

Time-Domain(TD) Analysis

$$ +C_0\frac{d^nr(t)}{dt^n}+C_1\frac{d^{n-1}r(t)}{dt^{n-1}} + ... + C_nr(t)\\ +=E_0\frac{d^me(t)}{dt^m}+E_1\frac{d^{m-1}e(t)}{dt^{m-1}}+...+E_me(t) +$$
+ +

Three Steps

+
    +
  • Homogeneous
  • +
  • Particular
  • +
  • Calculation on coefficients
  • +
+

Determining Coefficients

If functions are continuous, we can get their boundary conditions by determining the derivatives.

+

Then the coefficients can be solved by multipling the inverse of Vandermonde matrix with the boundary condition matrix.

+

Zero-input and -state Responses

Zero-input response The response caused by the initial state (i.e., energy originally stored in the system), and it is denoted by $r_{zi}(t)$

+

Zero-state response $r(0_-)\equiv 0$, the response caused only by the external excitation and it is denoted by $r_{zs}(t)$

+

+

+

The combination of zero-input response and the zero-state response is not necessarily linear, since the existence of constant. If one of them vanishes, the other is linear.

+

Impulse and Step Responses

Impulse Response the zero-state response $h(t)$ to $\delta (t)$, which can be equalized to the initial condition.

+

Note: normally $n>m$.

+

Unit Step Response The zero-state response $g(t)$ to $u(t)$

+

There might be a forced term in $g(t)$.

+
$$ +g(t) = \int_0^th(\tau)d\tau +$$
+ +

Convolution

Zero-state required

+
$$ +e(t) = \int_{-\infty}^{\infty}e(\tau)\delta(t-\tau)\mathrm d\tau\\ +\Rightarrow r(t)=\int_{-\infty}^{\infty}e(\tau)h(t-\tau)\mathrm d\tau\\ +\Rightarrow r(t)=e(t)*h(t) +$$
+ +

the definition of convoluiton:

+
$$ +f_1(t)*f_2(t)=\int_{-\infty}^{\infty}f_1(\tau)f_2(t-\tau)\mathrm d\tau +$$
+ +

Integral interval $e(t)=0, \forall t<0$, $h(t)=0,\forall t<0$, so $r(t)=\int_0^t{e(\tau)h(t-\tau)\mathrm d\tau}$

+

The condition for applying convolution:

+
    +
  • For linear system ONLY
  • +
  • For time variant systems, $h(t, \tau)$ means response at time $t$ generated by the impulse at time $\tau$, then $r(t)=\int_0^th(t,\tau)e(\tau)\mathrm d \tau$; for time-invariant system is a special case, $h(t,\tau)=h(t-\tau)$.
  • +
+

The Properties of Convolution The commutative property, the distributive property, the associative property

+

Differential:

+
$$ +(f_1(t)*f_2(t))^\prime=f_1^\prime(t)*f_2(t) +$$
+ +

Integral

+
$$ +\int f_1(t)*f_2(t)=f_1(t) * \int f_2(t) +$$
+ +
$$ +(f_1(t) * f_2(t))^{(i)}=f_1^{(j)}(t) * f_2^{(i-j)}(t) +$$
+ +

Convolution with $\delta (t)$ or $u(t)$

+

(1) $f(t) * \delta(t) = f(t)$

+

(2) $f(t) * \delta(t - t_0) = f(t-t_0)$

+

(3) $f(t) * u(t) = \int_{\infty}^{t}f(\tau)\mathrm d\tau$

+

(4) $f(t) * \delta^\prime(t) = f^\prime(t)$

+

Fourier Transform

Fourier Series

requirements:

+
    +
  • has finite number of discontinuities
  • +
  • has finite number of maxima and minima
  • +
  • $\int_{t_0}^{t_0+T_1} |f(t)|\mathrm dt < \infty$
  • +
+
$$ +\begin{align*} +f(t)&=a_0+\sum_{n=1}^\infty \left[a_n\cos(n\omega_1)t + b_n\sin(n\omega_1t)\right]\\ +&=c_0 + \sum_{n=1}^\infty c_n\cos \left(n\omega_1t+\varphi_n \right)\\ +&=\sum_{n=-\infty}^{\infty}F_ne^{jn\omega_1 t} +\end{align*} +$$
+ +
$$ +\begin{align*} + a_0&=\frac{1}{T_1}\int_{t_0}^{t_0+T_1}f(t)\mathrm dt=c_0\\ + a_n&=\frac{2}{T_1}\int_{t_0}^{t_0+T_1}f(t)\cos(n\omega_1t)\mathrm dt\\ + b_n&=\frac{2}{T_1}\int_{t_0}^{t_0+T_1}f(t)\sin(n\omega_1t)\mathrm dt\\ + c_n&=\sqrt{a_n^2+b_n^2}\\ + \varphi_n&=-\tg^{-1}\frac{b_n}{a_n}\\ + F_n&=\frac 1{T_1}\int_{t_0}^{t_0+T_1}f(t)e^{-jn\omega_1t}\mathrm dt\\ + &=\frac 12e^{j\varphi_n}\\ + &=\frac 12(a_n-jb_n) +\end{align*} +$$
+ +

note When $b_n=0$, $\varphi_n = a_n > 0\ ?\ 0:\pi$

+

In the last part, the negative frequency is introduced for the convenience of the signal analysis. Therefore the amplitude is reduced to half.

+

FS for special functions

+
    +
  1. Even function $c_n=a_n, \varphi_n = 0, F_n=F_{-n}=\frac 12 a_n$
  2. +
  3. Odd function $a_0=0, a_n=0, \varphi_n=-\frac{\pi}{2}, F_n=F_{-n}=-\frac{1}{2}jb_n$
  4. +
  5. Half-wave Odd (odd harmonic) function, $f(t)=-f\left(t\pm \frac{T_1}2{}\right)$, contains only odd harmonics(both sine and cosine)
  6. +
  7. Finite term series
  8. +
+

FS for typical periodic signals

Periodic square wave

+
$$ +f(t)=\frac{E\tau}{T_1}+\sum_{n=1}^{\infty}\frac{2E\tau}{T_1}\text{Sa}(\frac{n\omega_1\tau}{2}) +$$
+ +
    +
  1. Spectrum is discrete with frequency spacing $\omega_1 = \frac{2\pi}{T_1}$. When $T_1 \rightarrow \infty$, the spectrum will be continuous.
  2. +
  3. Amplitude: $\text{Sa}\left(\frac{n\pi\tau}{T_1}\right)$ or $\text{Sa} \left(\frac{n\omega_1\tau}{2}\right)$, cross zero when $\omega_1 = \frac{2m\pi}{\tau}$
  4. +
  5. Non-zero FS coefficients of a aperiodic signal are infinite with most energy concentrated at low frequency components (within $\left(-\frac{2\pi}{\tau},\frac{2\pi}{\tau}\right)$). Thus we define the bandwith $B_{\omega} = \frac{2\pi}{\tau}$
  6. +
+

Periodic symmetric square wave

+

Since the spectrum crosses zero when $\omega_1 = \frac{2m\pi}{\tau}$, the even harmonic vanishes. Also the sine component vanishes.

+
$$ +c_n = \frac{2E\tau}{T_1}\left|\text{Sa}\left(\frac{n\omega_1\tau}{2}\right)\right|\\ +f(t) = \frac{2E}{\pi}\left[\cos(\omega_1t) - \frac{1}3\cos(3\omega_1t) + \frac{1}{5}\cos(5\omega_1t)-...\right] +$$
+ +

Periodic Serrated Pulse

+
$$ +f(t) = \sum_{n = 1}^\infty \frac{E}{n\pi}(-1)^{n+1}\sin (n\omega_1t) +$$
+ +

Periodic Triangular Pulse

+
$$ +f(t)=\frac E2 + \frac{4E}{\pi^2}\sum_{n=1}^\infty\frac{1}{n^2}\sin^2\left(\frac{n\pi}{2}\right)\cos(n\omega_1t)\\=\frac E2 + \frac{4E}{\pi^2}\sum_{n=1}^\infty\frac{1}{(2n-1)^2}\cos((2n-1)\omega_1t) +$$
+ +

consine of non-negative values

+
$$ +f(t) = \frac E\pi - \frac{2E}{\pi}\sum_{n=1}^\infty\frac{1}{n^2-1}\cos(\frac {n\pi}2)\cos(n\omega_1t) +$$
+ +

cosine of absoulute values

+
$$ +f(t) = \frac{2E}{\pi} + \frac{4E}{\pi}\sum_{n=1}^\infty (-1)^{n+1}\frac{1}{4n^2-1}\cos(2n\omega_0t) +$$
+ +

其中$\omega_0$ = $2\omega_1$

+

Fourier Transform

The case where $T_1\rightarrow \infty$. Signal becomes aperiodic.

+

Also, $\omega_1\rightarrow 0$ results in the continuous frequency axis. For square wave the magnitude $\frac{E\tau}{T_1}\rightarrow 0$.

+
$$ +f(t) =\sum_{n=-\infty}^{\infty}F(n\omega_1)e^{jn\omega_1 t}\\ +F(n\omega_1) = \frac 1T_1\int_{-\frac {T_1}2}^{\frac {T_1}2}f(t)e^{-jn\omega_1t}\mathrm dt +$$
+ +

We use spectrum density to replace spectrum, making the magnitude dropping to zero remain its meaning.

+
$$ +\frac{F(n\omega_1)}{\omega_1} = \frac{1}{2\pi}\int_{-\frac {T_1}2}^{\frac {T_1}2}f(t)e^{-jn\omega_1t}\mathrm dt\\ +F(\omega) = \lim_{\omega_1\rightarrow 0}\frac{2\pi F(n\omega_1)}{\omega_1}=\lim_{T_1\rightarrow \infty}\int_{-\frac {T_1}2}^{\frac {T_1}2}f(t)e^{-jn\omega_1t}\mathrm d t=\int_{-\infty}^\infty f(t)e^{-j\omega t}\mathrm d t\\ +f(t) = \sum_{n=-\infty}^{\infty}F(n\omega_1)\cdot \frac{1}{\omega_1}e^{jn\omega_1 t} \Delta(n\omega_1) = \frac{1}{2\pi}\int_{-\infty}^\infty F(\omega)e^{j\omega t}\mathrm d\omega +$$
+ +
$$ +F(\omega) = |F(\omega)|e^{j\varphi(\omega)} +$$
+ +

The fourier transfrom is continuous waveform, where every frequency has no energy but energy density, used to analyse aperiodic function.

+

Sufficient condition, but not necessary.

+
$$ +\int_{-\infty}^\infty |f(t)|\mathrm dt<\infty +$$
+ +

FT for typical aperiodic signals

Rectangular pulses

+
$$ +F(\omega) = \int_{-\tau/2}^{\tau/2} Ee^{-j\omega t}\mathrm dt = E\tau \text{Sa}\left(\frac{\omega \tau}{2}\right) +$$
+ +

Raised Cosine Signal

+
$$ +f(t) = \frac{E}{2}(1+\cos\frac{\pi t}{\tau})(u(t+\tau) - u(t - \tau))\\ +F(\omega) = \int_{-\tau}^{\tau}(1+\cos\frac{\pi t}{\tau})\mathrm dt = \frac{E\tau}{1 - \left(\frac{\omega \tau}{\pi}\right)^2}\text{Sa}({\omega \tau}) +$$
+ +

More compacted than square signal($|F(\omega)|\propto \frac 1{\omega^3}$). An explanation is that the raised cosine has no discontinuities.

+

Generally:

+
    +
  1. $f(t)$ has discontinuities, $|F(\omega)|\propto \frac 1{\omega}$
  2. +
  3. $\frac{d}{dt}f(t)$ has discontinuities, $|F(\omega)|\propto \frac 1{\omega^2}$
  4. +
  5. $\frac{d^2}{dt^2}f(t)$ has discontinuities, $|F(\omega)|\propto \frac 1{\omega^3}$
  6. +
+

The width $\tau$ of the raised cosine signal is defined at $\frac E2$ rather than at the bottom, making it easy to compare with
the rectangular pulse of same width. The first zeros of the
frequency spectrum are identical.

+

raised consine is energy-concentrative and has been widely used in digital communications.

+

Single-sided exponential singal

+
$$ +f(t) = e^{-at}u(t)\\ +F(\omega) = \frac{1}{a+j\omega} +$$
+ +

Two-sided, anti-symmetric exponential signal

+
$$ +f(t) = -e^{at}u(-t) + e^{-at}u(t)\\ +F(\omega) = \frac{-2j\omega}{a^2+\omega^2} +$$
+ +

Sign function

+
$$ +\text{sgn}(t) = u(t) - u(-t)\\ +F(\omega) = \lim_{a\rightarrow 0}\frac{-2j\omega}{a^2+\omega^2}= \frac{2}{j\omega} +$$
+ +

Gaussian singal

+
$$ +f(t) = Ee^{-\left(\frac{t}{\tau}\right)^2}\\ +F(\omega) = \sqrt \pi E\tau e^{-\left(\frac{\omega\tau}{2}\right)^2} +$$
+ +

Sinc Function

+
$$ +f(t) = \frac{E}{\pi}\frac{\sin(\omega_c t)}{t}\\ +F(\omega) = E(u(\omega - \omega_c ) + u(\omega + \omega_c ))\\ +$$
+ + +

FT on impulse and step functions

$$ +\mathcal F[\delta(t)] = 1\\ +\mathcal F[1] = 2\pi \delta(\omega) +$$
+ +

The spectrum of impulse function covers the entire frequency range. The interferences caused by a variety of electric sparks always cover the full frequency range.

+
$$ +\mathcal F[\delta^\prime (t)]= j\omega\\ +\mathcal F[\delta^{(n)}(t)] = (j\omega)^n +$$
+ +
$$ +\mathcal F[u(t)] = \pi \delta(\omega) + \frac{1}{j\omega} +$$
+ +

Due to the DC component in u(t), an impulse exists.

+

Properties of FT

Symmetry $\mathcal F[F(t)]= 2\pi f(-\omega)$ , if $f(t)$ is a even function, $\mathcal F[F(t)]= 2\pi f(\omega)$

+

Linearity $\mathcal{F}[\Sigma_{i=1}^{n}a_if_i(t)] = \Sigma_{i=1}^{n}a_iF_i(\omega)$

+

Odd-Even, Imaginary-Real $f(t) = f_e(t)+f_o(t)$, then

+
$$ +\begin{align*} + F(\omega) &= \int_{-\infty}^\infty f(t)\cos \omega t \mathrm dt -j\int_{-\infty}^\infty f(t)\sin \omega t \mathrm dt\\ + &=R(\omega)+jX(\omega)\\ + &=\int_{-\infty}^\infty f_e(t)\cos \omega t \mathrm dt -j\int_{-\infty}^\infty f_o(t)\sin \omega t \mathrm dt\\ +\end{align*}. +$$
+ +

$R(\omega)$ is an even function of $\omega$, $X(\omega)$ is an odd function of $\omega$.

+

$|F(\omega) = \sqrt{R^2(\omega)+F^2(\omega)}|$ is even function.

+

$\varphi(\omega) = \tg^{-1}\frac{R(\omega)}{X(\omega)}$

+

if $f(t)$ is real and even, then $f(t)=f_e(t), F(\omega)=R(\omega)$, the phase shift is $0$ or $\pi$.

+

if $f(t)$ is real and odd, $f(t) = f_o(t)$, then $F(\omega)=jX(\omega)$, $F(\omega)$ has only imaginary part and is odd, the phase shift is $\pm \frac{\pi}{2}$

+

Scaling $\mathcal{F}[f(at)]=\frac 1{|a|}F\left(\frac{\omega}a\right)$ Expansion in TD results in Compression in FD.

+

Time Shifting $\mathcal{F}[f(t\pm t_0)] = F(\omega)e^{\pm j\omega t_0}$

+

Frequency Shifting $\mathcal F[f(t)e^{\pm j\omega_0t}] = F(\omega\mp\omega_0)$

+

Differentiation property$\mathcal F\left[\frac{\mathrm d}{\mathrm dt}f(t)\right] = j\omega F(\omega)$

+

$\mathcal F\left[\frac{\mathrm d^n}{\mathrm dt^n}f(t)\right] = (j\omega)^n F(\omega)$

+

$\mathcal F\left[\frac{\mathrm d^n}{\mathrm d\omega^n}F(\omega)\right] = (-jt)^nf(t)$

+

Integration Property $\mathcal{F}\left[\int_{-\infty}^t f(\tau)\mathrm{d} \tau\right] = \frac{F(\omega)}{j\omega} + \pi F(0)\delta(\omega)$

+

Convolution theorem

$$ +\mathcal F[f_1(t)* f_2(t)] = F_1(\omega)F_2(\omega)\\ +\mathcal F[f_1(t)\cdot f_2(t)] = \frac 1{2\pi} F_1(\omega) * F_2(\omega) +$$
+ +

FT for Periodic Signals

$$ +\mathcal F[\cos (\omega_0 t)] = \pi [\delta(\omega + \omega_0) + \delta(\omega - \omega_0)]\\ +\mathcal{F} [\sin (\omega_0 t)] = j\pi [\delta(\omega+\omega_0) + \delta(\omega - \omega_0)] +$$
+ +

FT for periodic of $T_1$ & $\omega_1=2\pi/T_1$

+
$$ +\mathcal F[f(t)] = 2\pi\sum_{n=-\infty}^{+\infty} F_n\delta(\omega - n\omega_1)\\ +F_n = \frac 1{T_1}\int_{-T_1/2}^{T_1/2}f(t)e^{-jn\omega_1 t}\mathrm dt = \frac{1}{T_1}F_0(\omega)\vert_{\omega =n\omega_1} +$$
+ +

Where $F_0(\omega)$ is the FT considering waveform of $f(t)$ only in $|t|\le T_1/2$.

+

example:

+
$$ +f(t) = \sum_{n=0}^{\infty}\delta(t-nT_1), F_n=\frac{1}{T_1}\\ +F(\omega) = \frac{2\pi}{T_1}\sum_{n=0}^{\infty}\delta(\omega - n\omega_1)=\omega_1\sum_{n=0}^{\infty}\delta(\omega - n\omega_1) +$$
+ +
$$ +F_0(ω) \text{ determines the profile of } F(ω)\\ +T_1\text{ determines the density of the impulses +}\\ +T_1↑, ω_1↓\text{, intensity of harmonics}↓\\ +T_1↓,ω_1↑\text{, intensity of harmonics}↑\\ +$$
+ +

+

In the same way:

+

+

FT for periodically sampled signals

$$ +F(\omega) = \mathcal F[f(t)]\\ +P(\omega) = \mathcal F[p(t)]\\ +f_s(t) = f(t)p(t)\\ +F_s(\omega) =\frac{1}{2\pi} F(\omega) * P(\omega) +$$
+ +

Then,

+
$$ +P(\omega) = 2\pi \sum_{n = -\infty}^{+\infty} P_n\delta(\omega - \omega_s)\\ +F(\omega) * P(\omega) = 2\pi \sum_{n = -\infty}^{+\infty} P_nF(\omega - n\omega_s)\\ +F_s(\omega) = \sum_{n = -\infty}^{+\infty} P_nF(\omega - n\omega_s) +$$
+ +

+

For the frequency-domain sampling:

+
$$ +F_1(\omega) = F(\omega)P(\omega)\\ +P(\omega) = \sum_{n=-\infty}^{+\infty} \delta(\omega - n\omega_1)\\ +f_1(t) = f(t) * \frac{1}{\omega_1}\sum_{n=-\infty}^{+\infty} \delta(t - nT_1) = \frac{1}{\omega_1}\sum_{n=-\infty}^{\infty} f(t-nT_1) +$$
+ +

The Sampling Theorem

+
$$ +\omega_s \ge 2\omega_m +$$
+ +

A band-limited signal whose spectrum is strictly within $[0, f_m]$ could be uniquely determined by the samples on itself, if and only if the sampling interval $T_s \le 1/(2f_m)$.

+

$T_s = \frac{1}{2f_m}$ is called the Nyquist interval.

+

$2f_m$ is called the Nyquist frequency.

+

对于单频信号,奈奎斯特频率的采样可能会出现问题。例如正弦信号,每次采样都采在零点上,那就没法复现信号。单频信号没法描述带宽。

+

A FD verison:

+

+

L Transform

Unilateral L-transform

$$ +F(s) = \int^{\infty}_{0}f(t)e^{-st}\mathrm dt, s=\sigma+j\omega\\ +f(t)=\frac{1}{2\pi j}\int_{\sigma-j\infty}^{\sigma+j\infty}F(s)e^{st}\mathrm ds +$$
+ +

$F(s) = \mathcal{L}[f(t)]$ is called image function, $f(t) = \mathcal{L}^{-1}[F(s)]$ is called primitive function.

+

assuming that $f(t)$ is causal and always 0 if $t<0$.

+
$$ +\mathcal L \left[\frac{\mathrm df(t)}{\mathrm dt}\right] = -f(0) + sF(s) +$$
+ +

The initial state is automatically included in differential equation.

+

We define the unilateral L-Transform as:

+
$$ +F(s) = \int_{0_-}^{\infty}f(t)e^{-st}\mathrm dt\\ +\mathcal L \left[\frac{\mathrm df(t)}{\mathrm dt}\right] = -f(0_-) + sF(s) +$$
+ +

Conditions for L-Transform:

+
    +
  1. Limited discontinuities
  2. +
  3. Exponential order
  4. +
+

The strong attenuation factor can make the function convergent.

+

Region of Convergence (ROC)

+

Axis of convergence

+

Coordinate of convergence $\sigma_0$

+

Comman LT Pairs

$$ +\begin{align*} +f(t)&\Rightarrow F(s)\\ +\delta(t) &\Rightarrow 1\\ +u(t) &\Rightarrow \frac 1s\\ +e^{-at} &\Rightarrow \frac{1}{s+a}\\ +t^n & \Rightarrow \frac{n!}{s^{n+1}}\\ +\sin (\omega t)&\Rightarrow \frac{\omega}{s^2 + \omega^2}\\ +\cos (\omega t)&\Rightarrow \frac{s}{s^2+\omega^2}\\ +\end{align*} +$$
+ +

Properties of LT

Linarity

+
$$ +\mathcal L [k_1f_1(t) + k_2f_2(t)] = k_1F_1(s) + k_2F_2(s)\\ +$$
+ +

Differentiation

+
$$ +\mathcal L \left[\frac{\mathrm d f(t)}{\mathrm d t}\right] = sF(s) - f(0_-) +$$
+ +

Intergration

+
$$ +\mathcal L\left[\int_{-\infty}^t f(\tau)\mathcal d\tau\right]=\frac{F(s)}{s} + \frac{f^{(-1)}(0)}{s} +$$
+ +

Time Shifting

+
$$ +\mathcal L\left[f(t-t_0)u(t-t_0)\right] = e^{-st_0}F(s) +$$
+ +

Use $u(t-t_0)$ to avoid nagative part of $f(t)$ emerges.

+

Frequency Shifting

+
$$ +\mathcal L[f(t)e^{-at}] = F(s+a) +$$
+ +

Scaling

+
$$ +\mathcal L[f(at)] = \frac 1a F\left(\frac{s}{a}\right) +$$
+ +

s-Domain Differentiation

+
$$ +\frac{\mathrm d}{\mathrm ds}\mathcal L[f(t)] = \mathcal L[-tf(t)] +$$
+ +

s-Domain Differentiation

+
$$ +\int_s^\infty F(s) = \mathcal{L}\left[\frac{f(t)}{t}\right] +$$
+ +

Initial value

+
$$ +f(0_+) = \lim_{s\rightarrow\infty}sF(s) +$$
+ +

Final value

+
$$ +\lim_{t\rightarrow\infty} f(t) = \lim_{s\rightarrow0} sF(s) +$$
+ +

Generalized limit: $\lim_{t\rightarrow\infty} \sin(\omega t)=0$

+

Convolution

+
$$ +\mathcal L[f_1(t)*f_2(t)] = F_1(s)F_2(s) +$$
+ +

Applications

Differential Equations

+
$$ + F(s) = \frac{A(s)}{B(s)} = \frac{a_ns^n + a_{n-1}s^{n-1} + \cdots + a_1s + a_0}{b_ms^m + b_{m-1}s^{m-1} + \cdots + b_1s + b_0} % The division of two polynomials +$$
+ +

(assume that $n<m$)

+

The roots of numerator is called zeros, while the roots of denominator is called poles.

+

Unknown function F(s) can be represented by the ratio of two polynomials if all initial states are 0.

+
    +
  1. real poles
  2. +
+
$$ +F(s) = \frac{A(s)}{(s-p_1)(s-p_2)(s-p_3)} +$$
+ +
    +
  1. complex conjugate poles
  2. +
+
$$ +F(s) = \frac{A(s)}{D(s)[(s+\alpha)^2 + \beta^2]} = \frac{F_1(s)}{[(s+\alpha)^2 + \beta^2]} = \frac{F_1(s)}{(s+\alpha - j\beta)(s+\alpha + j\beta)} + \dots +$$
+ +
$$ +k_1 = (s+\alpha - j\beta)F(s)|_{s = -\alpha + j\beta} = \frac {F_1(-\alpha + j\beta)}{2j\beta}\\ +k_2 = (s+\alpha + j\beta)F(s)|_{s = -\alpha - j\beta} = \frac {F_1(-\alpha - j\beta)}{-2j\beta} +$$
+ +
    +
  1. Multiple poles
  2. +
+
$$ +F(s) = \frac {A(s)}{B(s)} = \frac{A(s)}{(s-p_1)^k D(s)}\\ += \frac{K_{11}}{(s-p_1)^k}+\frac{K_{12}}{(s-p_1)^{k-1}}+\dotsb+\frac{K_{1k}}{s-p_1} + \frac{E(s)}{D(s)}(s-p_1)^k +$$
+ +

+

+

Circuit model:

+

+

+

+

Use initial value and final value to verify it.

+

System Function

$$ +\begin{cases} + R(s) = H(s) \cdot E(s)\\ + r(t) = h(t) * e(t) +\end{cases} +\Rightarrow H(s) = L[h(t)] +$$
+ +

Driving point function & transfer function

+

+

L-transform can be used in the following analysis:

+
    +
  • TD characteristics (response decomposition)
  • +
  • FD characteristics (steady-state with sine signal input,applications such as filtering)
  • +
  • Stability (active network, feedback, oscillator, control system)
  • +
+

TD characteristics by 0-point distribution

Three cases:

+
    +
  • Real poles
  • +
  • Complex conjugate poles
  • +
  • Real pole of high-order
  • +
+
    +
  1. Zero pole of H(s)
  2. +
+

+

+

Zero only affects the phase and amplitude, while the shape and type of waveform is determined by the poles.

+
    +
  1. pole distribution $\Leftrightarrow$ corresponding natural/forced responses
  2. +
+
$$ +H(s) = \frac{\prod_{i = 1}^m(s-z_{hj})}{\prod_{i = 1}^n(s-p_{hi})}\\ +E(s) = \frac{\prod_{i = 1}^u(s-z_{el})}{\prod_{i = 1}^v(s-p_{ek})}\\ +\text{if } m + u < n + v\\ +R(s) = E(s)H(s) = \sum_{k=1}^n\frac{K_{hk}}{s - p_{hk}} + \sum_{k=1}^v\frac{K_{ek}}{s-p_{ek}} +$$
+ +

The natural response of $r(t)$ is only related to $p_{hk}$, while the forced response is only related to $p_{ek}$.

+

$K_{hk}$, $K_{ek}$ are related to both $H(s)$ and $E(s)$.

+

However natural and forced responses could not be completely separated, if there exists $k, k^\prime$ satisfying $p_{hk}=p_{ek^\prime}$.

+

$p_{hi}$ are called natural frequency of the system.

+

However, some common factors may be eliminated:

+
$$ +\frac{(s+1)}{(s+1)(s+2)} = \frac{1}{(s+2)} +$$
+ +
$$ +H(s) = \frac{\Delta_{jk}}{\Delta} +$$
+ +

All the poles of $H(s)$ are the natural frequencies of the system, but $h(t)$ may not include all the natural frequencies(but the root of $\Delta$ contains all natural frequencies).

+

In most cases:

+
$$ +\text{Re}(p_{hi}) < 0, \text{Re}(p_{ei}) = 0 +$$
+ +

Thus the natural response is transient, while the forced response is steady-state.

+

However, some natural response can be steady-state(conjugate poles of $Re(p_{hi})$), while some forced response can be transient.

+

+

+

+
$$ +E_m|H(j\omega)|\sin (\omega_0t + \varphi_0) +$$
+ +
$$ +H(j\omega) =K\cdot \frac{\prod(j\omega - z_j)}{\prod (j\omega - p_i)} +$$
+ +

+

+

+

for band-pass filter,

+

BW is where Peak(dB) - 3dB

+

for low-pass filter,

+

BW = $f_{\text{cut-off}}$

+

According to the sampling theorem, the signal bandwith is often determined by the first zero of the spectrum.

+

All Pass Systems

+
$$ +R_e(p_i) = -R_e(z_i)\\ +I_m(p_i) = I_m(z_i) +$$
+ +

The Amplitude is const., while the phase can change.

+

Minimum-phase system/function

+

Definition: A stable system with poles on left-half s-plane is called minimum-phase system/function, if all the zeros are also on left-half s-plane or at the jω-axis. Otherwise is a non-minimum-phase system/function.

+

Property: A non-minimum-phase function can be represented as the product of a minimum-phase function and an all-pass function.

+

Stability of Linear System

A system is considered to be stable if bounded input always leads to bounded output.

+

Bounded-input, Bounded-output(BIBO)

+

The necessary & sufficient conditions for BIBO:

+
$$ +\int_{-\infty}^\infty|h(t)|\mathrm dt \le M +$$
+ +

Poles are:

+
    +
  • on the left half-plane: $\lim_{t\rightarrow \infty}[h(t)] = 0$, stable system
  • +
  • on the right half-plane, or at $j\omega$-axis with order of more than one: $\lim_{t\rightarrow \infty}[h(t)] = \infty$, unstable system
  • +
  • at $j\omega$-axis with order of one: $h(t)$ is non-zero or oscillated with equal amplitude, critical stable system
  • +
+

Two-sided (Bilateral) LT

$$ +F_B(s) = \int_{-\infty}^\infty f(t)e^{-st}\mathrm{d} t +$$
+ +
    +
  • t starts from −∞, i.e., non-causal signal as the input
    or regarding the initial condition as the input.
  • +
  • Easily to be associated with F-transform and Z-
    transforms
  • +
+

We determine the ROC by:

+
$$ +\lim_{t\rightarrow \infty} f(t)e^{-\sigma t} = 0\\ +\lim_{t\rightarrow -\infty} f(t)e^{-\sigma t} = 0 +$$
+ +

NOTE:

+
    +
  • If no overlap between the two constraints, then $F_B(s)$ does not exist.
  • +
  • $F_B(s)$ and $f(t)$ are not uniquely corresponding to each other.($\int_{-\infty}^\infty u(t)e^{-st}\mathrm{d} t = \frac{1}{s}$, $\int_{-\infty}^\infty -u(-t)e^{-st}\mathrm{d} t=\frac{1}{s}$)
  • +
  • Two-sided L-Transform shares almost all the properties with its single-sided counterpart except for the initial-value theorem.
  • +
  • Two-sided L-Transform has very limited applications as most continuous-time systems are causal.
  • +
+

**Relationship between LT and FT **

+
    +
  • $\sigma_0 > 0$, $F(\omega)$ does not exist
  • +
  • $\sigma_0 = 0$, impulse appears in $F(\omega)$
  • +
  • $\sigma_0 < 0$, $F(\omega)$ exists, $F(\omega) = F(s)|_{s=j\omega}$
  • +
+


(The LT above is unilateral LT.)

+

+

Extra Attention

$1 + e^{-s}$ also has zero(many!). Note that if it is on the denominator.

+

FT in Telecom. Systems

System discussed in this chapter are strictly stable:

+
$$ +\mathcal{F}[f(t)] = F(s)|_{s=j\omega} +$$
+ +

Because even for critical stable system, FT is not the same as LT(containing $\delta$), there will be ambiguity between $H(j\omega)$ and $H(s)|_{s=j\omega}$.

+

For every freq. component, it is reshaped in its phase and amplitude by the system function when passing through the system, related with its frequency. Thus the system can distort the original signal.

+

Distortion

+

2 types of distortion:

+
    +
  • Non-linear distortion (new frequency components)
  • +
  • Linear distortion (without new frequency components), just the amplitude and/or phase distortion.
  • +
+

Distortionless transmission

+
$$ +e(t)\rightarrow ke(t - t_0) +$$
+ +
$$ +R(j\omega) = \int_{-\infty}^\infty ke(t -t_0)e^{-j\omega t}\mathrm dt=ke^{-j\omega t_0}\int_{-\infty}^\infty e(x)e^{-j\omega x}\mathrm dx=ke^{-j\omega t_0} E(j\omega) +$$
+ +

So, $H(j\omega) = ke^{-j\omega t_0}$, $h(t)=K\delta(t - t_0)$.

+

The Amplitude is frequency independent, $BW\rightarrow \infty$.

+

Phase response is linear at negative slope.

+

The impulse response of a distortionless linear system is
also an impulse.

+

The physical scenario: group delay.

+
$$ +\tau = -\frac{\mathrm d\varphi (\omega)}{\mathrm d\omega} +$$
+ +

Condition for phase distortionless property: the group delay remains a constant.

+

Filter

Ideal Low pass (LP) Filter

+
$$ +H(j\omega) = \begin{cases} + 1 \cdot e^{-j\omega t_0}, &|\omega|< \omega_c,\\ + 0, &|\omega|> \omega_c. +\end{cases} +$$
+ +

+

The Impulse response of Ideal LP

+

+
    +
  • Severe distortion. $BW_{\delta(t)}\rightarrow \infty$, but $BW_{\text{Lowpass}}=\omega_c$, the higier frequency is eliminated.
  • +
  • Non-causal. When $t\lt 0$, $h(t)\ne 0$.
  • +
+

Unit-step response of Ideal LP

+

+

+

+

The response is similar to the input if $\frac{1}{2}=\frac{\pi}{\omega_c}\llless \tau$.

+

Gibbs phenomenon: 9% overshoot at discontinuity. Use other window functions can eliminate this, e.g. raised-cosine window.

+

Modulation and demodulation

Means of modulation:

+

Spectrum shifting

+

$f(t) = g(t)\cos(\omega_0t)$, $F(\omega) =\frac{1}{2\pi} G(\omega) * \pi[\delta(\omega - \omega_0) + \delta (\omega + \omega_0)] = \frac{1}{2}[G(\omega + \omega_0) + G(\omega - \omega_0)]$.

+

+

Demodulation:

+

coherent demodulation

+

$g_0(t)=[g(t)\cos(\omega_0 t)]\cos(\omega_0t) = \frac{1}{2}g(t) + \frac{1}{2}g(t)\cos2\omega_0t$

+

+

Envelope Detection

+

+

Applications of BPF

Window Function
(Page 304)

+
$$ +h_a(t) = \frac{\sqrt a \sin\left(\frac{\pi t}{a}\right)\cos \left(\frac{3\pi t}{a}\right)}{\sqrt{ \pi} \pi t}\\ +H_a(\omega) = \begin{cases} + \frac{1}{2}\sqrt{\frac{a}{\pi}}, \text{if } \frac{2\pi}{a}\le |\omega| \le \frac{4\pi}{a},\\ + 0, \text{otherwise}. +\end{cases} +$$
+ +

+

Recover Continuous Time signal from its Samples

Analysis on signal after band-pass filter

+

Page 301

+

Sampling with impulse func.

+

FD analysis:

+

Sampled signal(By impulse function):

+
$$ +F_s(\omega) = \frac{1}{T_s}\sum_{n=-\infty}^\infty F(\omega - n\omega_s) +$$
+ +

Ideal LP Filter:

+
$$ +H(j\omega) = \begin{cases} + T_s, &|\omega|< \omega_c,\\ + 0, &|\omega|> \omega_c. +\end{cases} +$$
+ +

Recovered signal:

+
$$ +F(\omega) = F_s(\omega) \cdot H(\omega) +$$
+ +

TD analysis:

+

Sampled signal:

+
$$ +f_s(t) = \sum_{n=-\infty}^\infty f(nT_s)\delta(t - nT_s) +$$
+ +

Ideal LP Filter:

+
$$ +h(t) = T_s\frac{\omega_c}\pi \text{Sa}(\omega_c t) +$$
+ +

Recovered signal:

+
$$ +f(t) = f_s(t) * h(t) = T_s\frac{\omega_c}\pi \sum_{n=-\infty}^\infty f(nT_s) \text{Sa}(\omega_c (t-nT_s)) +$$
+ +

+

+

Sampling with a zero-order hold

+

+
$$ +h_0(t) = u(t) - u(t - T_s)\\ +f_{s0}(t) = f_s(t)* h_0(t) +$$
+ +
$$ +\begin{align*} +&\mathcal F\lbracef_{s0}(t)\rbrace \\&=\mathcal F\{f_s(t)\} \cdot \mathcal F\{h_0(t)\} \\ &=F_s(\omega) \cdot H_0(\omega)\\ +&=\sum_{-\infty}^{\infty}F(\omega - n\omega_s) \cdot \text{Sa}(\frac{\omega_c T_s}{2})e^{-j\frac{\omega T_s}{2}}\\ +\end{align*} +$$
+ +

LP Filter for compensation

+
$$ +H_{0r}(\omega) = \begin{cases} + \frac{1}{\text{Sa}(\frac{\omega T_s}{2})}e^{j\omega T_s/2}, &|\omega| \le \omega_s/2,\\ + 0, &|\omega|> \omega_s/2. +\end{cases} +$$
+ +

Linear phase response is OK! No needed for delay compensation.

+

1st-order hold Sampling

+

+

Mulitplexing FDM and TDM

Transmit mulitple singals over a single channel concurrently.

+

Frequency Division Multiplexing (FDM) - OFDM (Orthogonal FDM)

+

Time Division Multiplexing (TDM)-sharing slot, statistical multiplexing

+

Code Division Multiplexing (CDM)- Code division, logical multiplexing

+

Wavelength Division Multiplexing (WDM)- Optical carrier

+

+

+

+

Vector Analysis of Signals

Vector Space

+

+

+

+

+

Objective for singal decomposition

$$ +r(t) = H[e(t)] = H\left[\sum_{i=0}^ne_i(t)\right] = \sum_{i=0}^nH[e_i(t)] +$$
+ +

Basics

Orthogonal Vector

+

+

Orthogonal Function

+

Represend $f_1(t)$ in terms of $f_2(t)$(both real), for $t_1<t<t_2$

+
$$ +f_1(t)\approx c_{12}f_2(t) +$$
+ +

Residual error $\overline{\varepsilon^2} = \overline{f_e^2(t)} = \frac{1}{t_2 - t_1}\int_{t_1}^{t_2}[f_1(t) - c_{12}f_2(t)]^2\mathrm dt$

+

Let $\frac{\mathrm d \overline{\varepsilon^2}}{\mathrm d c_{12}} = 0$, then $\overline{\varepsilon^2}$ is minimized.

+

The coefficient can be determined as

+
$$ +c_{12} = \frac{\int_{t_1}^{t_2}f_1(t)f_2(t)\mathrm dt}{\int_{t_1}^{t_2}f_2^2(t)\mathrm dt} = \frac{\langle f_1, f_2\rangle}{\langle f_2, f_2\rangle} +$$
+ +

If $c_{12} = 0$, then $f_1(t), f_2(t)$ are called Orthogonal Functions.

+

And

+
$$ +\int_{t_1}^{t_2}f_1(t)f_2(t)\mathrm dt = 0 +$$
+ +

Orthogonal Function Set

+

Any real function $f(t)$ can be represented as the sum of $n$-D orthogonal real functions.

+
$$ +f(t) = \sum_{r=1}^n c_rg_r(t) +$$
+ +

According to the minimal mean square error, the coefficient can be determined as

+
$$ +c_r = \frac{\int_{t_1}^{t_2}f(t)g_r(t)\mathrm dt}{\int_{t_1}^{t_2}g_r^2(t)\mathrm dt} = \frac{\langle f, g_r\rangle}{\langle g_r, g_r\rangle} +$$
+ +

If $g_1(t), g_2(t), …, g_n(t)$ are orthogonal to each other, i.e.

+
$$ +\int_{t_1}^{t_2}g_r(t)g_s(t)\mathrm dt =\begin{cases} + K_i, &r = s,\\ + 0, &r \ne s +\end{cases} +$$
+ +

Then $f(t)$ can be represented as the sum of $n$-D orthogonal real functions.

+

Then $g_1(t), g_2(t), …, g_n(t)$ are called Orthogonal Function Set.

+

If $\int_{t_1}^{t_2}g_i^2(t)\mathrm dt = 1$, the orthogonal function set is called Orthonormal Function Set.

+

Orthogonality of Complex Function

+
$$ +c_{12} = \frac{\int_{t_1}^{t_2}f_1(t)f_2^*(t)\mathrm dt}{\int_{t_1}^{t_2}f_2(t)f_2^*(t)\mathrm dt} = \frac{\langle f_1, f_2^*\rangle}{\langle f_2, f_2^*\rangle} +$$
+ +

Orthogonal Function Set satisfies

+
$$ +\int_{t_1}^{t_2}g_r(t)g_s^*(t)\mathrm dt =\begin{cases} + K_i, &r = s,\\ + 0, &r \ne s +\end{cases} +$$
+ +

The definition of Orthogonal is

+
$$ +\int_{t_1}^{t_2}f_1(t)f_2^*(t)\mathrm dt = \int_{t_1}^{t_2}f_2(t)f_1^*(t)\mathrm dt = 0 +$$
+ +

NOTE:

+
    +
  • If two signals are orthogonal within a given interval, they are not necessarily orthogonal within other intervals.

    +
  • +
  • If two signals are not orthogonal, they must be correlated.

    +
  • +
+

Complete Orthogonal Function and Parseval’s Theorem

Complete Orthogonal Funtion Set

+
$$ +\overline{\varepsilon^2} = \frac{1}{t_2-t_1}\left[\int_{t_1}^{t_2}f^2(t)\mathrm dt - \sum_{r = 1}^nc_r^2K_r\right] +$$
+ +

If $\lim_{t_2 \to \infty}\overline{\varepsilon^2} = 0$, then ${g_r(t)}$ is said to be a Complete Orthogonal Function Set.

+

Alternative definition of complete orthogonal set

+

Other than the elements in ${g_r(t)}$, there is no finite-energy signal $x(t)$, which satisfies

+
$$ +\int_{t_1}^{t_2}x(t)g_r(t)\mathrm dt = 0, \forall r\\ +\text{or } \int_{t_1}^{t_2}x(t)g_r^*(t)\mathrm dt = 0, \forall r +$$
+ + +

Trigonometric Set

+
$$ +\left\{\cos n\omega_1 t\right\}_{n\rightarrow\infty}\\ +\left\{\sin n\omega_1 t\right\}_{n\rightarrow\infty} +$$
+ +

Complex exponential set

+
$$ +\left\{e^{jn\omega_1 t}\right\}_{n\rightarrow\infty} +$$
+ +

Parseval’s Theorem

+
$$ +\int_{t_1}^{t_2}f(t)^2\mathrm dt = \sum_{r=1}^\infty c_r^2K_r = \sum_{r=1}^\infty\int_{t_1}^{t_2}[c_rg_r(t)]^2\mathrm dt +$$
+ +

Physical interpretation:

+

The energy (power) of a signal always equals to the sum of the energy (power) of all its components in a complete orthogonal function set.

+

Mathematical interpretation:

+

The norm of vector signals keeps invariant under orthogonal transform.

+

Correlation

Physical interpretation:

+

Gauge of the similarity of two signals

+

Energy and Power Signals

+

Instaneous Power $p(t) = i^2(t) R$

+

The energy consumed by $R$ in a period

+
$$ +E = \int_{-T_0/2}^{T_0/2}p(t)\mathrm dt = R\int_{-T_0/2}^{T_0/2}i^2(t) \mathrm dt +$$
+ +

Average Power:

+
$$ +P = \frac{1}{T_0}\int_{-T_0/2}^{T_0/2}p(t)\mathrm dt = \frac{1}{T_0}R\int_{-T_0/2}^{T_0/2}i^2(t) \mathrm dt +$$
+ +

The energy signals and power signals:

+
$$ +E = \lim_{T_0 \to \infty}\int_{-T_0/2}^{T_0/2}f^2(t)\mathrm dt\\ +P = \lim_{T_0 \to \infty}\frac{1}{T_0}\int_{-T_0/2}^{T_0/2}f^2(t)\mathrm dt +$$
+ +

Correlation Coefficient

+
$$ +\rho_{12} = \frac{\int_{t_1}^{t_2}f_1(t)f_2^*(t)\mathrm dt}{\sqrt{\int_{t_1}^{t_2}f_1^2(t)\mathrm dt}\sqrt{\int_{t_1}^{t_2}f_2^2(t)\mathrm dt}} = \frac{\langle f_1, f_2\rangle}{\sqrt{\langle f_1, f_1\rangle}\sqrt{\langle f_2, f_2\rangle}} = \frac{\langle f_1, f_2\rangle}{\|f_1\|_2\|f_2\|_2} +$$
+ +

If $f_1(t)$ is a linear function of $f_2(t)$, then $\rho_{12} = \pm1$, $\overline{\varepsilon^2} = 0$.

+

If $f_1(t)$ is orthogonal to $f_2(t)$, then $\rho_{12} = 0$, $\overline{\varepsilon^2}$ is maximized.

+
    +
  • Describe the correlation of two signals from the perspective of energy difference.
  • +
  • Quantitatively measure the correlation of two signals in terms of inner product.
  • +
+

Correlation Function

+

The similarity between one signal with a delayed version of another signal.

+

(1) $f_1(t)$ and $f_2(t)$ are both real and energy signals

+
$$ +R_{12}(\tau) = \int_{-\infty}^{\infty}f_1(t)f_2(t-\tau)\mathrm dt = \int_{-\infty}^{\infty}f_1(t + \tau)f_2(t)\mathrm dt\\ +R_{21}(\tau) = \int_{-\infty}^{\infty}f_2(t)f_1(t-\tau)\mathrm dt = \int_{-\infty}^{\infty}f_2(t + \tau)f_1(t)\mathrm dt\\ +R_{12}(\tau) = R_{21}(-\tau) +$$
+ +

(2) $f_1(t)$ and $f_2(t)$ are both complex and energy signals

+

If $f_1(t) = f_2(t) = f(t)$

+

Autocorrelation:

+
$$ +R(\tau) = \int_{-\infty}^{\infty}f(t)f(t-\tau)\mathrm dt = \int_{-\infty}^{\infty}f(t + \tau)f(t)\mathrm dt\\ +$$
+ +

(2) $f_1(t)$ and $f_2(t)$ are both complex and energy signals

+
$$ +R_{12}(\tau) = \int_{-\infty}^{\infty}f_1(t)f_2^*(t-\tau)\mathrm dt = \int_{-\infty}^{\infty}f_1(t + \tau)f_2^*(t)\mathrm dt\\ +R_{21}(\tau) = \int_{-\infty}^{\infty}f_2(t)f_1^*(t-\tau)\mathrm dt = \int_{-\infty}^{\infty}f_2(t + \tau)f_1^*(t)\mathrm dt\\ +R_{12}(\tau) = R_{21}^*(-\tau) +$$
+ +

Autocorrelation:

+
$$ +R(\tau) = \int_{-\infty}^{\infty}f(t)f^*(t-\tau)\mathrm dt = \int_{-\infty}^{\infty}f(t + \tau)f^*(t)\mathrm dt\\ +R(\tau) = R^*(-\tau) +$$
+ + +

(3) $f_1(t)$ and $f_2(t)$ are both real and power signals

+
$$ +R_{12}(\tau) = \lim_{T\rightarrow\infty}\left[\frac1T\int_{-T/2}^{T/2}f_1(t)f_2(t-\tau)\mathrm dt \right]\\ +R_{21}(\tau) = \lim_{T\rightarrow\infty}\left[\frac1T\int_{-T/2}^{T/2}f_2(t)f_1(t-\tau)\mathrm dt \right]\\ +$$
+ +

Autocorrelation

+
$$ +R(\tau) = \lim_{T\rightarrow\infty}\left[\frac1T\int_{-T/2}^{T/2}f(t)f(t-\tau)\mathrm dt \right]\\ +$$
+ +

(4) $f_1(t)$ and $f_2(t)$ are both complex and power signals

+
$$ +R_{12}(\tau) = \lim_{T\rightarrow\infty}\left[\frac1T\int_{-T/2}^{T/2}f_1(t)f_2^*(t-\tau)\mathrm dt \right]\\ +R_{21}(\tau) = \lim_{T\rightarrow\infty}\left[\frac1T\int_{-T/2}^{T/2}f_2(t)f_1^*(t-\tau)\mathrm dt \right]\\ +$$
+ +

Autocorrelation

+
$$ +R(\tau) = \lim_{T\rightarrow\infty}\left[\frac1T\int_{-T/2}^{T/2}f(t)f^*(t-\tau)\mathrm dt \right]\\ +$$
+ +

Correlation Theorem

+
$$ +\mathcal F(x(t)) = X(\omega)\\ +\mathcal F(y(t)) = Y(\omega)\\ +\mathcal F(R_{xy}(\tau)) = X(\omega)Y^*(\omega)\\ +$$
+ +

If $x(t) = y(t)$, The FT of the autocorrelation function is $\mathcal F[{R_{xx}(\tau)}] = |X(\omega)|^2$

+

If $y(t)$ is a real and even function: $Y^*(\omega) = Y(\omega)$

+

Then the correlation theorem is equivalent to the convolution theorem

+
$$ +\mathcal F(\int_{-\infty}^\infty x(t)y(t-\tau)\mathrm dt) = X(\omega)Y(\omega)\\ +$$
+ +

Generally,

+
$$ +R_{12}(t) = f_1(t) * f_2(-t) +$$
+ +

Energy & Power Spectral Density

$$ +R(\tau) = \int_{-\infty}^{\infty}f(t)f^*(t-\tau)\mathrm dt\\ +$$
+ +
$$ +R(\tau) = \frac{1}{2\pi}\int_{-\infty}^{\infty}\lvert F(\omega)\rvert^2 e^{j\omega\tau}\mathrm d\omega\\ +|F(\omega)|^2 = \int_{-\infty}^{\infty}R(\tau)e^{-j\omega\tau}\mathrm d\tau\\ +$$
+
$$ +R(0) = \int_{-\infty}^{\infty}f(t)f^*(t)\mathrm dt = \int_{-\infty}^{\infty}\lvert f(t)\rvert^2\mathrm dt\\ +R(0) = \frac{1}{2\pi}\int_{-\infty}^{\infty}\lvert F(\omega)\rvert^2\mathrm d\omega\\ +$$
+ +
$$ +\int_{-\infty}^{\infty}\lvert f(t)\rvert^2\mathrm dt = \frac{1}{2\pi}\int_{-\infty}^{\infty}\lvert F(\omega)\rvert^2\mathrm d\omega +$$
+ +

Energy Spectral Density

+
$$ +\mathcal{E}(\omega) = \lvert F(\omega)\rvert^2\\ +$$
+ +
$$ +\mathcal{E}(\omega) = \mathcal{F}[R(\tau)]\\ +R(\tau) = \mathcal{F}^{-1}[\mathcal{E}(\omega)]\\ +$$
+ +

Power Spectral Density

+
$$ +\mathcal F[ R(\tau)] = \mathcal P(\omega)\\ +$$
+ +

It is called Power Spectral Density (PSD).

+

Wiener-Khinchin Theorem

+
$$ +R(\tau) = \frac{1}{2\pi}\int_{-\infty}^{\infty}\mathcal P(\omega)e^{j\omega\tau}\mathrm d\tau\\ +\mathcal P(\omega) = \int_{-\infty}^{\infty}R(\tau)e^{-j\omega\tau}\mathrm d\omega\\ +$$
+ +

ESD/PSD of the System Response

$$ +|R(j\omega)|^2 = |H(j\omega)|^2|E(j\omega)|^2\\ +\mathcal{E}_r(\omega) = |H(j\omega)|^2\mathcal{E}_e(\omega)\\ +\mathcal{P}_r(\omega) = |H(j\omega)|^2\mathcal{P}_e(\omega)\\ +$$
+ +

+

The last line of this table is wrong. The correct is:

+
$$ +R_h(\tau) = h(\tau) * h^*(-\tau) +$$
+ +

Match Filters

$$ +H(j\omega) = kS(-j\omega)e^{-j\omega t_m}\\ +h(t) = ks(t_m - t)\\ +$$
+ +

$t_m$ is the signal width in TD.

+

Discrete time signals

Discrete time-axis, but continuous amplitude-axis

+

Sequence operation

Addition $z(n) = x(n) + y(n)$

+

Multiplication $z(n) = x(n) * y(n)$

+

Multiplied a coefficient $z(n) = a * x(n)$

+

Shift $z(n) = x(n - m)$ right shift($m>0$), $z(n) = x(n +m)$ left shift

+

Reflection $z(n) = x(-n)$

+

Difference $\Delta x(n) = x(n + 1) - x(n)$ Forawrd difference,

+

$\nabla x(n) = x(n) - x(n - 1)$ Backward difference

+

$\nabla^mx(n) = \nabla(\nabla^{m-1}x(n))$

+

Summation $z(n) = \sum_{k = -\infty}^{n}x(k)$

+

Scaling $z(n) = z(2n)$ squeeze,

+

$z(n) = x(n/2)$, extend

+

Typical sequences

+

+

Relations of several singal waveforms

+
$$ +u(n) = \sum_{k = 0}^{\infty}\delta(n - k)\\ +\delta(n) = u(n) - u(n - 1)\\ +R_N(n) = u(n) - u(n - N)\\ +$$
+ +

Signal Decomposition

$$ +x(n) = \sum_{m = -\infty}^{\infty}x_m\delta(n - m)\\ +$$
+ +
$$ +\delta(n - m) = \begin{cases} +1, & n = m\\ +0, & n \neq m +\end{cases} +$$
+ +

Difference equations

+

Numerical solution of difference equations

+

General form of difference equation:

+
$$ +\sum_{k = 0}^N a_ky(n - k) = \sum_{r = 0}^M b_ry(n - r)\\ +$$
+ +

Methods:

+
    +
  • Recursive method
  • +
    • +
    • Intuitive, difficult to formulate the closed-form solutions
    • +
    +
  • +
  • Time-domain classical method
  • +
    • +
    • Obtain homogeneous and particular solutions and using the boundary condition to determine the coefficients.
    • +
    +
  • +
  • The sum of the zero-input and zero-state responses
  • +
    • +
    • Convolution (next class)
    • +
    +
  • +
  • Z-transform (Chapter 8)
  • +
  • State variable method (Chapter 11)
  • +
+

Homogeneous Solution

+
$$ +\sum_{k = 0}^N a_ky(n - k) = 0\\ +$$
+ +

The characteristic root $\alpha_k$ satisfies:

+
$$ +a_0\alpha^N + a_1\alpha^{N-1} + \cdots + a_N = 0\\ +$$
+ +

The homogeneous solution is:

+
$$ +y(n) = c_1\alpha_1^n + c_2\alpha_2^n + \cdots + c_N\alpha_N^n\\ +$$
+ +

Particular Solutions:

+

+

General steps

+
    +
  1. Obtain homogeneous solutions from characteristic equation $c_1\alpha_1^n + c_2\alpha_2^n + \cdots + c_N\alpha_N^n$
  2. +
  3. Determine the form of the particular solution $D(n)$
  4. +
  5. The complete solution $c_1\alpha_1^n + c_2\alpha_2^n + \cdots + c_N\alpha_N^n + D(n)$
  6. +
  7. Introduce the boundary condition and set up equations
    $$ +y(0) = C_1 +C_2 + \cdots + C_N + D(0)\\ +y(1) = C_1\alpha_1 +C_2\alpha_2 + \cdots + C_N\alpha_N + D(1)\\ +\vdots\\ +y(N - 1) = C_1\alpha_1^{N - 1} + C_2\alpha_2^{N - 1} + \cdots + C_N\alpha_N^{N - 1} + D(N - 1)\\ +\Rightarrow\\ +Y(k) - D(k) = VC\\ +C = V^{-1}(Y(k) - D(k))\\ +$$
  8. +
+

Zero-input and zero-state responses

$$ +y(k) = y_{zi}(k) + y_{zs}(k) +$$
+ +

Zero-Input Response
$D(k) = 0 \Rightarrow C_{zi} = V^{-1}Y_{zi}(k)$

+

Zero-State Response

+
$$ +\begin{align*} + C_{zs} &= V^{-1}[Y_{zs}(k) - D(k)]\\ +C_{zs} &= V^{-1}[Y(k) - Y_{zi}(k) - D(k)]\\ +C &= C_{zi} + C_{zs}\\ +\end{align*} +$$
+ +

Natural Response $\sum_{k = 1}^NC_k\alpha_k^n$

+

Forced Response $D(n)$

+

Characteristics of the boundary condition for difference equations

+

N-th order difference equation should have N independent boundary conditions.

+

Compared with continuous systems, there are no big differences between $0_+$ and $0_-$ in discrete systems.

+

$y(-1), y(-2), \dots, y(-N)$ are the system memory (storage) before the excitation is added: $0_-$

+

Derive (together with the excitation) $y(0), y(1), …, y(N-1): 0_+$

+

Using Z-transform can avoid mistakes-similar to the Laplace transform in continuous systems.

+

Impulse response of DT systems

Similar to CT System, h(n) reflects system’s property

+

Causality $h(n) = h(n) u(n)$ (unlateral, $n\lt 0$ no response)

+

Stability $\sum_{n=-\infty}^\infty |h(n)| \lt \infty$ (absolutely summable)

+
 NOTE:  critical stability can be considered as either stable or unstable, e.g.,  system whose impulse response is a sine sequence
+
+

Not all practical discrete systems are necessarily causal:

+
    +
  • Variable is not time, like image processing
  • +
  • Variable is time, but data has been recorded and processed, like voice processing, meteorology, stock systems.
  • +
+

Example: Smooth windowing

+
$$ +y(n) = \frac{1}{2M+1}\sum_{k=-M}^M x(n-k) +$$
+ +

Discrete non-causal system

+

Convolution Sum

$$ +y(n) = \sum_{m = -\infty}^\infty x(m)h(n - m) = h(n) * x(n) +$$
+ +

Similar to CT system, also satisfies both distributive and associative laws

+

Calculation of convolution:
Four steps: reflection, shift, multiplication and summation.

+

Calculation of correlation:
Cross- & auto-correlation: shift, multiplication & summation.

+

Example:

+
$$ +x(n) = u(n) - u(n - N)\\ +h(n) = a^nu(n)\\ +y(n) = x(n) * h(n) +$$
+ +
$$ +y(n) = \sum_{m = -\infty}^\infty [u(m) - u(m - N)]a^{n - m}u(n - m) +$$
+ +

if $n < 0$, then $y(n) = 0$

+

if $0 \le n \lt N - 1$, $y(n) = \sum_{m = 0}^na^{n-m} = \frac{1}{1 - a}[1 - a^{n+1}]$

+

if $n \ge N - 1$, $y(n) = \frac{1 - a^{-N}}{1 - a^{-1}}a^n$

+

Deconvolution

+

Signal retrieval y(n) and h(n) are known, how to derive x(n)?

+

Measurement equipment (linear system), like sensor for measuring blood pressure

+

System identification y(n) and x(n) are known, how to derive h(n)?

+

Earthquake signal, like geological survey, oil exploration, etc.

+
$$ +\begin{bmatrix*} + y(0)\\ + y(1)\\ + y(2)\\ + \vdots\\ + y(n) +\end{bmatrix*} = +\begin{bmatrix*} + h(0) & 0 & 0 & \dotsb & 0\\ + h(1) & h(0) & 0 & \dotsb & 0\\ + h(2) & h(1) & h(0) & \dotsb & 0\\ + \vdots & \vdots & \vdots & \ddots & \vdots\\ + h(n) & h(n-1) & h(n-2) & \dotsb & h(0)\\ +\end{bmatrix*}\begin{bmatrix*} + x(0)\\ + x(1)\\ + x(2)\\ + \vdots\\ + x(n) +\end{bmatrix*} +$$
+ +

Thus,

+
$$ +x(n) = \left[y(n) - \sum_{m = 0}^{n-1} x(m) h(n - m)\right]/h(0)\\ +h(n) = \left[y(n) - \sum_{m = 0}^{n-1} h(m) x(n - m)\right]/x(0) +$$
+ +

Important Concepts

+
    +
  1. Symbol rate : clock period is $T$, signal symbol rate is $f = 1/T$.
  2. +
  3. Information rate: information rate equals to symbol rate for binary encoding, otherwise, equal to multiplication between symbol rate and number of information bits per symbol.
  4. +
  5. Signal bandwidth: the first zero of non-return-to-zero (NRZ) signal’s spectrum is $1/T$, so the signal bandwidth is $B=1/T =f$.
  6. +
+
+

这句话是在介绍非归零码(Non-Return-to-Zero,简称NRZ)信号的带宽计算方式。

+

在信号处理和通信中,信号的频谱表示了信号在不同频率上的能量分布。对于一个NRZ信号,它的频谱图中第一个零点(也就是在零周围出现的第一个极小值点)出现在频率为$1/T$处,其中$T$是NRZ信号中一个脉冲的时间长度。这是因为NRZ信号的频谱是由一个周期为$T$的方波产生的,其频率成分只包含正弦函数的奇次谐波。其中,最低的一个谐波频率是$f=\frac{1}{T}$,对应的是频率为$f$的正弦波。所以,NRZ信号的带宽$B$就被定义为$f=1/T$。

+

简而言之,NRZ信号的带宽是由脉冲的时间长度决定的,具体来说,带宽等于脉冲频率的一半,即带宽等于$f=1/T$。

+
+

NOTE:

+

When NRZ code is used, signal bandwidth = symbol rate

+

When return-to-zero (RZ) code is used, signal bandwidth > symbol rate

+

Using NRZ code can save bandwidth yet high frequency components of the rectangular signal will suffer from the severe inter-symbol interference (ISI). So the raised cosine or Sa function is preferred.

+
+

ChatGPT:

+

归零码和非归零码都是数字通信中常用的编码方式。

+

归零码(Return-to-Zero,简称RZ)是一种二进制码,其中一个信号所代表的位是由一个脉冲表示的。发送二进制“1”时,脉冲电平为高电平,发送二进制“0”时,脉冲电平为低电平。在归零码中,一个信号位所代表的脉冲之后,信号在下一时刻会回到零电平。由于归零码中每个脉冲结束时信号回到零电平,因此这种编码方式具有稳定可靠的特点,但是传输的带宽相对较大。

+

非归零码(Non-Return-to-Zero,简称NRZ)的编码方式与归零码不同之处在于,在NRZ信号中,一个信号所代表的位是由一个固定电平表示的。当信号所代表的位是二进制“1”时,固定电平为高电平;当信号所代表的位是二进制“0”时,固定电平为低电平。这种编码方式的好处是带宽更小,但是却存在着在多个二进制“1”连续发送时,出现误解的情况。

+

综上所述,归零码是二进制码中脉冲与幅度的双重编码,不易产生传输误码,但其对于通信带宽需求较大;而非归零码不需要对脉冲进行编码,在带宽方面具有一定的优势,但长时间连续发送相同信息时会产生误解。

+
+

Z-Transform

Similar to the L-Tranform.

+

Definition

+
$$ +X(z) = Z(x(n)) = \sum_{n = -\infty}^{\infty} x(n) z^{-n} +$$
+ +

Z-T of Typical Series

+

$z \in \Complex$

+
$$ +\delta(n) \rightarrow 1\\ +u(n) \rightarrow \frac{1}{1-z^{-1}}(|z| \gt 1)\\ +nu(n) \rightarrow \frac{z^{-1}}{(1-z^{-1})^2}(|z| \gt 1)\\ +a^n u(n) \rightarrow \frac{1}{1-az^{-1}}(|z| \gt |a|)\\ +\cos(\omega_0 n) u(n) \rightarrow \frac{1-z^{-1}\cos(\omega_0)}{1-2z^{-1}\cos(\omega_0) + z^{-2}}\\ +\sin(\omega_0 n) u(n) \rightarrow \frac{z^{-1}\sin(\omega_0)}{1-2z^{-1}\cos(\omega_0) + z^{-2}}\\ +$$
+ +

The Region of Convergence

+

+

Inverse Z-Transform

+
$$ +x(n) = \frac{1}{2\pi j} \oint_C X(z) z^{n-1} dz +$$
+ +

Method

+

Contour Integration(residue method)

+

Right-sided sequence

+
$$ +x(n) = \sum_{k = 1}^{N} Res\{X(z)z^{n-1}\}|_{z = z_k} +$$
+ +

Left-sided sequence

+
$$ +x(n) = - \sum_{k = 1}^{N} Res\{X(z)z^{n-1}\}|_{z = z_k} +$$
+ +

Power series expansion(Long division)

+

+

If it is right sided,

+
$$ +X(z) = \sum_{n = 0}^\infty x(n)z^{-n} +$$
+ +

If it is left sided,

+
$$ +X(z) = \sum_{n = -\infty}^{-1}x(n)z^{-n} +$$
+ +

Partial Fraction Expansion

+
$$ +\frac{z}{z - a} \lrarr \begin{cases} + a^nu(n), &|z|\gt |a|\\ + -a^nu(-n-1), &|z|\lt |a| +\end{cases} +$$
+ +

+

+

+

Properties of Z-T

+

Linearity

+

Addition and homogeneity

+

ROC may change!

+

i.e. poles are cancelled when added: ROC will enlarge or and shrink.

+

Time shifting

+

(a) bilateral: If $\mathcal Z[x(n)] = X(z), R_{X_1} < |z| < R_{X_2}$, then $\mathcal{Z}[x(n-m)] = z^{-m}X(z), R_{X_1} < |z| < R_{X_2}$.

+

(b) unilateral: if $\mathcal{Z}[x(n)] = X(z), R_{X_1} < |z|$, then $\mathcal{Z}[x(n-m)] = z^{-m}[X(z) + \sum_{k = -m}^{-1}x(k)z^{-k}], R_{X_1}\lt |z|$, and $\mathcal{Z}[x(n+m)] = z^{m}[X(z) - \sum_{k = 0}^{m-1}x(k)z^{-k}], R_{X_1}\lt |z|$

+

For casual sequence, $n < 0, x(n) = 0$, the unilateral is also $\mathcal{Z}[x(n-m)] = z^{-m}X(z)$.

+

The reason is that the unilateral z transform doesn’t contain the $n<0$ parts of sequence, but after shifting, sometimes must be counted(right shift), sometimes must be discarded(left shift).

+

Linear weighting on sequence(Z domain differentiation)

+
$$ +\mathcal{Z}[x(n)] = X(z) \Rightarrow nx(n)\lrarr -z\frac{dX(z)}{dz} +$$
+ +

Generalization:

+
$$ +n^mx(n)\lrarr \bigg[-z\frac{d}{dz}\bigg]^m X(z) +$$
+ +

Geometric progression(Z-domain scaling)

+
$$ +a^n(x^n) \lrarr X(\frac{z}{a})\\ +(R_{x1} \lt \bigg|\frac{z}{a}\bigg| \le R_{x2}) +$$
+ +
$$ +a^{-n}x(n) \lrarr X(az)\\ +(-1)^nx(n) \lrarr X(-z) +$$
+ +

Initial-value theorem

+
$$ +x(0) = \lim_{z \rightarrow \infty }X(z) +$$
+ +

Final-value theorem

+
$$ +\lim_{n \rightarrow \infty } x(n) = \lim_{z \rightarrow 1}[(z-1)X(z)] +$$
+ +

condition: when $n \rightarrow \infty$, $x(n)$ converge

+

Thus, the poles of $X(z)$ are inside the unit circle, the radius of ROC is less than 1.

+

For $a^nu(n), |a| \lt 1$, the final value is 0.

+

Or, if the pole is on the unit circle, it should be 1, and is of the 1st order.

+

$u(n)$’s final value is 1.

+

+

Time-domain convolution theorem

+

If $\mathcal{Z}{x(n)} = X(z), (R_{x1} \lt |z| \lt R_{x2}), \mathcal{Z}{h(n)} = H(z), (R_{h1} \lt |z| \lt R_{h2})$

+
$$ +\mathcal{Z}[x(n) * h(n)] = X(z)H(z)\\ +\max(R_{x1}, R_{h1}) \lt |z| \lt \min(R_{x2}, R_{h2}) +$$
+ +

If poles are cancelled in multiplication, ROC is enlarged.

+

Conclusion: (Z Transform) convolution in time-domain is equivalent to multiplication (of Z Transform) in Z-domain.

+

Z domain convolution theorem

+
$$ +\mathcal{Z}[x(n)h(n)] = \frac{1}{2\pi j} \oint_C X(\frac{z}{v})H(v)v^{-1}dv +$$
+ +

or

+
$$ +\mathcal{Z}[x(n)h(n)] = \frac{1}{2\pi j} \oint_C X(v)H(\frac{z}{v})v^{-1}dv +$$
+ +

where $C$ is a closed contour in the intersection of ROCs of $X(\frac{z}{v})$ and $H(v)$ or $X(v)$ and $H(\frac z v)$.

+

let $v = \rho e^{j\theta}, z = r e^{j\varphi}$,

+

then

+
$$ +\mathcal Z[x(n)h(n)] = \frac{1}{2\pi}\int_{-\pi}^\pi X(\rho e^{j\theta})H(\frac r\rho e^{-j(\varphi - \theta)})d\theta +$$
+ +

Mapping of ZT and LT

$$ +z = e^{sT} ,\omega_s = \frac{2\pi}{T} +\\ +re^{j\theta} = e^{(\sigma + j\omega)T}\\ +$$
+ +

then,

+
$$ +r = e^{\sigma T} = e^{2\pi\frac{\sigma}{\omega_s}}\\ +\theta = \omega T = 2\pi\frac{\omega}{\omega_s} +$$
+ +

when $\sigma$ is constant,

+

vertical line in $s$-plane maps the circle in $z$-plane.

+

$s$-plane imaginary axis maps the unit circle in $z$-plane.

+

when $\omega$ is constant,

+

+

Correspondence of ZT and LT

+

+

Solving difference equation by Z-T

$$ +\sum_{k = 0}^N a_ky(n-k) = \sum_{r = 0}^M b_rx(n-r) +$$
+ +

Two methods:

+
    +
  • TD method
  • +
  • Z-T method (notice the ROC)
  • +
+

ZT method

+
    +
  1. perform unilateral Z-T on both sides.
  2. +
+

$x(n-r), y(n-k)$ are both right shifted series

+
$$ +\sum_{k = 0}^N a_kz^{-k}[Y(z) + \sum_{l = -k}^{-1}y(l)z^{-l} ]= \sum_{r = 0}^M b_rz^{-r}[X(z) + \sum_{m = -r}^{-1}x(m)z^{-m} ] +$$
+ +
    +
  1. Derive $Y(z)$
  2. +
  3. Perform inverse transform on $Y(z)$ to get $y(n)$(ROC!)
  4. +
+

Zero input response

+
$$ +x(n) = 0\\ +Y(z) = \frac{-\sum_{k = 0}^M[a_kz^{-k}\cdot \sum_{l = -k}^{-1}y(l)z^{-l}]}{\sum_{k = 0}^Na_kz^{-k}} +$$
+ +

Zero state response

+
$$ +y(l) = 0\\ +\text{ casual sequence }: x(m) = 0\\ +\sum_{k = 0}a_kz^{-k}Y(z) = \sum_{r = 0}^M b_rz^{-r}X(z)\\ +Y(z) = X(z)\cdot\frac{\sum_{r = 0}^M b_rz^{-r}}{\sum_{k = 0}^Na_kz^{-k}} = X(z)\cdot H(z) +$$
+ +

System function of DT system

Unit Impulse/sample response $h(n)$ and system function H(z)

+
$$ +y(n) = x(n) * h(n)\\ +Y(z) = H(z)\cdot X(z) +$$
+ +
$$ +H(z) = \frac{Y(z)}{X(z)} = \frac{\sum_{r = 0}^M b_rz^{-r}}{\sum_{k = 0}^Na_kz^{-k}} +$$
+ +

Factorization

+
$$ +H(z) = \frac{\prod_{r = 1}^M(1-z_rz^{-1})}{\prod_{k=1}^N1-p_kz^{-1}} +$$
+ +

We can draw the conclusions directly from the relationship between Z-T and L-T

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Imaginary axis$\sigma=0$Constant amplitude$r = 1$Unit circle
Right half plane
Left half plane
Real axis
+

+

+

Stability and Causality

+

Stable: iff

+
$$ +\sum_{n=-\infty}^\infty |h(n)|\lt \infty +$$
+ +
$$ +z = 1, H(z) = \sum_{n=-\infty}^\infty h(n)\lt \infty +$$
+ +

The condition is ROC of stable system includes the unit circle.

+

Causal:

+
$$ +h(n) = h(n)u(n) +$$
+ +

Condition is ROC includes $\infty$: $R_{X_1}\lt |z|$

+

Stable and causal

+
$$ +a\le |z| \le \infty, a\le 1 +$$
+ +

Discrete-time Fourier Transform(DTFT)

Definition

+
$$ +\mathcal{F}[x(t)\delta_T(t)] = \int_{-\infty}^\infty x(t)\delta_T(t)e^{-j\omega t}dt = \sum_{n=-\infty}^\infty x(nT)e^{-j\omega nT} +$$
+ +

take $T = 1$

+
$$ +\sum_{n=-\infty}^\infty x(n)e^{-j\omega n} = \text{DTFT[x(n)]} +$$
+ +

The relation ship with Z-T:

+
$$ +X(z) = \sum_{n = -\infty}^\infty x(n)z^{-n}, z = e^{j\omega}\\ +$$
+ +
$$ +DTFT[x(n)] = X(z)|_{|z|=1} = X(z)|_{z = e^{j\omega}} = X(e^{j\omega}) +$$
+ +

Inverse transform

+
$$ +x(n) = \frac{1}{2\pi j}\oint_{|z| = 1}X(z)z^{n-1}\mathrm dz=\frac{1}{2\pi}\int_{-\pi}^\pi X(e^{j\omega})e^{j\omega n}\mathrm d\omega +$$
+ +

Frequency Response of DT system

The steady-state response to sine sequence

+
$$ +x(n) = A\sin(n\omega)(n\ge 0)\\ +y_{ss}(n) = A|H(e^{j\omega})|\sin(n\omega + \varphi)\\ +H(e^{j\omega}) = \sum_{n=-\infty}^\infty h(n)e^{-jn\omega} +$$
+ +

The FT of $h(n)$, $H(e^{j\omega})$ is a periodic function with period of $\omega_s = 2\pi /T = 2\pi$.

+

If $h(n)$ is real, then the amplitude/phase response is even/odd function.

+

The amplitude is determined within $[0, \omega_s/2]$

+

+

+

NOTE:

+
    +
  • We can derive the frequency response (function of $\omega$) by letting $D$ move along the unit circle once.
  • +
  • $H(j\omega)$ is periodic. The frequency response from 0 to $\omega_s/2$ can be determined by letting $D$ move along half circle.
  • +
  • If pole $p_i$ is close to the unit circle, there will be a peak in the frequency response. If zero $z_i$ is close to the unit circle, there will be a notch in the frequency response.
  • +
  • For statble systems, $p_i$ should be inside the unit circle, while $z_i$ could be inside or outside the unit circle.
  • +
  • poles and zeros at origin have no influence on amplitude.
  • +
+

Analog and digital Filter

Fundamental Principles

+

+

The spectrum of $x(t)$ is strictly inside $\pm \omega_m$.

+

We choose the sampling frequency:$\omega_s = \frac{2\pi}{T} \ge 2\omega_m$

+

+

Classifications of digital filters

+
$$ +y(n) = \sum_{k=0}^M b_kx(n-k) - \sum_{k=1}^N a_ky(n-k) +$$
+ +

In terms of structure

+

recursive: $a_k\ne 0$ at least for one $k$

+

non-recursive: $a_k=0$, for all $k$

+

In terms of the characteristics of $h(n)$

+

Infinite impulse response(IIR): recursive, non-linear phase

+

Finite impulse response(FIR): non-recursive, linear phase.

+

IIR filter

+

Impulse invariance

+

Based on the s-domain analog filters.

+

Design method 1: 冲激响应不变法

+

Replace $\frac{1}{s-s_k}$ with $\frac{1}{1-e^{s_kT}z^{-1}}$. Then $H_a(s)$ become $H(z)$.

+

The relationship between the continuous and discrete filters:

+
$$ +H(z)|_{z = e^{sT}} = \frac{1}{T}\sum_{k=-\infty}^\infty H_a(s + j\frac{2\pi}{T}k) +$$
+ +

The result is just repeat the original filter at sampling frequency, thus it attenuates slower.

+

NOTE:The digital filter implemented this way has aliasing.

+

The frequency response of analog filter must be attenuated enough within $\omega_s$.

+

This approach can only realize LP and BP filter, but not HP and band-stop one.

+

method 2: Bilinear transformation emerges to address this problem (you can study it by yourself)

+
$$ +s = \frac{2}{T}\left(\frac{1 - z^{-1}}{1 + z^{-1}}\right)\\ +z = \frac{1 + \frac{sT}{2}}{1 - \frac{sT}{2}} +$$
+ +

Bilinear transformation is non-linear transformation.

+

To implement digital filter, A/D and D/A are required, along with ROM, RAM, ALU, delay units (shift registers), etc.

+

FIR filter

+
$$ +H(z) = \sum_{k = 0}^{N-1}b_kz^{-k} = \sum_{n=0}^{N-1}h(n)z^{-n} +$$
+ +

Poles are at $z=0$. $N - 1$ zeros.

+

FIR filter has linear-phase iff

+
$$ +h(n) = h(N - 1 - n)(\text{evenly symmetric})\\ +h(n) = -h(N - 1 - n)(\text{oddly symmetric}) +$$
+ +

+

+

Feedback System: Signal Flow Graphs

Operator and Transfer Operator:

+
$$ +p = \frac{d}{dt}\\ +\frac{1}{p} = \int_{-\infty}^t(\cdot)d\tau +$$
+ +
$$ +(C_0p^n + C_1p^{n-1} + \dotsb + C_n)r(t) = (E_0p^m + E_1p^{m - 1} + \dotsb + E_m)e(t)\\ +D(p)r(t) = N(p)e(t) +$$
+ +

Rules:

+
    +
  • Common factors can’t be eliminated.
  • +
  • Be careful when changing the order of operation($\frac{d}{dt}\int_{-\infty}^tx(\tau)d\tau = x(t)$, $\int_{-\infty}^t\frac{d}{d\tau}x(\tau)d\tau = x(t) - x(-\infty)$)
  • +
+

transfer operator:

+
$$ +r(t) = \frac{N(t)}{D(t)}e(t) = H(p)e(t) +$$
+ +

Brief introduction to the signal flow graphs(SFG)

+

+

+

Terminnologies in SFG

+

Node, Transfer function, Branch(The branch gain is the transfer function), Source node, Sink node, Mixed node.

+

Properties of SFG

+
    +
  1. Signal only passes through a branch with the direction indicated by the arrowhead.
  2. +
  3. Signals of incoming branches are added at a node, and the added signal appears on the all outgoing branches.
  4. +
  5. A sink node can be separated from a mixed node.
  6. +
  7. For a given system, the SFGs can be different.(equations for a system can be different)
  8. +
  9. After the SFG being inversed, the transfer function keeps invariant, but the signals represented by the inner nodes will be different.
  10. +
+

Note: Inversion is done by inversing the transfer direction of each branch, and exchanging the source and sink nodes as well.

+

Algebra of SFG

+

+

+

Simplify:

+

NOTE: The SFG can be simplified using the following steps:

+

a. Merge the cascaded branches to decrease the number of nodes;

+

b. Merge the parallel branches to decrease the number of branches;

+

c. Eliminate all the loops.

+

Then, the system function can be readily derived.

+

+

Mason’s Formula

+
$$ +H = \frac{1}{\Delta} \sum_k g_k\Delta_k +$$
+![](../images/ss/lec21_9.jpg) + +

State-variable analysis of system

$$ +\mathbf {\lambda = A\lambda + Be}\\ +\mathbf{r = C\lambda + De} +$$
+ +

Features of the state-variable analytical method

+
    +
  • (1)Provide internal characteristics of the system
  • +
  • (2) Convenient to represent and analyze the multi-input, multi-output (MIMO) cases
  • +
  • (3) Easy to be extended to time-variant or nonlinear cases
  • +
  • (4) Introduce two important concepts: controllability and observability
  • +
  • (5) Convenient for numerical computation
  • +
+

General form and setup method (CT)

$$ +\frac{d}{dt}\mathbf{\lambda}(t)_{k \times 1} = \mathbf{A}_{k \times k}\mathbf{\lambda}(t)_{k \times 1} + \mathbf{B}_{k \times m}\mathbf{e}(t)_{m \times 1}\\ +\mathbf{r}(t)_{r \times 1} = \mathbf{C}_{r \times k}\mathbf{\lambda}(t)_{k \times 1} + \mathbf{D}_{r \times m}\mathbf{e}(t)_{m \times 1} +$$
+ +

$r$ responses, $k$ state variables, $m$ inputs.

+

For time-variant system, $\mathbf{A, B, C, D}$ are fuction of $t$.

+

Direct methods:

+
    +
  • observation
  • +
  • Topological analysis
  • +
+

Used in curcuit analysis.

+

Indirect methods:

+
    +
  • From block diagram or flow graph
  • +
  • From input-output equation
  • +
  • From transfer function
  • +
+

Used in controlled system analysis.

+

From input-output equation

+
$$ +\frac{r(t)}{e(t)} = \frac{b_0p^k + \dotsb + b_k}{p^k + \dotsb + a_k} +$$
+ +

NOTE : under the zero-state condition, $p$ is equivalent to $s$

+
$$ +H(p) = \frac{b_0 + b_1p^{-1} + \dotsb + b_kp^{-k}}{1 + a_1p^{-1} + \dotsb + a_kp^{-k}} +$$
+ +

The SFG is:

+

+
$$ +\dot{\lambda}_1 = \lambda_2\\ +\dot{\lambda}_2 = \lambda_3\\ +\vdots\\ +\dot{\lambda}_k = -a_k\lambda_1 - a_{k-1}\lambda_2 - \dotsb - a_1\lambda_k + e(t)\\ +r(t) = b_k\lambda_1 + b_{k-1}\lambda_2 + \dotsb + b_1\lambda_k + b_0(-a_k\lambda_1 - a_{k-1}\lambda_2 - \dotsb - a_1\lambda_k + e(t))\\ +=(b_k - a_kb_0)\lambda_1 + (b_{k-1} - a_{k-1}b_0)\lambda_2 + \dotsb + (b_1 - a_1b_0)\lambda_k + b_0e(t) +$$
+ +
$$ +\mathbf A = \begin{bmatrix} + 0 & 1 & 0 & \dotsb & 0\\ + 0 & 0 & 1 & \dotsb & 0\\ + \vdots & \vdots & \vdots & \ddots & \vdots\\ + 0 & 0 & 0 & \dotsb & 1\\ + -a_k & -a_{k-1} & -a_{k-2} & \dotsb & -a_1 +\end{bmatrix}\\ +B = \begin{bmatrix} + 0\\ + 0\\ + \vdots\\ + 0\\ + 1 +\end{bmatrix}\\ +\mathbf C = \begin{bmatrix} + b_k - a_kb_0 & b_{k-1} - a_{k-1}b_0 & \dotsb & b_1 - a_1b_0 +\end{bmatrix}\\ +D = b_0 +$$
+ +

If the order of differential equation on the left side is higher than that on the right side:

+
$$ +b_0 = 0, \mathbf{D} = 0 +$$
+ +

If the derivatives of the excitation on the right side are absent,

+
$$ +\mathbf{C} = [b_k, 0, \dotsb, 0], \mathbf{D} = 0 +$$
+ +

Factorizing Transfer operator

+

+

+

+

+

+

+

+

Solving CT system’s state equations

Time domain method using computer.

+

Transform-domain(Laplace-tranform) method

+
$$ +\frac{d}{dt}\mathbf{}{\lambda}(t) = \mathbf{A\lambda}(t) + \mathbf{Be}(t)\\ +\mathbf{r}(t) = \mathbf{C\lambda}(t) + \mathbf{De}(t)\\ +\mathbf{\lambda}(0_-) = \begin{bmatrix} +\lambda_1(0_-)\\ +\lambda_2(0_-)\\ +\vdots\\ +\lambda_k(0_-)\\ +\end{bmatrix} +$$
+ +
$$ +s\mathbf \Lambda(s) - \mathbf{\lambda}(0_-) = \mathbf{A\Lambda}(s) + \mathbf{BE}(s)\\ +\mathbf{R}(s) = \mathbf{C\Lambda}(s) + \mathbf{DE}(s) +$$
+ +
$$ +\mathbf{\Lambda}(s) = (s\mathbf {I} - \mathbf{A})^{-1}\mathbf{\lambda}(0_-) + (s\mathbf {I} - \mathbf{A})^{-1}\mathbf{BE}(s)\\ +\mathbf R(s) =\mathbf{C} (s\mathbf {I} - \mathbf{A})^{-1}\mathbf{\lambda}(0_-) + (\mathbf C(s\mathbf {I} - \mathbf{A})^{-1}\mathbf{B + D)E}(s) +$$
+ +

Let $\Psi(s) = (s\mathbf I - \mathbf A)^{-1}$, which is called characteristic matrix.

+
$$ +\mathbf\lambda(t) = \mathcal{L}^{-1}[\Psi(s)\lambda(0_-)] + \mathcal{L}^{-1}[\Psi(s)\mathbf{B}] * e(t)\\ +\mathbf r(t) = \mathbf{C}\mathcal{L}^{-1}[\Psi(s)\lambda(0_-)] + \lbrace\mathbf{C}\mathcal{L}^{-1}[\mathbf\Psi(s)\mathbf{B] + D}\delta(t)\rbrace * e(t) +$$
+ +

Time-domain method

+
$$ +e^{\mathbf At} = \sum_{k = 0}^\infty \frac{1}{k!}A^kt^k +$$
+ +

properties

+
$$ +e^{\mathbf At}e^{-\mathbf At} = \mathbf I\\ +e^{\mathbf At} = [e^{-\mathbf At}]^{-1}\\ +\frac{d}{dt}e^{\mathbf At} = \mathbf Ae^{\mathbf At} = e^{\mathbf At} \mathbf A\\ +$$
+ +
$$ +\frac{d}{dt}\mathbf \lambda(t) = \mathbf A\mathbf \lambda(t) + \mathbf B\mathbf e(t)\\ +e^{-\mathbf At}\frac{d}{dt}\mathbf \lambda(t) = e^{-\mathbf At}\mathbf A\mathbf \lambda(t) + e^{-\mathbf At}\mathbf B\mathbf e(t)\\ +\frac{d}{dt}e^{-\mathbf At}\mathbf \lambda(t) = e^{-\mathbf At}\mathbf B\mathbf e(t)\\ +\lambda(t) = e^{\mathbf At}\mathbf \lambda(0_-) + \int_0^te^{\mathbf A(t - \tau)}\mathbf B\mathbf e(\tau)d\tau\\ +=e^{\mathbf At}\lambda(0_-) + e^{\mathbf At} \mathbf B * \mathbf e(t) +$$
+ +

output

+
$$ +\mathbf r(t) = \mathbf C e^{\mathbf At}\mathbf \lambda(0_-) + \mathbf C e^{\mathbf At} \mathbf B * \mathbf e(t) + \mathbf D\mathbf e(t)\\ += \mathbf C e^{\mathbf At}\mathbf \lambda(0_-) + [\mathbf C e^{\mathbf At} \mathbf B + \mathbf D\delta(t)] * \mathbf e(t) +$$
+ +

Correspond to LT:

+
$$ +\mathcal{L}[e^{\mathbf At}] = (s\mathbf I - \mathbf A)^{-1} +$$
+ +

Derive System Functions

+

+

+

That for DT system

State equation setup

+
$$ +\begin{align*} + \mathrm\lambda(n + 1) &= \mathbf A\mathrm\lambda(n) + \mathbf B\mathrm x(n)\\ + \mathrm y(n) &= \mathbf C\mathrm\lambda(n) + \mathbf D\mathrm x(n) +\end{align*} +$$
+ +

Solving:

+
$$ +\lambda(n) = \underbrace{A^n\lambda(0)u(n)}_{\text{Zero Input}} + \underbrace{\left[\sum_{i=0}^{n-1}A^{n-1-i}Bx(i)\right]u(n-1)}_{\text{Zero State}}\\ +y(n) = \underbrace{CA^n\lambda(0)u(n)}_{\text{Zero Input}} + \underbrace{\left[\sum_{i=0}^{n-1}CA^{n-1-i}Bx(i)\right]u(n-1) + Dx(n)u(n)}_{\text{Zero State}} +$$
+ +

The Impulse response is:

+
$$ +h(n) = CA^{n-1}Bu(n-1) + D\delta(n) +$$
+ +

Calculate $A^n$: Cayley-Hamilton Theorem

+

ZT Solution

+
$$ +\begin{align*} + z\mathrm\Lambda(z) - z\lambda(0) &= \mathbf A\mathrm\Lambda(z) + \mathbf B\mathrm X(z)\\ + \mathrm Y(z) &= \mathbf C\mathrm\Lambda(z) + \mathbf D\mathrm X(z) +\end{align*} +$$
+ +
$$ +\mathrm \Lambda(z) = (z\mathbf I - \mathbf A)^{-1}\lambda(0) + (z\mathbf I - \mathbf A)^{-1}\mathbf B\mathrm X(z)\\ +\mathrm Y(z) = \mathbf C(z\mathbf I - \mathbf A)^{-1}\lambda(0) + \left[\mathbf C(z\mathbf I - \mathbf A)^{-1}\mathbf B + \mathbf D\right]\mathrm X(z) +$$
+ +

then

+
$$ +\lambda(n) = \mathcal{Z}^{-1}\left[(z\mathbf I - \mathbf A)^{-1}z\right]\lambda(0) + \mathcal{Z}^{-1}\left[(z\mathbf I - \mathbf A)^{-1}\mathbf B\right] * \mathcal{Z}^{-1}\left[\mathrm X(z)\right]\\ +y(n) = \mathcal{Z}^{-1}\left[\mathbf C(z\mathbf I - \mathbf A)^{-1}z\right]\lambda(0) + \mathcal{Z}^{-1}\left[\mathbf C(z\mathbf I - \mathbf A)^{-1}\mathbf B + \mathbf D\right] * \mathcal{Z}^{-1}\left[\mathrm X(z)\right] +$$
+ +

Comparing this with CT solution, we find

+
$$ +A^n = \mathcal{Z}^{-1}\left[(\mathbf I - z^{-1}\mathbf A)^{-1}\right]\\ +$$
+ +
$$ +H(z) = C(\mathbf I - z^{-1}\mathbf A)^{-1}\mathbf B + D +$$
+ +

Linear Transform on state vectors

$$ +\mathbf{\gamma} = \mathbf P\mathbf \lambda +$$
+ +

The equations become:

+
$$ +\frac{d}{dt}\gamma(t) =\mathbf{PAP}^{-1}\mathbf \gamma(t) + \mathbf{PB}e(t)\\ +\mathbf y(t) = \mathbf {CP}^{-1}\gamma(t) + \mathbf D\mathbf e(t) +$$
+ +

Similarity transform doesn’t change the eigenvalues.

+

Transform function matrix keeps invariant under linear transformation.

+

We can diagonalize the matrix A.

+

Calculate eigenvalues $\alpha$ -> calulate eigenvectors $\xi$ -> $\mathbf P^{-1} = [\xi_i]$, $\hat A = \text{diag}(\alpha_i)$

+

Controllable & Observable

Controllable is

+
$$ +\text{rank} [A\ AB\ \dots\ A^{k-1}B] \text{ is full} +$$
+ +

Uncontrollabilty is the input can’t change the response.

+

Obeservability is

+
$$ +\text{rank} \begin{bmatrix} + C\\ + CA\\ + \vdots\\ + CA^{k-1} + \end{bmatrix} + \text{ is full} +$$
+ +

Unobserverbility is the response is not affected by the input.

+

After the diagonalization of A:

+

B doesnt contain zero $\Leftrightarrow$ completely controllable. Otherwise, the 0s is coresponding to the uncontrollable state variables.

+

C doesnt contain zero $\Leftrightarrow$ completely observable. Otherwise, the 0s is coresponding to the unobservable state variables.

+

In fact:

+
$$ +H(s) = C(s\mathbf I - \mathbf A)^{-1}\mathbf B + D \stackrel{D = 0}{=} \sum_{i=1}^n \frac{C_iB_i}{s - \alpha_i} +$$
+ +

The $H(s)$ only contains the controllable and observable state variables. So the state and output equations contains more information than the $H(s)$.

+

+

CDMA

Use a set of orthogonal codes to support multiple users by orthorgonal multiplexing.

+

Example

Assume K users need to connect with the base station simultaneously for CDMA system.

+
    +
  1. Design a set of orthogonal codes
  2. +
  3. Design on the transmitter
  4. +
  5. Design on the receiver
  6. +
+

An example of Code 4:

+
$$ +\begin{align*} + \mathbf c_1 &= [1\ 1\ 1\ 1\ -1\ -1\ -1\ -1]\\ + \mathbf c_2 &= [1\ 1\ -1\ -1\ 1\ 1\ -1\ -1]\\ + \mathbf c_3 &= [1\ -1\ 1\ -1\ 1\ -1\ 1\ -1]\\ + \mathbf c_4 &= [1\ -1\ -1\ 1\ 1\ -1\ -1\ 1] +\end{align*} +$$
+ +
$$ +R_{x, y}(j) = \begin{cases} + \sum_{k = 0}^{N - 1 - j} x(k)y(k + j), &0 \le j \le N - 1\\ + \sum_{k = 0}^{N - 1 + j} x(k - j)y(k), &-N + 1 \le j \le 0\\ + 0, & |j| \ge N +\end{cases} +$$
+ +

Must satisfy:

+
$$ +R_{k, i} \begin{cases} + =T, &k = i, \tau=0\\ + \ll T, &k \ne i \text{ or } \tau \ne 0 + \end{cases} +$$
+ +

second:

+

(1) frequency shifting: $d_k(t)\cos(\omega t)$

+

(2) spreading: $s_k(t) = d_k(t)c_k(t)\cos(\omega t)$

+

third: coherent detection/de-spreading

+

Core:

+
    +
  • Orthogonal code design(signal design)
  • +
  • Code capturing and tracking(signal processing and system design)
  • +
  • Multi-use detection and channel estimation(singal processing and system design)
  • +
+

Code design

requirements:

+
    +
  • sharp auto-correlation curve
  • +
  • zero cross-correlation
  • +
  • largest possible orthogonal code set
  • +
  • highest possible complexity for security performance
  • +
+

Commonly used codes:

+
    +
  • Walsh code
  • +
  • PN sequence
  • +
  • GOLD codes
  • +
+
$$ +H_1 = (0)\\ +H_2 = \begin{pmatrix} + H_1 & H_1\\ + H_1 & \overline{H_1} +\end{pmatrix} = \begin{pmatrix} + 0 & 0\\ + 0 & 1 +\end{pmatrix}\\ +H_4 = \begin{pmatrix} + H_2 & H_2\\ + H_2 & \overline{H_2} + \end{pmatrix} +$$
+ +
    +
  • sliding window capturing
  • +
  • multiple correlators to detect phase match
  • +
+

The period of address code is much shorter than the period of data code: $T_c < T_d$, so the modulated signal is much wider in FD, whose spectrum is called spread spectrum.

+
\ No newline at end of file diff --git "a/2023/02/27/\346\225\260\351\200\273/index.html" "b/2023/02/27/\346\225\260\351\200\273/index.html" new file mode 100644 index 00000000..c3a76148 --- /dev/null +++ "b/2023/02/27/\346\225\260\351\200\273/index.html" @@ -0,0 +1,918 @@ +数逻 | Guo_Yun + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

数逻

Introduction

Boolean Algebra

The Number System

BCD

BCD (Binary-Coded Decimal)

+

Classic method: 8421BCD.

+

add calculation:

+

the problem of carry:

+
$$ +(14)_D+(28)_D=(0001\ 0100)_{BCD} + (0100\ 0100)_{BCD}\\ +=(0101\ 1100)_{BCD}=(0110\ 0010)_{BCD} +$$
+ +

Gray Code

used in logic simplification and signal transmission.

+

every time a single bit is changed.

+

Floating poing Number

Negative numbers

Complement Numeric System

+

1’s Complement: $N_{1’s} + (-N){1’s} = (111…){1’s}$, or just inverting every bit of N. Low space efficiency and difficult to compute.

+

2’s Complement: $N_{2’s} + (-N){2’s} = (000…){2’s}$, or just inverting every bit of N and plus 1. A shift on 1’s Complement.

+

MSB=Most significant bit, LSB=Least significant bit.

+
$$ +-N=N_{us}-2^n=\sum_{i=0}^{n-1}k_i2^i-2^n=-k_{n-1}2^{n-1}+k_{n-2}2^{n-2}+\dots k_02^0 +$$
+ +

So just set the weight of MSB to $-2^{n-1}$.

+

we ignore the bit beyond the range to make sure the answer is correct.

+
$$ +(101)_{2's}+(001)_{2's}=(110)_{2's}\\ +(011)_{2's}-(001)_{2's}=(011)_{2's}+(111)_{2's}=(010)_{2's} +$$
+To detect an overflow, we can notice if 2 positive numbers add up to a negative numbers or 2 negative numbers add up to a positive numbers. + +

We can fix overflow by adding 0 as MSB if the answer should be positive and adding 1 as MSB if the answer should be negative.

+

Boolean expression

Definition

$$ ++(\text{OR/logic add}),\cdot (\text{AND/logic multiply}), \prime(\bar{})(\text{NOT/logit NOT}) +$$
+ +

Boolean function

Duality

+

AND<->OR, 0<->1, variables unchanged.

+
$$ +F_1=F_2\Leftrightarrow F_1^D=F_2^D +$$
+ +

De Morgan’s Law

+

AND<->OR, 0<->1, X<->X’

+

Useful Theorem

+

X(Y+Z)=XY+XZ

+

XY+Z=(X+Z)(Y+Z)

+

X+XY=X

+

X(X+Y)=X

+

Boolean function simplification

2-level logic

Standard form
SOP and POS

+

Sum of Products or Products of Sum

+

Min-term
A min-term is a product of all variables taken either in the direct or complemented form, each variable shown once.

+

$A’B’C’=m_0$ and $ABC=M_7$

+

Max-term A max-term is a sum of all variables taken either in the direct or complemented form, each variable shown once.

+

$A+B+C=M_0$ and $A’+B’+C’=M_7$

+
$$ +m_6= \overline{M_6} +$$
+ +

Karnaugh Maps

+

Use row and columns to represent combinations of the inputs(by min-terms), the cell to represent the value. The inputs is ordered by the sequence of Grey Code.

+

Simplification of 2-level logic

Karnaugh Maps method

+

If two adjacent min-terms deliver logic 1, merge them.

+

Implicant

+
$$ +G\Rightarrow F, \text{then }G\text{ is the implicant of }F\\ +no\ Q\ s.t.P\Rightarrow Q\Rightarrow F, \text{then }P \text{ is the prime implicant of }F\\ +\text{If one min-term can only be covered by one prime implicant, this prime implicant is an EPI.} +$$
+ +

EPI will finally exist there.

+

Q-M method

+

algorithm to simplify multiple-input large-scale function.

+

Combinational Logic

Gate

NAND, NOT, NOR is better than AND, OR in saving area.

+

Transmission Gate Use both NMOS and PMOS to form a CMOS switch. NMOS is good at transmitting low volt while PMOS is better at working on high volt.

+

Tri-state Gate EN is high, TG on, F=A; EN is low, TG off, F is isolated from input A. The states are called logic 0, logic 1 and high-resistance Z.

+

+

The bottom part of the circuit is used to avoid the high-Z state.

+

Combinational logic circuits

Outputs are the function of logic input circuits.

+

Determined only by current not past inputs + delay

+

To deal with complex logic with many inputs, we should:

+
    +
  • From 2-level to multi-level(BDD?)
  • +
  • Divide-and-conquer
  • +
  • Re-using
  • +
+

Metrics

Static metrics Logic voltage values, DC noise margins, Area, Fan-out

+

Dynamic metrics Speed/delay, Power dissipation, Noise(reference)

+

Speed rise time and fall time. Propagation time.

+

Fan out The maximum number of CMOS inputs that one logic output can drive.

+

Power and energy Leakage power(static power): subthreshold leakage power, gate leakage, D/S subtrate leakage. We can reduce the static power:

+
    +
  • increase $|V_{TH}|$
  • +
  • or decrease $V_{DD}$.
  • +
+
$$ +P_{total} = P_{dynamic} + P_{dynamic\_short} + P_{leakage} +$$
+ +

Dynamic power $P_{dynamic_short}$ shows in pull-up and pull-down on.

+
$$ +P = C_LV_{DD}^2\underset{\text{Flip Prob.}}{\alpha_{0-1}}f +$$
+ +

To reduce dynamic power:

+
    +
  • Reduce VDD and Capacitors
  • +
  • Reduce frequency, flipping probability.
  • +
+

Energy-delay product is a metric. It’s hard to reduce.

+
    +
  • Low power can increase the lifetime of the chip.
  • +
  • Low delay can increase the speed of the chip.
  • +
+

Hazard

static-1 hazard ‘1’ output has a transient ‘0’ glitch

+

static-0 hazard ‘1’ output has a transient ‘0’ glitch

+

dynamic hazard several transitions during a single output change(not required)

+

If the initial input and final input cannot be covered by one PI, it may have a glitch as state transition.

+

Basic comb. logic circuits

Encoder: inputs are more, outputs are less($n \le 2^m$)

+

Decoder: inputs are less, outputs are more($m = 2^n$)

+

Multiplexer: From several inputs, choose one as output according to the address inputs. It can be used to make a shift register. We can use n-bit-addr MUX for m-bit function.

+

Adder: Half adder & full adder.

+

Half Adder: $S = A \oplus B$

+

Full adder: $C_{out} = A\cdot C_{in} + B\cdot C_{in} + A\cdot B, S = A\oplus B\oplus C_{in}$

+

Implements of Full Adder:

+

Serial Adder $C_{i+1} = A_iC_i+B_iC_i + A_iB_i$. The latency is disastrous.

+

Carry Lookahead Adder(CLA)

+

First define $P_i = A_i\oplus B_i, G_i = A_iB_i$, P means Carry-bit propagation, G means Carry-bit Generation. Thus, $C_{i+1} = G_i + P_iC_i, S_i = A_i\oplus B_i\oplus C_i = P_i\oplus C_i$. Thus the $C_i$ can be replaced:

+
$$ +C_1 = G_0+P_0C_0\\ +C_2 = G_1 + P_1(G_0+P_0C_0) = G_1 + P_1G_0+P_1P_0C_0\\ +C_3 = G_2 + P_2(G_1 + P_1G_0+P_1P_0C_0) = G_2 + P_2G_1 + P_2P_1G_0+P_2P_1P_0C_0\\ +C_4=G_3+P_3(G_2 + P_2G_1 + P_2P_1G_0+P_2P_1P_0C_0)=G_3+P_3G_2 + P_3P_2G_1 + P_3P_2P_1G_0+P_3P_2P_1P_0C_0 +$$
+ +

A 4-bit CLA can be designed using these formulas. For more, it is too complex. However, we can cascade the 4-bit CLA to reach the balance of latency and complexity.

+

Moreover, here comes the parallel intra- and inter-group CLA which regards the 4-bit adder as a block and defines its $P_i$ and $G_i$, connecting the 4-bit adders in a similar manner as the structure of 4-bit adder inside.

+

Sequential logic

+

Clock

    +
  • Ring Oscillator
  • +
  • LC oscilator
  • +
  • Crystal Oscillator
  • +
+

State and FSM

States contain all needed infomation. could be redundant.

+

Finite State Machine(FSM) The number of input, output and states are finite.

+

Mealy FSM:

+

+

Moore FSM:

+

+

We describe the FSM by State Transition Table or State Diagram.

+

+

+

Remember: Moore is less.

+

Latch

Watch the input at the duration clock enables.

+

Examples

SR latch

+

+

$SR=0$ is required.

+
$$ +Q^+=S+R^\prime Q +$$
+ +

A gated version:

+

+
$$ +Q^+=C^\prime Q + C(S+R^\prime Q) +$$
+ +

D latch

+

+
$$ +Q^+=D +$$
+ +

Transimission Gate version

+

+

Timing parameters

+

+

Flip-Flop

Watch the input only at the moment when clock signal rises or falls.

+

Examples

D Flip-flop(DFF)

+

+

2 D latches in series with opposite clock.

+

Use the delay to help us

+

The delay of NOT gate at the bottom enables the slave to lock first and the master to unlock second when clock falls.

+

Also, the delay of NOT gate at the bottom makes $t_h=0$.

+

+

Two time constraints

+

Set-up time constraints: restrict the clock cycle.

+

+

$t_{logic}(max)$ is also called propagation delay $t_{dab}$.

+

Hold time constraints: restrict the $t_d$

+

+

$t_{logic}(min)$ is also called contamination delay($t_{cab}$).

+

4 types of FF

+

+

+

Characteristic equations

+
$$ +Q^+=D\\ +Q^+=T\overline Q + \overline{T}Q\\ +Q^+=S+\overline{R}Q\\ +Q^+=J\overline{Q}+\overline{K}Q +$$
+ +

Problems

Can $t_h$ be negative?

+

setup-and-hold-time

+

How to convert FF?

+

https://blog.csdn.net/qq_43975016/article/details/121193168

+

Analyzing Sequential Logic

Function Analysis

+

+

State Transistion Table

+

+

+

+

+

+

Opt.2 is different and needed to be thought carefully. The x and s in $g(x, s)$ may not be caused by same x.

+

Time Constraint

+

Designing Sequential Logic

Step 1 Determine the input, output and state

+

+

Here, Moore is more in FSM states.

+

Step 2 State simplification

+

2 methods: row matching & implication chart

+

row matching: $P\equiv Q$ iff. outputs and next states are same.

+

We can use implication table to optimize the row matching method.

+

+

+

Step 3 State allocation/representation

+

+

Many methods:

+

+

Next state and input/output based criteria

+

Highest Priority:

+

Same input and same next state should be encoded adjacently.

+

+

Medium Priority:

+

Next states of the same state should have adjacent
encoding.

+

+

Lowest Priority:

+

States with the same output should have adjacent
encoding.

+

+

Step 5 Get Excitation and Output Equations

+

+

Step 6 Draw Logic Circuit Diagram

+

Typical Sequential Logic Circuits

Register & Counter

+

Register

+

Shift register. Serial/Parallel Input, Serial/Parallel Output.

+

+

+

+

Counter

+

UP/Down Counter

+

+

Specific-base Counter

+

000→010→011→101→110→000

+

+

Self-Starting problem of counter

+

Abnormal state(001, 100, 111)

+

+

Ring counter & twisted ring counter

+

+

+

Async & snyc Counter

+

+

+

+

Instruction Set Architecture

Introduction

Implement Algorithm In Hardware

+

Three steps:

+
    +
  • Instruction fetch
  • +
  • Instruction decoding
  • +
  • Instruction execution & data write-back
  • +
+

Program Counter(PC)

+

Current Instruction Address

+

Updated Every Cycle

+

Arithmetic/Logic Instructions

+

Arithmetic Logic Unit(ALU)

+

REG to REG, NOT Directly access data memory

+

Branch/Jump Instructions

+

Branch After Comparison

+

Jump Directly

+

Load/Store Instructions

+

Load Data: data memory to REG

+

Store Data: REG to data memory

+

General Purpose Processore Structure

Turing Machine

+

2 Turing Machine Models:

+
    +
  • Princeton architecture
  • +
  • Harvard architecture
  • +
+

+

Program FLow

+

+

Instruction Set Design

Instruction set is the bridge between software & generall-purpose (GP) CPU.

+

Performance Evaluate

+
$$ +\text{Performance} = \frac{1}{\text{Execution Time}} +$$
+ +

Task Execution Time By CPU:

+
$$ +\text{Total Time} = \text{Waiting for I/O} + \text{Execution Time}\\ +\text{Execution Time} = \text{Cycle }\# \times \text{Clock Cycle }T = \frac{\text{Cycle }\# }{\text{Clock }f} +$$
+ +
$$ +\text{Cycle } \# = \text{Progream Instruction }\# \times \text{Average Cycle } \# \text{ for one inst.} +$$
+ +

Average Cycle # for one instruction is also known as the cycle per instruction (CPI)

+

So,

+
$$ +\text{Execution Time} = \text{Instruction }\# \times \text{CPI} \times \text{Clock Cycle } +$$
+ +

CPI

+
$$ +\text{CPI} = \sum_{i = 1}^n \text{CPI}_i \times \text{P}_i +$$
+ +

Where $\text{P}_i$ is the i-th instruction occurrence frequency, and $\text{CPI}_i$ is the clock cycle # of the i-th instruction.

+

Factors that affect Performance

+
    +
  • Instruction #
  • +
    • +
    • ISA, regardless of its specific implementation
    • +
    +
  • +
    • +
    • Compiler
    • +
    +
  • +
  • CPI
  • +
    • +
    • Memory System and Processor Architecture
    • +
    +
  • +
    • +
    • The Instruction Composition In the Program
    • +
    +
  • +
    • +
    • Compiler
    • +
    +
  • +
  • Clock Cycle
  • +
    • +
    • Machine implementation details
    • +
    +
  • +
    • +
    • Memory System and Processor Architecture
    • +
    +
  • +
+

+

Data Access

+

+

+

Set Design

+

RISC & CISC

+

+

+

Five Questions

+
    +
  • How to make use of 11 extra bits in arithmetic operations?
  • +
  • How to use 16 bits to represent 32-bit address for branch?
  • +
  • How to encode branch instruction with immediate?
  • +
  • How to use 21 bits to represent 32-bit address for memory address?
  • +
  • How to use 26 bits to represent 32-bit address for jump?
  • +
+

MIPS Instruction Set

Instruction Storage and Data Storage

32-bits instruction length, and 32 general-purpose registers.

+

First 6 bits are opcode.

+

Register

+

+

the register index is limited to 5 bits.

+

Instruction Type(R, I, J)

Type: R

+

Field Division and detailed definition

+

+

Q1: Can we make use of the extra 11 bits?

+

+

Type: I

+

It’s immediate.

+

+

2 cases:

+

+

+

Q2:The possible address range covers 32 bits. How to represent the address with limited 16 bits for branch?

+

base + offset

+

+

Q3: How to encode the branch with immediate?

+

No direct instructions for this.

+

We use compare instruction and branch instruction to achieve this.

+

Q4: The possible address range covers 32 bits. How to represent the address with limited 21 bits for memory access?

+

base + offset

+

+

Type: J

+

+

Q5: The possible address range covers 32 bits. How to represent
the address with limited 26 bits for jump?

+

3 types of jump operation: j, jal and jr.

+

+

Summary

+

+

Addressing mode

5 modes:

+
    +
  • Register addressing
  • +
  • Immediate addressing
  • +
  • Base (base-offset) addressing
  • +
  • PC-related addressing
  • +
  • Pseudo-direct addressing
  • +
+

Register addressing

+

+

Immediate addressing

+

+

How to load a 32-bit constant to $s0?

+

+

Base-offset addressing

+

+

PC-related addressing

+

+

+

Pseudo-direct addressing

+

+

It is faster because no add operation needed, comparing to PC_new = {PC_old + address << 2}.

+

Summary

+

+

Instruciton System

Arithmetic

+

Add add $t0, $t1, $t2 #$t0=$t1+$t2

+

Add immediate addi $t2, $t3, 5 #$t2=$t3+5

+

Subtract sub $t2,$t3,$t4 #$t2=$t3-$t4

+

NO subtract-an-immediate instruction! We use 2’s complement immediate in the addi.

+

Logic

+
1
2
3
4
and $t0, $t1, $t2
or $t0, $t1, $t2
xor $t0, $t1, $t2
nor $t0, $t1, $t2
+ +

No NOT instruction. We set $t1 or $t2 to 0 and use NOR.

+

With immediate:

+
1
2
3
andi $t0, $t1, 10
ori $t0, $t1, 10
xori $t0, $t1, 10
+ +

Shift

+

Immediate-amount shift:

+
1
2
3
4
5
6
sll $t0, $t1, 10
# $t0 = $t1 << 10, logical
srl $t0, $t1, 10
# $t0 = $t1 << 10, logical
sra $t0, $t1, 10
# $t0 = $t1 >> 10, arithmetic, depending on the sign bit
+ +

Register-amonut shift:

+
1
2
3
4
5
6
sllv $t0, $t1, $t3
# $t0 = $t1 << ($t3%32), logical
srl $t0, $t1, $t3
# $t0 = $t1 << ($t3%32), logical
sra $t0, $t1, $t3
# $t0 = $t1 >> ($t3%32), arithmetic, depending on the sign bit
+ +

Compare instruction

+
1
2
3
4
5
slt $t1, $t2, $t3
# if ($t2 < $t3) $t1=1;
# else $t1=0
sltu $t1, $t2, $t3
# unsigned comparison
+ +

With immediate:

+
1
2
slti $t1, $t2, 10
sltui $t1, $t2, 10
+ +

About i, u, iu

+

+

Load/Store Instruction

+
1
2
lw $t1, 32($t2)
sw $t3, 500($t4)
+ +

Register stores base address is called base register,
Constant in the instruction is called offset.

+

Branch instruction

+
1
2
3
4
5
6
beq $t0, $t1, target
#if $t0=$t1, then execute
#instruction target
bne $t0, $t1, target
# if $t0!=$t1, then execute
# instruction target
+ +

More than this 2 instructions.

+

Jump instruction

+

Unconditional branch

+
1
2
j label
#unconditionally jump to label
+ +

Procedure Call

+

MIPS uses registers for argument and return data/address.

+

Argument registers: $a0-$a3

+

Return value registers: $v0-$v1

+

Retuen address register: $ra

+

jal Procedure #Procedure call jr $ra #Procedure return

+

jal and j are both J-type, but jal will store the return address.

+

jr is R-type, will jump to the address restored in the register, so it can jump very far.

+

Maintain the register data

+

2 types:

+
    +
  • Temporaries data registers
  • +
  • Saved data registers
  • +
+

+

Who saves the register data?

+

Caller(temp) or Callee(save)

+

+

We use Stack to maintain the register data.

+

+

Stack Operation with $sp

+

e.g. push $s1, $s2 , $s3

+
1
2
3
4
addi $sp, $sp, -12
sw $s1, 8($sp)
sw $s2, 4($sp)
sw $s3, 0($sp)
+

pop $s1, $s2, $s3

+
1
2
3
4
lw $s1, 0($sp)
lw $s2, 4($sp)
lw $s3, 8($sp)
addi, $sp, $sp, 12
+ +

Leaf Procedures

+

Procedures that do not call others are called leaf procedures.

+

Nested Procedures

+

Nested(Recursive) Procedures are procedures that invoke “clones” of themselves.

+

e.g.

+
1
2
3
4
int fact (int n) {
if (n < 1) return 1;
else return (n * fact(n - 1));
}
+ +
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
fact:
addi $sp, $sp, -8
sw $ra, 4($sp)
sw $a0, 0($sp)
slti $t0, $a0, 1
beq $t0, $zero, L1
addi $v0, $zero, 1
addi $sp, $sp, 8
jr $ra
L1:
addi $a0, $a0, -1
jal fact
lw $a0, 0($sp)
lw $ra, 4($sp)
addi $sp, $sp, 8
mul $v0, $a0, $v0
jr $ra
+ +

Single-Cycle Processor

+

+

+

+

+

+

+

Load Operation Takes MUCH LONGER!!!

+

Multi-Cycle Processor

+

The Multicycle processor processes different inst. in different cycles. Thus, it can avoid the time limitation by the slow instruction.

+

Modules on th datapath can be used multiple times within an inst. That is Module reuse.

+

Performance improvement depends on the detailed delay. The multicycle is not necessarily faster than the single cycle.

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

Exception and Interrupt

+

Generally, exceptions and interrupts are events that can change the normal instruction execution flow (other than branches and jumps).

+

Exception
– Internal unpredictable events such as overflow.

+

Interrupt
– External unpredictable events such as I/O.

+

+

+

+

+

+

+

+

Pipelined processor

+

Pipeline means spatial and temporal reuse.

+

Divide a complex task into several sub-tasks to
execute sequentially, and assign each sub-task to
dedicated hardware

+

Different sub-tasks of multiple tasks can be
processed simultaneously to improve the
performance

+

• Time-division multiplexing: the same resource is reused through
different cycles

+

• Space-division multiplexing: multiple resources are reused
within one cycle

+

Pros: improved efficiency

+

Cons: Some inst. depends on the former inst.. However, the former inst. has not finished yet, if the prediction of branch is wrong, time is wasted.

+

Instruction-Level Parallelism (ILP)

+

– Execute multiple instructions in parallel

+

– One mainstream approach to CPU performance improvement

+

Basic Techniques

+

– Pipelining: instruction execution is divided into several stages, and
each stage can be processed with the other stages (of other
instructions) simultaneously

+

– Superscalar: multiple dedicated functional units are equipped so
that CPU can receive & execute more instructions within one cycle.

+

– Very Long Instruction Word (VLIW): each instruction consists of
multiple segments to utilize the processor resources independently.

+

5 stages in MIPS:

+
    +
  1. Instruction Fetch (IF)
  2. +
  3. Instruction Decode / Register File
  4. +
  5. ALU Execution(EX)
  6. +
  7. Memory Data Access(MEM)
  8. +
  9. Reg Write-Back(WB)
  10. +
+

Latency of the stages in the pipeline should
be as equivalent as possible, why?
–The pipeline performance is bottlenecked by the stage
of the longest latency

+

Metrics of pipelined processors

+
    +
  • Throughput(TP): Executed instruction # per unit time
  • +
  • Max throughput: The throughput of a steady-state pipeline with a continuous instruction input stream
  • +
  • Real throughput: The throughput of the pipeline executing task with finite instructions
  • +
+

Real TP:

+
$$ +TP = \frac n {T_k} = \frac{n}{(n+k-1)\Delta t} +$$
+ +

Max TP:

+
$$ +TP_{max} = \lim_{n\rightarrow\infty}\frac{n}{(n+k-1)\Delta t} = \frac{1}{\Delta t} +$$
+ +

Speed up Execution time ratio between w/o or w/ pipelining.

+

$T_0$: execution time without pipelining

+

$T_k$: execution time with k-stage pipelining(assume each stage has the same latency)

+
$$ +\frac{T_0}{T_k} +$$
+ +

Real speedup:

+
$$ +S = \frac{nk\Delta t}{(n + k - 1)\Delta t} = \frac{kn}{n + k - 1} +$$
+ +

Max speedup:

+
$$ +S_{max} = \lim_{n\rightarrow \infty}\frac{kn}{k + n - 1} = k +$$
+ +

Pipelined datapath

+

+

+

+

+

+

+

Many inst. doesnt need MEM stage, but the stage can’t be skipped, since it may “collide” with the previous inst.

+

Q: How to get the control signals in each stage?

+

Control signals are generated at ID/RF stage.

+

Control signals flow in the pipeline: use when needed; reserve when subsequent stages needed; discard when not needed any more.

+

+

Why RegDst Doesnt needed in the stages after EX?

+

The RegDst is used to select the destination register. However, the destination register is determined in the EX stage. Thus, RegDst is not needed in the stages after EX.

+

Sometimes this can cause trouble:

+
1
2
3
LW R2, R9(10)
ADD R4, R3, R2
ADD R6, R5, R4
+ +

The R4 is accessed before it updates.

+

Hazard in the pipeline

Structural Hazards

+

Two instructions acquire the same hardware resource simultaneously.

+

+

Solution:

+
    +
  1. Add resources: separating PC+4 from ALU; Harvard architecture
  2. +
  3. Adjust stages: add MEM
  4. +
+

+

+

MIPS is born to be pipelined: the problem of structural hazard is solved by the structure of MIPS.

+

Data Hazards

+

+

2 solutions:

+

Stalling

+

+

Forwarding(Bypassing)

+

+

+

But, load uses hazard emerges:

+

+

+

Still, a nop needed to stall the pipeline.

+

+

Is there any possibility to eliminate the stall?

+

Yes, if the MIPS code can be optimized.

+

+

Control Hazards

+

+

Stalling

+

+

Forwarding

+

+

If Move the branch decision to ID stage:

+

+

+

Delay slot

+

+

Prediction

+

Static Branch Prediction

+

+

Cancel the effect caused by false prediction.

+

Dynamic Branch Prediction

+
    +
  • History-based dynamic prediction
  • +
  • Using runtime behaviour to predict future branches
  • +
+

At IF stage, there are Branch History Table(BHT) and Branch Target Buffer(BTB).

+

beq at IF stage

+

• Look up if the instruction address is in BHT and BTB.

+

• If not in, create a new entry. If in, check whether the
branch is taken at the last time. If taken, send the target
address to PC as the next address for IF.

+

–beq at ID stage

+

• IF stage will fetch instruction based on the predicted
target address

+

Implementation of the Pipiline

+

Data hazard

+

Forwarding

+

EX/MEM hazard

+
1
2
3
4
5
6
7
8
if (EX/MEM.RegWrite
and (EX/MEM.RegWrAddr != 0)
and (EX/MEM.RegWrAddr == ID/EX.RegisterRs))
ForwardA = 10
if (EX/MEM.RegWrite
and (EX/MEM.RegWrAddr != 0)
and (EX/MEM.RegWrAddr == ID/EX.RegisterRt))
ForwardB = 10
+ +

MEM/WB hazard

+
1
2
3
4
5
6
7
8
9
10
if (MEM/WB.RegWrite
and (MEM/WB.RegWrAddr != 0)
and (MEM/WB.RegWrAddr == ID/EX.RegisterRs)
and (EX/MEM.RegWrAddr != ID/EX.RegisterRs || ~ EX/MEM.RegWrite))
ForwardA = 01
if (MEM/WB.RegWrite
and (MEM/WB.RegWrAddr != 0)
and (MEM/WB.RegWrAddr == ID/EX.RegisterRt)
and (EX/MEM.RegWrAddr != ID/EX.RegisterRt || ~ EX/MEM.RegWrite))
ForwardB = 01
+ +

load-use hazard

+

We have to stall the pipeline for one cycle.

+

Condition: if (ID/EX.MemRead and ((ID/EX.RegisterRt == IF/ID.RegisterRs) or (ID/EX.RegisterRt == IF/ID.RegisterRt)))

+

How to stall?

+

Stall & flush

+

PC & ID/IF: stall(Keep the control signals)

+

EX & MEM & WB: flush(Set the control signals to 0)

+

Control signals:

+

EX: RegDst, ALUOp1, ALUOp0, ALUSrc

+

MEM: Branch, MemRead, MemWrite

+

WB: MemToReg, RegWrite

+
1
2
3
4
if {ID/EX.MemRead
and ((ID/EX.RegisterRt = IF/ID.RegisterRs)
or (ID/EX.RegisterRt = IF/ID.RegisterRt))}
Keep IF/ID; Keep PC; Flush ID/EX;
+ +

Special Case:

+

Memory-to-memory copy

+
1
2
lw $1, 10($2)
sw $1, 10($3)
+ +

The stall is unnecessary. We can use forwarding to solve the problem.

+

Control Hazard

+

BEQ & J need 1 stall cycle.

+

Control hazards are not as frequent as data
hazards, but they are harder to be resolved
effectively as forwarding.

+

Another type of control hazard: exceptions and interrupts.

+

– “Exception” includes any unpredictable events that
can change the normal control flow, which has no
distinction between internal and external.

+

– “Interrupt” is only used for external events.

+

+

Advanced techniques for processor

Instruction-level parallelism

Superpipelining: a deeper pipeline

+

VLIW

+

Multiple-issue: a wider pipeline

+

Superscalar

+

+

Thread-level parallelism

Hyper-threading

+

+

Multicore

+

Heterogeneous computing

GPU

+

XPU

+

Memory

Basics

SRAM cell

+

High speed, low density & expensive

+

+

DRAM cell

+

Low speed, high density & cheap. The charge in capacitor may leak, so the data cannot be stored for a long time.

+

+

+

Evaluation

3C model:

+

Compulsory miss first access to a block

+

Capacity miss all lines in cache are used

+

Conflict miss(collision miss) not fully filled, but the blocks # > available ways #.

+
\ No newline at end of file diff --git a/2023/09/18/Computer-Network/index.html b/2023/09/18/Computer-Network/index.html new file mode 100644 index 00000000..581fe0e7 --- /dev/null +++ b/2023/09/18/Computer-Network/index.html @@ -0,0 +1,823 @@ +Computer Network | Guo_Yun + + + + + + + + + + + + + + + + + + + + + + + +

Computer Network

参考书籍

A.S Tanebaum (著),严伟,潘爱民(译) 计算机网络(第五版), 2004,清华大学出版社

+

A.S Tanebaum,Nick Feamster, David Wetherall (著),潘爱民(译), 计算机网络(第六版), 2022, 清华大学出版社(彩色版,非常精美)

+

杂项

token ring

+

计算机网络最核心的技术:分组(packet)。

+

grid computing

+

计算机网络的历史与进展

网络计算的基本模式

+
    +
  • C/S or B/W
  • +
  • P2P
  • +
+

服务

+
    +
  • 延迟、带宽、丢失率、可靠性
  • +
  • 单播/多播, 实时/非实时
  • +
+

链路:光纤、电缆和卫星

+
    +
  • 电子、光子等作为传输介质
  • +
  • 节点:机械/电/光
  • +
+

协议

+
    +
  • TCP/IP, ATM, MPLS, SONET, Ethernet, PPP, X.25, FrameRelay, AppleTalk, IPX, SNA
  • +
+

功能

+
    +
  • 路由,差错控制、拥塞控制、服务质量(QoS)
  • +
+

应用:FTP、HTTP

+

空间距离

+
    +
  • 局域网 (LAN): 以太网、令牌环、FDDI
  • +
  • 城域网 (MAN): DQDB, SMDS ,以太网
  • +
  • 广域网 (WAN): X.25, ATM, frame relay, DWDM
  • +
+

信息类型

+
    +
  • 数据网络 vs. 通信网络
  • +
+

应用类型

+
    +
  • 专用网络:飞机订票网,银行网,信用卡网
  • +
  • 通用网络:Internet
  • +
+

使用权

+
    +
  • 私有:企业网
  • +
  • 公用:电话网、Internet
    协议的所有权
  • +
  • 私有: SNA (Systems Network Architecture)
  • +
  • 开放: IP
    技术
  • +
  • 地面 vs. 卫星
  • +
  • 有线 vs. 无线
    协议
  • +
  • IP, AppleTalk, SNA
  • +
+

计算机网络的形成

+
    +
  • 多终端系统
  • +
  • 把计算机互联起来
    1970年代的计算机网络
  • +
  • X.25 分组交换网:各国的电信部门建设运行
  • +
  • 各种专用的网络体系结构:SNA,DECnet
  • +
  • Internet 的前身ARPANET进行实验运行
    1980年代的计算机网络
  • +
  • 标准化计算机网络体系结构:OSI
  • +
  • 局域网络 LAN 技术空前发展
  • +
  • 建成NSFNET,Internet 初具规模
  • +
+

迈特卡尔夫定律(联网定律)

+

网络价值随用户数平方成正比。未联网设备增加 $N$ 倍,效率增加 $N$ 倍。联网设备增加 $N$ 倍,效率增加 $N^2$ 倍

+

Internet 标准化组织

+
    +
  • Internet Engineering Task Force(IETF):IETF负责Internet协议的研发和改进。IETF被分为很多个工作组(working groups),他们提交的文档称为RFC(Request For Comments)。
  • +
  • IRTF(Internet Research Task Force):IRTF由一些专注于某个领域长期发展的研究小组组成。
  • +
  • Internet Architecture Board(IAB):IAB负责定义Internet的整体框架,为IETF提供大方向上的指导。
  • +
  • The Internet Engineering Steering Group(IESG):IESG在技术方面管理IETF的活动,负责Internet标准的制定过程。
  • +
+

所有的标准以RFC的形式发布出来,可以从www.ietf.org免费获得,但不是所有的RFC都是Internet标准。标准形成的一般步骤是:

+
    +
  • Internet Drafts
  • +
  • RFCs
  • +
  • Proposed Standard
  • +
  • Draft Standard(需要两个可以工作的实现)
  • +
  • Internet Standard(由IAB发布)
  • +
+

David Clark, MIT, 1992:

+
    +
  •  "We reject: kings, presidents, and voting. 
    +
    +
  • +
  •   We believe in: rough consensus and running code.”
    +
    +
  • +
+

Paul Baran 分组交换网络

+

与 Donald Watts Davies 在这个思想的发明上有争议。

+

Baran 的设计细节:

+

报文发送

+
    +
  • 每个交换节点根据自己的路由表判断如何转发报文
  • +
  • 每个报文的转发都是独立于其他报文的
  • +
  • 交换节点不保存端节点的状态
      +
    • 可扩展性好
    • +
    • 不是最有效的网络
    • +
    • 发送不是完美的
        +
      • 端节点必须能容忍发送错误并从中恢复
        分布式系统
      • +
      +
    • +
    +
  • +
  • 所有交换节点是平等的
  • +
  • 避免了单一节点失效问题
  • +
  • 部件可以失效,但系统不可以
  • +
  • 系统的健壮性来自于
      +
    • 足够的物理(硬件)冗余
    • +
    • 适应性路由
    • +
    +
  • +
+

模拟实验表明:“extremely survivable networks can be built using a moderately low redundancy of connectivity level”—Paul Baran, 1964

+

比较两种可靠系统的实现思路:

+

电话系统

+
    +
  • 笨终端,聪明的网络
  • +
  • 确保每个网络部件都是可靠的
      +
    • 系统可靠性=部件可靠性
    • +
    • 通过局部冗余实现部件的高可靠性
    • +
    • 期望每个部件都能正常工作,部件失败的可能性很低
    • +
    +
  • +
  • 需要人工配置的,高度控制的网络
  • +
+

Baran的系统

+
    +
  • 建立在简单的、不可靠部件上的可靠系统
  • +
  • 自适应的系统
  • +
  • 聪明的终端,可以修正传输错误
  • +
+

Baran 设计思想的一种实现:Internet

+
    +
  • 连接异构的子网
  • +
  • 提供两种基本功能
      +
    • 全球唯一的地址
    • +
    • 报文通过动态路由从源节点发送到目的节点
    • +
    +
  • +
+

simple, flexible, scalable, and robust

+

分组交换的特点:

+

简单性

+
    +
  • 每个报文携带各自的地址信息
  • +
  • 一个路由表可以为所有的流量服务
  • +
  • 可以适应爆炸性的增长
      +
    • 越简单越不容易出错
    • +
    • 越简单越容易增长
    • +
    • 对基本网络功能的要求少,可以在其上建立多种类型的网络
    • +
    +
  • +
+

灵活性

+

Everything over IP

+

IP over Everything

+

可扩展性

+

可扩展的系统必须能对付

+
    +
  • 端系统的增加
  • +
  • 流量的增加
  • +
  • 网络规模的增长
      +
    • 大的路由表
    • +
    • 路由频繁的变化
    • +
    +
  • +
+

边缘论:End-to-End Argument

+

路由器只负责传输,复杂的功能(纠错,重传)都由终端自行解决

+

健壮性

+
    +
  • 动态路由具有自适应的特性
      +
    • 动态路由和报文转发相辅相成
    • +
    • 周期性路由更新
    • +
    • 默认: 现有的部件会失效,会有新的部件加入,认为变化是正常的
    • +
    +
  • +
  • 牺牲一定的带宽的利用率,提高健壮性(报文头开销,更新开销)
  • +
+

数据通信基本原理

香农定理:
带宽为 $H$ 赫兹,信噪比为 $S/N$ 的任意信道的最大数据传输率为 $H\log_2(1 + S/N) (bps)$

+
    +
  • 此式是利用信息论得出的,具有普遍意义
  • +
  • 与信号电平级数、采样速度无关
  • +
  • 此式仅是上限,实践中难以达到
  • +
+

曼彻斯特码(Manchester),也称相位编码

+
    +
  • 原理:每一位中间都有一个跳变,从低跳到高表示“0”,从高跳到低表示“1”。
  • +
  • 优点:克服了NRZ码的不足。每位中间的跳变即可作为数据,又可作为时钟,能够自同步。
  • +
+

+

差分曼彻斯特码(Differential Manchester)

+
    +
  • 原理:每一位中间都有一个跳变,每位开始时有跳变表示“0”,无跳变表示“1”。位中间跳变表示时钟,位前跳变表示数据。
  • +
  • 优点:时钟、数据分离,便于提取。
  • +
+

网络体系结构

计算机网络的构成

资源子网

+
    +
  • 服务器(Server)
  • +
  • 客户机(Client)
  • +
+

C/S -> B/W -> P2P

+

通信子网

+
    +
  • 通信线路(通道)
  • +
  • 网络互连设备(路由器、交换机、集线器等)
  • +
+

基本结构

点到点通道

+
    +
  • 一条线路连接两台网络互联设备
  • +
  • 一般两台计算机的连接要经过多台互联设备
  • +
  • 星形、环形、树形、全连结、交叉环、不规则图
  • +
  • 关键技术:路由选择(Routing)
  • +
+

广播网络

+
    +
  • 总线,环

    +
  • +
  • 组播网络(Multicast Networks):把成员分组

    +
  • +
  • 单播网络(Unicast Networks)

    +
      +
    • 点到点连接
    • +
    +
  • +
  • 关键技术:通道分配

    +
      +
    • 静态分配:分时间片
        +
      • 控制简单,通道利用率低
      • +
      +
    • +
    • 动态分配各站点动态使用通道
        +
      • 控制复杂,通道利用度高
      • +
      • 通道分配方法:
          +
        • 集中式:只有一个仲裁机构
        • +
        • 分布式:各站点均有仲裁机构
        • +
        +
      • +
      +
    • +
    +
  • +
  • PAN

    +
  • +
  • LAN

    +
  • +
  • MAN

    +
  • +
  • WAN

    +
  • +
  • internet,指一种技术(Internet,指实体的网络)

    +
  • +
  • Interplanetary Internet

    +
  • +
+

计算机网络体系结构

对计算机网络及其部件所完成的功能的比较精确的定义,即从功能的角度描述计算机网络的结构,是层次模型和协议的集合。

+

注意:计算机网络体系结构仅仅定义了网络及其部件通过协议应完成的功能,不定义协议的实现细节和各层协议之间的接口关系。

+

协议分层的优点:易于协议的设计、分析、实现和调试

+

计算机网络的功能:

+
    +
  • 基本功能:为地理位置不同的计算机用户提供访问通路
  • +
  • 具体化为:
      +
    • 连接源节点和目的节点的物理传输线路,可以经过中间节点
    • +
    • 每条线路两端的结点利用波形进行二进制通信
    • +
    • 无差错的信息传送
    • +
    • 多个用户共享一条物理线路
    • +
    • 按照地址信息,进行路由选择
    • +
    • 信息缓存与流量控制
    • +
    • 会话控制
    • +
    • 满足各种用户、各种应用的访问要求
    • +
    +
  • +
+

网络协议

层次结构的计算计网络功能中最重要的功能是通信功能,这种通信功能主要涉及同层中通信双方的相互作用,位于不同计算机上进行对话的第N层通信各方可分别看成是一种进程,称为对等进程(同等进程)

+

协议

+

计算机网络同等层次中,通信双方进行信息交换时必须遵守的规则。

+

协议栈

+

一个特定系统所使用的一组协议统称为协议栈。

+

接口

+

相邻层之间有一个接口(Interface),它定义了下层向上层提供的原语操作与服务

+

层、协议和接口

协议特性

+
    +
  • 不知道上下层的内部结构
  • +
  • 独立完成某种功能
  • +
  • 为上层提供服务
  • +
  • 使用下层提供的服务
  • +
+

服务分类

    +
  • 面向连接的服务
      +
    • 当使用服务传输数据时,首先建立连接,然后使用该链接传送数据,使用完后,关闭连接。
    • +
    • 特点:顺序性好,类似于电话
    • +
    +
  • +
  • 面向无连接的服务
      +
    • 直接使用服务传送数据,每个分组独立进行路由选择。
    • +
    • 特点:顺序性差,类似于邮政
    • +
    +
  • +
  • 连接与可靠的关系
      +
    • 连接并不意味着可靠,可靠要通过确认、重传等机制来保证
    • +
    • 面向无连接的可以是可靠的,例如挂号信
    • +
    +
  • +
+

TCP(可靠的连接),UDP(不可靠的)

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
服务例子
面向连接的例子
可靠的报文流页面序列
可靠的字节流文件下载
不可靠的连接IP语音
无连接的例子
不可靠的数据报垃圾邮件
有确认的数据报文本消息
请求-响应数据库查询
+

服务原语(primitives)

服务在形式上是由一组接口原语(或操作)来描述的

+

四种类型:

+
    +
  • 请求(request):实体请求服务做一些工作
  • +
  • 指示(Indication):实体被通知事件的发生
  • +
  • 响应(Response):实体对某个事件的响应
  • +
  • 确认(Confirm):对较早请求产生响应的确认
  • +
+

分层

引入中间层,为底层不同的网络技术提供统一的抽象,服务上层业务

+

计算机网络参考模型

计算机网络的标准化

电信标准

+

ITU(International Telecommunication Union)

+
    +
  • ITU-R:无线通信
  • +
  • ITU-T:电信标准
  • +
  • ITU-D:开发
  • +
+

国际标准化组织:ISO

+

一个国际标准的形成:

+
    +
  • CD(Committee Draft)
  • +
  • DIS(Draft International Standard)
  • +
  • IS(International Standard)
  • +
+

其他标准化组织

+
    +
  • ANSI
  • +
  • NIST
  • +
  • IEEE
  • +
  • OIF
  • +
+

互联网标准化组织

+

互联网标准是自发,而非政府干预的,标准文本称为 RFC(Request For Comments)

+

OSI 参考模型

alt

+

alt

+

TCP/IP 参考模型

    +
  • 物理层
      +
    • 在物理线路上传输原始的二进制位
    • +
    +
  • +
  • 数据链路层
      +
    • 在有差错的物理线路上提供无差错的数据传输
    • +
    • 第一层和第二层合称为:Host-to-Network
    • +
    +
  • +
  • Internet 层(网络层)
      +
    • 控制通信子网提供源点到目的点的IP分组传送
    • +
    +
  • +
  • 运输层
      +
    • 提供端到端的数据传送服务,包括 TCP 和 UDP
    • +
    +
  • +
  • 应用层
      +
    • 提供各种管理和应用服务功能
    • +
    +
  • +
+

alt

+

其他参考模型

Novell NetWare 参考模型

+

alt

+

ATM 参考模型(B-ISDN)

+

alt

+

排队与统计复用

+

若分组的到达速率超过链路的传输速率:

+
    +
  • 分组在端口中排队,等待链路发送
  • +
  • 当排队等待的分组超过分配给端口队列的缓存大小,缓存溢出,导致新到达的分组被丢弃
  • +
  • 端口队列将随即到达的分组进行一定程度的整形,实现了关联端口链路的统计复用
  • +
+

分组延时的组成

+
$$ +D = d_{proc} + d_{queue} + d_{trans} + d_{drop} +$$
+ +

$d_{trans}$:传输延时:

+
    +
  • L: 分组长度
  • +
  • R:链路速率
  • +
  • $d_{trans} = L / R$
  • +
+

$d_{prop}$ 传播延时:

+
    +
  • $d$:链路长度
  • +
  • $s$:传播速度
  • +
  • $d_{prop}$:$d/s$
  • +
+

吞吐量

+

单位时间内发送者可以给接收者传送的比特数

+
    +
  • 瞬时吞吐量:给定时刻的速率
  • +
  • 平均吞吐量:一段时间内的平均速率
  • +
+

瓶颈链路:端到端路径(Path)上约束端到端平均吞吐量的链路(Link)

+

alt

+

几个概念

+
    +
  • 报文:传输层协议的传输单位。报文由传输协议的头和应用层协议数据组成。就互联网而言,报文就是 TCP 报文段,报文段一定要封装在 IP 数据报(Datagram)中。
  • +
  • 报文段: TCP 协议端到端传输的单位。
  • +
  • IP 数据报分组:IP 协议的端到端传输单位,由 IP 头和传输层协议数据组成。
  • +
  • 分组:穿越网络层和链路层之间接口的数据单位。可以是完整的 IP 数据报或者 IP 数据报的分片(fragment)
  • +
  • 帧:链路层协议传输单元
  • +
+

物理层

物理层提供机械的、电气的、功能的和规程的特性,目的是启动、维护和关闭数据链路实体之间进行比特传输的物理连接。这种连接可能通过中继系统,中继系统内的传输也是在物理层。

+

物理层的网络互联设备:中继器

+

物理层的基本功能:在两个网络设备之间提供透明的比特流传输。

+

物理层操作:物理连接的启动与关闭,正常数据的传输,以及维护管理。

+
    +
  • 连接方式 (点到点,点到多点)
  • +
  • 通信方式 (单工,半双工,全双工)
  • +
  • 位传输方式(串行,并行)
  • +
+

物理层的四个重要特性:

+
    +
  • 机械特性
  • +
  • 电气特性
  • +
  • 功能特性
  • +
  • 规程特性
  • +
+

机械特性

+

主要定义物理连接的边界点,即接插装置;规定物理连接时所采用的规格、引脚的数量和排列情况

+

电气特性

+

规定传输二进制位时,线路上信号的电压高低、阻抗匹配、传输速率和距离限制。

+

功能特性

+

主要定义各条物理线路的功能。

+

线路的功能分为四大类:

+
    +
  • 数据
  • +
  • 控制
  • +
  • 定时
  • +
  • 接地
  • +
+

规程特性

+

主要定义各条物理线路的工作规程和时序关系。

+

传输介质

+

有导向介质

+
    +
  • 铜线、光纤
  • +
+

磁介质

+

双绞线

+

同轴电缆

+

光纤

+

无导向介质

+
    +
  • 无线电波、激光、红外等
  • +
+

扩频技术

+
    +
  • 窄带通信
      +
    • 窄带的接受效果更加
    • +
    • 利于提高单位 Hz 的能量
    • +
    +
  • +
  • 扩频通信
      +
    • 调频扩频
    • +
    • 直接序列扩频
    • +
    • 超宽带(UWB)
    • +
    +
  • +
+

无线电传输

+

低频率、大波长的无线电容易穿过障碍物。全方向发射。

+

微波传输

+
    +
  • f >100Mhz,波长在厘米级
  • +
  • 微波沿直线传播
  • +
  • 无法穿越障碍物,容易被雨水吸收
  • +
  • 多径衰落(Multipath fading)
  • +
  • 造价低
  • +
+

红外线和毫米波

+
    +
  • 波长在毫米级
  • +
  • 很难穿越障碍物
  • +
  • 短程通信(无需授权)
  • +
  • 遥控器等
  • +
  • 室内无线LAN
  • +
+

光波传输

+
    +
  • 自由空间光通信
  • +
  • 无法穿透雨或浓雾
  • +
  • 受环境影响较大
  • +
+

典型传输网络

+
    +
  • 电话网络
      +
    • SONET/SDH
    • +
    • 采用TDM技术,是同步系统,由主时钟控制,时钟精度10e-9。
    • +
    • 路径(path),链路(line),段(section)
    • +
    +
  • +
+

基本结构

+
    +
  • 一帧包含 810 字节,每 125 us 产生一帧
  • +
  • 基本 SONET 信道称为 STS-1
  • +
+

蜂窝无线电(Cellular Radio)

+
    +
  • 单方向的寻呼系统
  • +
  • 打电话给寻呼公司,输入寻呼机号码;
  • +
  • 寻呼公司的计算机收到请求,通过线路传到高处(山顶)的天线;
  • +
  • 天线直接广播信号(本地寻呼),或传递给卫星(异地寻呼),卫星再广播。
  • +
  • 需要很小的带宽
  • +
+

模拟蜂窝电话

+
    +
  • 使用小的蜂窝
  • +
  • 在附近(不相邻)的蜂窝中重用传输频率
  • +
  • 发射功率小,设备小而便宜
  • +
+

数字蜂窝网络

+
    +
  • 第一代:模拟蜂窝电话
  • +
  • 第二代:数字蜂窝电话
  • +
  • 第三代:3G
  • +
+

有线接入网络

+

通信卫星

+

电力线通信

+

数据链路层

定义和功能

数据链路层协议定义了一条链路的两个结点间交换数据的单元格式,以结点发送和接收数据单元的动作。

+

概念:

+

结点(node):网络中的主机(host)和路由器(router)称为结点

+

链路(link): 通信路径上连接相邻结点的信道称为链路

+

点到点(point to point):一条链路的两个相邻结点间的通信称为点到点通信, 也称为通信路径(path)的一跳(hop)

+

端到端(end to end)

+

从源结点(source node)到目的结点(destination node)的通信称为端到端通信,通信路径可能由多个链路组成。

+

与端到端(end to end,E2E)相对应的概念是逐调(hop by hop,HBH)

+

虚拟数据通路

+

实际数据通路

+

功能:

+

数据链路层协议应提供的最基本功能

+
    +
  • 向网络层提供服务
  • +
  • 定界与同步
  • +
  • 差错控制
  • +
  • 顺序控制
  • +
  • 流量控制
  • +
+

提供三种服务

+
    +
  • 不可靠无连接服务
  • +
  • 可靠无连接服务
  • +
  • 可靠面向连接服务
  • +
+

成帧

Framing: 将比特流分成离散的帧,并计算每个帧的校验和。

+

字符计数法

+
    +
  • 在帧头中用一个域来表示整个帧的字符个数
  • +
  • 缺点:若计数出错,对本帧和后面的帧有影响
  • +
+

带字符填充的首尾字符定界法

+
    +
  • 起始字符 DLE STX,结束字符DLE ETX
      +
    • DLE:Data Link Escape
    • +
    • STX:Start of Text
    • +
    • ETX:End of Text
    • +
    +
  • +
  • 字符填充
  • +
  • 局限于 8 位字符和 ASCII 字符传送
  • +
+

带位填充的首尾标记定界法

+
    +
  • 帧的起始和结束都用一个特殊的位串“01111110”,称为标记(flag)
  • +
  • “0”比特插入删除技术
  • +
+

物理层编码违例法

+

只适用于物理层编码有冗余的网络

+
    +
  • 802 LAN:曼彻斯特编码中
      +
    • 高-低 / 低-高 分别表示1/0,
    • +
    • 高-高 / 低-低 不表示数据,可以用来做定界符。
    • +
    +
  • +
+

差错控制

一般方法:接收方给发送方一个反馈(响应)

+

出错情况

+
    +
  • 帧出错,包括发送帧和相应帧
  • +
  • 帧丢失,包括发送帧和相应帧
  • +
+

一般方案

+
    +
  • 通过计时器和序号保证每帧最终交给目的网络层仅一次
  • +
+

流量控制

防止发送过快,淹没接收端

+
    +
  • 例如,接收端缓存溢出
  • +
+

错误检测和纠正

差错出现特点

+
    +
  • 随机、偶发、孤立
  • +
  • 连续突发(burst)
    处理差错的两种基本策略
  • +
  • 使用纠错码
  • +
  • 发送方在每个数据块中加入足够的冗余信息,使得接收方能够判断接收到的数据是否有错,并能纠正错误。
      +
    • 例:前向纠错FEC (Forward Error Correcting):
    • +
    +
  • +
  • 使用检错码
  • +
  • 发送方在每个数据块中加入足够的冗余信息,使得接收方能够判断接收到的数据是否有错,但不能判断哪里有错。
  • +
+

奇偶校验
最简单的例子是奇偶校验,在数据后填加一个奇偶位

+

奇偶校验可以用来检查奇数个错误

+

纠错码

码字(codeword)

+
    +
  • 一个帧包括m个数据位,r个校验位,n = m + r,
  • +
  • 则此n比特单元称为n位码字
    海明距离(Hamming distance)
  • +
  • 两个码字之间不同的比特位数目。
  • +
  • 例如:0000000000 与0000011111的海明距离为5
  • +
+

结论

+
    +
  • 如果两个码字的海明距离为d,则需要d个单比特错就可以把一个码字转换成另一个码字;
  • +
  • 为了检查出d个错,需要使用海明距离为 d + 1 的编码;
  • +
  • 为了纠正d个错,需要使用海明距离为 2d + 1 的编码。
  • +
+

m个信息位,r个校验位,纠正单比特错 (n=r+m)

+

对 $2^m$ 个任何有效信息中的任何一个,有 $n$ 个与其距离为 1 的无效码字,因此有

+
$$ +(n + 1)2^m \le 2^n +$$
+ +

利用 $n = m + r$,得到 $m + r + 1 \le 2^r$,给定 m,利用上式得到校正单比特误码的校验位数目下界

+
    +
  • 码位从左边开始编号,从“1”开始;
  • +
  • 位号为2的幂的位是校验位,其余是信息位;
  • +
  • 每个校验位使得包括自己在内的一些位的奇偶值为偶数(或奇数)
  • +
  • 为看清数据位k对哪些校验位有影响,将k写成2的幂的和。
  • +
+

汉明码的工作过程:

+
    +
  • 每个码字到来前,接收方计数器清零;
  • +
  • 接收方检查每个校验位k (k = 1, 2, 4 …)的奇偶值是否正确;
  • +
  • 若第 k 位奇偶值不对,计数器加 k;
  • +
  • 所有校验位检查完后,若计数器值为0,则码字有效;若计数器值为m,则第m位出错。例:若校验位1、2、8出错,则第11位变反。
  • +
+

检错码

使用纠错码传数据,效率低。适用于不可重传的场合。

+

大多情况采用的检测码加重传。

+

二进制多项式

+

二进制码串表示成二进制多项式

+

循环冗余码(CRC)

+
    +
  • 发送方与接收方事前商定。
  • +
  • 生成多项式的高位和低位必须为1
  • +
  • 生成多项式必须比传输信息对应的多项式短
  • +
+

CRC 的基本思想
校验和(checksum)加载帧尾,使带校验和的帧的多项式能被 $G(x)$ 除尽,接收方接受时,用 $G(x)$ 去除它,若有余数,则传输出错。

+

校验和计算算法

+

设 $G(x)$ 为 $r$ 阶,在帧的末尾加 $r$ 个0,使得帧为 $m + r$ 位,相应多项式为 $x^rM(x)$。

+

按照模 2 除法用对应$G(x)$ 的位串去除对应于 $x^rM(x)$减去余数,结果就是要传送的带检验和的多项式 $T(x)$。

+

CRC 的检错能力:

+

发送方发送 $T(x)$,接收方接受的$T(x) + E(x)$,$E(x) \ne 0$。

+

$(T(x) + E(x)) / G(x) = 0 + (E(x) / G(x))$

+

如果$(E(x) / G(x))$的余数为0,则差错不能发现;否则可以发现。

+

alt

+

alt

+

数据链路层协议

无约束单工协议

    +
  • 工作在理想情况
  • +
  • 单工传输
  • +
  • 发送方无休止工作(要发送的信息无限多)
  • +
  • 接收方无休止工作(缓冲区无限大)
  • +
  • 通信线路(信道)不损坏或丢失信息帧
  • +
+

工作过程

+
    +
  • 发送程序: 取数据,构成帧,发送帧;
  • +
  • 接收程序: 等待,接收帧,送数据给高层
  • +
+

单工停等协议

协议描述

+
    +
  • 增加约束条件:接收方不能无休止接收。
    解决方案
  • +
  • 接收方每收到一个帧后,给发送方回送一个响应。
    工作过程
  • +
  • 发送程序:取数据,成帧,发送帧,等待响应帧
  • +
  • 接收程序:等待,接收帧,送数据给高层,回送响应帧。
  • +
+

有噪声信道的单工协议

协议描述

+
    +
  • 增加约束条件:信道(线路)有差错,信息帧可能损坏或丢失。
  • +
+

解决方案

+
    +
  • 出错重传
      +
    • 带来的问题
        +
      • 响应帧重复?发送帧头中放入序号
      • +
      +
    • +
    +
  • +
  • 重传触发:
      +
    • 超时重传
    • +
    • 什么时候重传?定时器
      ARQ/PAR
    • +
    • PAR (Positive Acknowledgement with Retransmission)
    • +
    • ARQ (Automatic Repeat reQuest)
    • +
    +
  • +
+

流量控制

滑动窗口协议

捎带确认(piggybacking)

+

一位滑窗协议

+
    +
  • 窗口大小:N = 1,发送序号和接收序号的取值范围:0,1;
  • +
  • 可进行数据双向传输,信息帧中可含有确认信息(piggybacking);
  • +
  • 信息帧中包括两个序号域:发送序号和接收序号
    (已经正确收到的帧的序号)
    存在问题
  • +
  • 能保证无差错传输,但是基于停等方式;
  • +
  • 若双方同时开始发送,则会有一半重复帧;
  • +
  • 效率低,传输时间长。
  • +
+

退后n帧协议

选择重传协议

\ No newline at end of file diff --git "a/2023/09/18/\351\200\232\347\275\221/index.html" "b/2023/09/18/\351\200\232\347\275\221/index.html" new file mode 100644 index 00000000..b9e2016a --- /dev/null +++ "b/2023/09/18/\351\200\232\347\275\221/index.html" @@ -0,0 +1,1748 @@ +通网 | Guo_Yun + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

通网

信息论基础

离散随机变量的信息度量

$$ +H(X) = \mathbf E\lbraceH(X=x_i)\rbrace = -\sum_i p_i \log p_i +$$
+ +

称为熵

+

单位:

+
    +
  • 2 (Bit)
  • +
  • e (Nat)
  • +
  • 10 (Hartely)
  • +
+

表示了信息描述的有效性极限

+

信源编码(Source Coding),通过信息的有效表示,提高通信的有效性。例如: Huffman 编码

+

离散随机变量的最大熵:$\max_{p_i} H(X) = \log|S|$

+

前缀码:任何码字都不是其他码字的前缀。前缀码保证了唯一可译码。是二叉树叶子节点。

+

Kraft不等式

+

对于信源字符集$\lbrace a_1, \dots, a_m\rbrace$,必满足:

+
$$ +\sum\limits_{k=1}^{M}2^{-l(a_k)} \le 1 +$$
+ +

同时,若上式成立,必存在码长分别为$𝑙(𝑎_𝑘)$的前缀码。

+

最小前缀码的平均码长:

+
$$ +\min \bar L =\sum\limits_{i=1}^{M}p_il_i\\ +s.t.\sum\limits_{i=1}^{M} 2^{-l_i} = 1 +$$
+ +

由拉格朗日乘子法

+
$$ +p_i = 2^{-l_i}, \bar L_{min} = -\sum\limits_{i=1}^{M}p_i \log p_i +$$
+ +

记 $H(X) = -\sum p_i\log p_i$ .一般的,上下界为$H(X) \le \bar L \lt H(X) + 1$.

+

如果我们将$k$个独立同分布的信源符号 $x_1, \dots, x_k$堪称一个,对整体应用前缀码编码:

+
$$ +\begin{align*} + H(X_1, \dots, X_k) &= -\sum P(x_1, \dots, x_k) \log P(x_1, \dots, x_k)\\ + &= -\sum P(x_1, \dots, x_k) [\log P(x_1) + \dots + \log(x_k)]\\ + &= -\sum P(x_1)\log (x_1) - \dots - \sum P(x_k)\log (x_k)\\ + &= -kH(X) +\end{align*} +$$
+ +

直观:对长度为$𝑛$的$M$种信源符号序列,$𝑥_𝑖$出现的次数$≈𝑛𝑝_𝑖$

+

典型序列应满足上述分布,否则就“小众”“非典型”

+

典型的个数 # $≈ \frac{𝒏!}{(𝑛𝑝_1) !… (𝑛𝑝_M) !}$

+

平均每个信源符号可以用 $L = \frac{1}{n}\log\left(\frac{𝒏!}{(𝑛𝑝_1) !… (𝑛𝑝_M) !}\right)$ 个 bit 来表达。

+

通过 Stirling 公式可以得出 L的上下界。

+

+
$$ +\lim\limits_{n\rightarrow \infty}^{} L = H(X) +$$
+ +

最大熵

+

离散型随机变量的最大熵为

+ +
$$ +\max_{p_i} H(X) = \log |S| +$$
+ +

可以用梯度法直观感受,当所有分量的概率相等时,熵最大。

+

联合熵

+

联合概率

+ +
$$ +p_{i, j} = \text{Pr}\lbrace X = x_i, Y = y_j\rbrace +$$
+ +

联合熵的定义:

+
$$ +H(XY) = -\sum\limits_{i}^{}\sum\limits_{j}^{} p_{i, j} \log p_{i, j} +$$
+ +

条件熵

+

条件概率

+ +
$$ +p_{i\mid j} = \text{Pr}\lbrace X = x_i \mid Y = y_j\rbrace +$$
+ +

条件熵的定义:

+
$$ +H(X|Y) = -\sum\limits_{i}^{}\sum\limits_{j}^{} p_{i, j} \log p_{i\mid j} +$$
+ +

通过相关观测进行无损压缩,若观测到 $Y = \alpha_j$:

+
$$ +\bar L(\alpha_j) = -\sum\limits_{i}^{}\sum\limits_{j}^{} p_{i\mid j} \log p_{i\mid j} +$$
+ +

于是

+
$$ +\bar L =-\sum\limits_{j=1}^{N} \bar L(\alpha_j)p_j = -\sum\limits_{j=1}^{N}p_j\sum\limits_{i=1}^{M}p_{i|j} \log(p_{i|j}) = -\sum\limits_{i=1}^{M}\sum\limits_{j=1}^{N}p_{ij}\log(p_{i|j}) = H(X|Y) +$$
+ +

链式法则

+
$$ +H(XY) = H(Y) + H(X|Y) +$$
+ +

两个随机变量的联合不确定性=一个随机变量的不确定性+知道这个随机变量后另一个随机变量残余的不确定性

+

互信息(Mutual Infomation)

+
$$ +\begin{align*} + I(X;Y) &= H(X) + H(Y) - H(XY)\\ + &= H(X) - H(X|Y) \\ + &= H(Y) - H(Y|X) +\end{align*} +$$
+ +

互信息的物理意义

+

第一种理解:

+
    +
  • X的不确定度减去观测Y后X残存的不确定度
  • +
  • 即:通过观测Y带来的帮助了解X的信息
  • +
+

第二种理解:

+
    +
  • Y的不确定度减去观测X后Y残存的不确定度
  • +
  • 即:通过观测X带来的帮助了解Y的信息
  • +
+

若$X, Y$相互独立,记为$X\perp Y$,则$I(X;Y) = 0$,$H(X) = H(X|Y)$,$H(Y) = H(Y|X)$。观测一个随机变量完全无助于了解另一个随机变量。

+
    +
  • $H(XY) = H(X) + H(Y)$,总平均码长等于各自平均码长之和。
  • +
+

若$X = Y$,则$I(X;Y) = H(X) = H(Y)$,$H(X|Y) = H(Y|X) = 0$。观测一个随机变量完全了解另一个随机变量。

+

$H(XY) = H(Y) + H(X|Y) = H(Y)$,只需要编码其中一个即可。

+
$$ +X \perp Y \leftrightarrow H(X + Y | X) = H(Y | X) = H(Y), H(X + Y, X) = H(Y , X) +$$
+ + +
$$ +H(X + X | X) = H(X | X) = 0, H(X + X, X) = H(X , X) = H(X) +$$
+ +

信息传输的基本模型

+
    +
  • 信息通道,简称信道(Channel)对于输入符号有随机扰动,本质上可用一组条件概率表示
  • +
  • 限于物理条件,信宿只能观测信道输出 $Y$,由此了解其输入 $X$
  • +
  • 通过观测Y可以获得的关于X的信息量是 $I(X;Y)$
  • +
+

信息传输的优化

+

目标:最大化发送端 $X$ 和接收方 $Y$ 的互信息

+

方法:

+
    +
  • 信道是由物理实现所决定的,无法控制
  • +
  • 但是可以选择X的概率分布
  • +
+

因此有如下优化问题:

+
$$ +p*_i = \argmax_{\sum_i p_i = 1, p_i \ge 0} I(X;Y) +$$
+ +

定义信道容量 $C = \max_{\sum_i p_i = 1, p_i \ge 0} I(X;Y)$

+

信道容量的物理意义

+
    +
  • 平均每个信道符号所能传的最大的信息量
  • +
  • 或:单位时间内信道所传最大的信息量
  • +
+

优化问题的表达式

+
$$ +p_i^* = \argmax_{\sum_i p_i = 1, p_i \ge 0} - \sum_i\sum_j p_i p_{j|i} \log \frac{\sum\limits_i p_i p_{j|i}}{p_{j|i}} +$$
+ +

信道容量不易计算

+

对称二进制信道(BSC)

+
    +
  • 一种典型信道模型
  • +
  • 分析信道编码时有很多应用
  • +
+

利用互信息表达式

+
$$ +\begin{align*} + I(X;Y) &= H(Y) - H(Y | X)\\ + &= H(Y) - \sum_i p_i \left[-\sum_j p_{j|i} \log p_{j|i}\right]\\ + &= H(Y) - [-\varepsilon\log \varepsilon - (1 - \varepsilon)\log(1 - \varepsilon)]\\ + &\le 1 - [-\varepsilon\log \varepsilon - (1 - \varepsilon)\log(1 - \varepsilon)] = C\\ +\end{align*}\\ +Y \sim \begin{bmatrix} + 0 & 1\\ + 1/2 & 1/2 +\end{bmatrix} +$$
+ +

如果误码率 $\varepsilon = 0.5$,则信道容量为0, 传递不了信息。

+

如果误码率 $\varepsilon > 0.5$,继续增大差错率,反而可以提高信道容量。

+

高斯信道

+ +
$$ +Y = X + N\\ +f_N(n) = \frac{1}{\sqrt{2\pi \sigma^2}}\exp\left(-\frac{(y - x)^2}{2\sigma^2}\right) +$$
+ +

alt

+

alt

+

Shannon 公式

+
$$ +C = W\log(1 + \frac{P}{Wn_0}) +$$
+ +

连续性随机变量的熵

$$ +H(X) = - \int\limits_{-\infty}^{\infty}p(x)\log p(x) \mathrm dx + \lim_{\Delta \rightarrow 0} \log \frac{1}{\Delta} +$$
+ +

我们只关心相对不确定性,定义微分熵

+
$$ +h(X) = -\int\limits_{-\infty}^{\infty}p(x) \log p(x)\mathrm dx +$$
+ +

微分熵是对连续型变量相对不确定性的一种描述

+
    +
  • 其定义剔除了连续性或“精准要求”带来的困难,保
    留了分布函数形状自身的特征
  • +
  • 它说明用有限字符集合的字符串描述连续分布的随机
    变量,则平均字符长度为无穷大
  • +
  • 为了用有限长字符串描述信源,需要进行有损压缩,
    从而带来失真,即原始信源和压缩结果之间的差异
  • +
  • 失真测度包括:均方误差,绝对值误差,主观误差等
  • +
  • 对于图像,视频和语音等连续信源的编码等均属于有
    损压缩
  • +
+

多元随机变量的熵

联合熵:

+
$$ +h(XY) = -\int\limits_{-\infty}^{\infty}p(x, y) \log p(x, y)\mathrm dx \mathrm{d}y +$$
+ +

条件熵:

+
$$ +h(Y|X) = -\int\limits_{-\infty}^{\infty}p(x, y) \log p(y|x)\mathrm dx \mathrm{d}y +$$
+ +

互信息:

+
$$ +\begin{align*} + I(X;Y) &= h(X) + h(Y) - h(XY)\\ + &= h(X) - h(X|Y) \\ + &= h(Y) - h(Y|X) +\end{align*} +$$
+ +

压缩编码

压缩编码的分类

    +
  • 无损压缩
      +
    • 输入:数字序列
    • +
    • 输出:数字序列
    • +
    • 目的:使得平均长度更小
    • +
    +
  • +
  • 有损压缩
      +
    • 输入:模拟信号
    • +
    • 输出:数字序列
    • +
    • 目的:实现数字传输
    • +
    +
  • +
+

信号压缩编码的步骤:

+
    +
  • 抽样
  • +
  • 量化
  • +
  • 压缩编码
  • +
+

抽样

连续时间信源的离散化

+

+

离散化的方式:在标准正交基上投影展开

+
$$ +s(t) = \sum_k a_k\phi_k(t)\\ +a_k = +$$
+ +

若 $s(t)$ 是时限信号(宽度 $T$),可以用傅里叶展开的系数作为离散化结果:$s(t) = \sum\limits_k a_k e^{2\pi jkt/T}$

+

若 $s(t)$ 是带限信号(带宽 $W$),可以在频域对 $\hat S(f)$ 做傅里叶展开:

+
$$ +\hat S(f) = \sum\limits_k \alpha_k e^{2\pi jkf/(2W)} +$$
+ +

变换回时域时,得到 Nyquist 抽样定理:

+
$$ +s(t) =\sum\limits_{k}^{}s(kT) \text{sinc}\left(\left(\frac{t}{T} - k\right)\right), T = \frac{1}{2W} +$$
+ +

频域无混叠等价于时域无畸变

+

对于带通采样,有无混叠条件:

+

+

可以推导得出:

+
$$ +f_s = 2B\left(1 + \frac{M}{N}\right)\\ +N = \left\lfloor\frac{f_H}{B}\right\rfloor\\ +M = \left\lbrace\frac{f_H}{B}\right\rbrace\\ +B = f_H - f_L +$$
+ +

+

横轴为 $f_H/B$,纵轴为 $f_s$

+

量化

+

分层电平: $\lbrace x_k \lt x \le x_{k + 1} \rbrace$

+

重建/输出电平:$y_k$代表一个量化区间,用以重构信号时使用的电平值

+

量化函数: $y = Q(x)$, $y_k = Q\lbrace x_k \lt x \le x_{k + 1} \rbrace$

+

量化间隔: $\Delta_k = x_{k + 1} - x_{k}$

+

均匀量化 & 非均匀量化

+

均匀量化只对有界随机变量存在

+

量化

    +
  • 在此只讨论标量的量化
  • +
  • 量化噪声: $q = x - y = x - Q(x)$
  • +
  • 量化噪声是一个随机变量
  • +
  • 方差 $\sigma_q^2 = \int_{-\infty}^{\infty}[x - Q(x)]^2p_x(x)\mathrm dx$
  • +
  • 方差与输入信号分布有关,不存在普适的最佳量化方案
  • +
+

量化噪声的计算

$$ +\sigma_q^2 =\sum\limits_{k=1}^{L}\int_{x_k}^{x_{k + 1}}(x - y_k)^2p_x(x)\mathrm dx +$$
+ +

从较容易的情况着手

+
    +
  • 只考虑电平区间 $[-V,V]$ 之间的信号,并假设量化间隔很小,亦即分层电平很密
  • +
  • 在实际情况中,信号的分布函数处处可导,此时每个量化区间内信号的条件分布为均匀分布
  • +
+

量化区间内,近似概率密度 $p_x(x) = \frac{P_k}{\Delta_k}$

+

密集分层的量化噪声近似

+
$$ +\sigma_{qn}^2 = \sum\limits_{k=1}^{L}\int_{x_k}^{x_{k + 1}}(x - y_k)^2p_x(x)\mathrm dx = \sum\limits_{k=1}^{L}\frac{P_k}{\Delta_k}\int_{x_k}^{x_{k + 1}}(x - y_k)^2\mathrm dx = \frac{1}{12}\sum_{k = 1}^L P_k\Delta_k^2 = \frac{1}{12} \int_{-V}^{V}(\Delta_k)^2p_x(x)\mathrm dx +$$
+ +

若 $\Delta_k = \Delta$,

+
$$ +\sigma_{qn}^2 = \frac{1}{12}\sum_k P_k\Delta_k^2 = \frac{\Delta_k^2}{12} +$$
+ +

计算量化结果做无损压缩后的比特数:

+
$$ +H(Q(x)) = -\sum_k P_k \log P_k = \underbrace{- \int_{-\infty}^{\infty}p_x(x)\log p_x(x) \mathrm dx }_{h(X)} + \log \frac{1}{\Delta} +$$
+ +

由 $\Delta = \sqrt{12\sigma_{qn}^2} = 2\sigma_{qn}\sqrt{3}$,

+
$$ +H(x) = h(x) + \log \frac{1}{2\sigma_{qn}\sqrt{3}} +$$
+ +

无损压缩的 bit 数为: $\tilde{R} = h(X) - \frac{1}{2}\log \sigma_{qn}^2 - 1.8$

+

对于均匀量化:

+
$$ +\Delta_k = \frac{x_{max} - x_{min}}{L} = \frac{2x_{max}}{L}, \forall k +$$
+ +

于是

+
$$ +\sigma_{qn}^2 = \frac{\Delta^2}{12} = \frac{x_{max}^2}{3L^2} +$$
+ +

这里的 $\sigma_{qn}^2$ 是正常量化噪声,仅仅是计算了信号落在 $[-x_{max}, x_{max}]$ 内的情况

+

如果信号落在 $[-x_{max}, x_{max}]$ 以外,就就近判断至两端的量化区间,产生过载噪声

+
$$ +\sigma_{qo}^2 = \int_{x_{max}}^{\infty}(x - x_{max})^2p_x(x)\mathrm dx + \int^{-x_{max}}_{-\infty}(x + x_{max})^2p_x(x)\mathrm dx = 2\int_{x_{max}}^{\infty}(x - x_{max})^2p_x(x)\mathrm dx +$$
+ +

总噪声等于正常量化噪声加上过载噪声:

+
$$ +\sigma_{qs}^2 = \sigma_{qn}^2 + \sigma_{qo}^2 +$$
+ +

如果用 $R$ bit 编码:

+
$$ +\Delta_k = \frac{2x_{max}}{L} = \frac{x_{max}}{2^{R - 1}}\\ +\sigma_{qn}^2 = \frac{\Delta^2}{12}\int_{-x_{max}}^{x_{max}}p_x(x)\mathrm dx = \frac{x_{max}^2}{3 \times 2^{2R}}\int_{-x_{max}}^{x_{max}}p_x(x)\mathrm dx +$$
+ +

定义非过载信号功率:

+
$$ +\sigma_s^2 = \int_{-x_{max}}^{x_{max}}x^2p_x(x)\mathrm dx +$$
+ +

当 $\int_{-x_{max}}^{x_{max}}p_x(x)\mathrm dx \rightarrow 1$, $SNR_q \approx \frac{\sigma_s^2}{x_{max}^2/(3 \times 2^{2R})} = 3 \times 2^{2R} \times \zeta^2$,这里定义 $\zeta = \frac{\sigma_s}{x_{max}}$ 为量化范围内信号的饱满程度。

+

对数单位下:

+
$$ +SNR_q(dB) = 6.02R + 20\log_{10}(\zeta) + 4.77 +$$
+ +
    +
  • 多一个 bit,$SNR_q$ 提升 $6.02dB$
  • +
  • $\zeta$ 要在合理范围,$\zeta$ 过大时过载会严重劣化性能
  • +
+

最优量化

目标:给定量化区间总数,最小化量化噪声

+

优化问题:

+
$$ +\min \sum\limits_{k=1}^{L}\int_{x_k}^{x_{k + 1}}(x - y_k)^2 p_x(x)\mathrm dx\\ +s.t. x_1\le y_1 \le x_2 \le y_2 \le \dots \le y_L \le x_{L + 1} +$$
+ +

分层电平在重建电平的中点:

+
$$ +\frac{\partial \sigma_q^2}{\partial x_k} = 0\\ +\Rightarrow x_{k, opt} = \frac{1}{2}(y_{k, opt} + y_{k - 1, opt}) +$$
+ +

重建电平在量化区间的质心:

+
$$ +\frac{\partial \sigma_q^2}{\partial y_k} = 0\\ +\Rightarrow y_{k, opt} = \frac{\int_{x_{k, opt}}^{x_{k+1, opt}}xp(x)\mathrm dx}{\int_{x_{k, opt}}^{x_{k+1, opt}}p(x)\mathrm dx} +$$
+ +

对于均匀分布,质心即中点(对于可导的概率分布,当分层很密的时候同样成立)

+
$$ + y_{k, opt} = \frac{\int_{x_{k, opt}}^{x_{k+1, opt}}xp(x)\mathrm dx}{\int_{x_{k, opt}}^{x_{k+1, opt}}p(x)\mathrm dx} = \frac{1}{2}(x_{k, opt} + x_{k + 1, opt}) +$$
+ +

结合

+
$$ +x_{k, opt} = \frac{1}{2}(y_{k, opt} + y_{k - 1, opt}) +$$
+ +

可得均匀分布的最佳量化是区间等分,中点重建

+

工程用量化

+

语音信号的量化

$[-V, V]$ 内均匀量化的缺陷:

+
    +
  • 最适合 $[-V, V]$ 之间的有限分布
  • +
  • 语音信号呈拉普拉斯分布,特点是:
      +
    • 信号功率小
    • +
    • 动态范围大(长拖尾)
    • +
    +
  • +
  • 如果采用均匀量化
      +
    • 较大的V:增大[-V,V]内的量化噪声
    • +
    • 较小的V:增大过载噪声
    • +
    +
  • +
+

解决思路1:非均匀量化

+

语音信号的非均匀量化

+

均匀量化的问题

+
    +
  • 对具有不同“概率权重”的区间“一视同仁”
  • +
  • 没有考虑概率密度对于量化噪声的影响
  • +
+

解决方案

+
    +
  • 对于信号经常出现的区域,使用较细的颗粒度进行量化
      +
    • 信号经常落入这个区域,减小该区域的量化噪声损失
    • +
    +
  • +
  • 对于信号不经常出现的区域,使用较粗的颗粒度进行量化
      +
    • 信号不经常落入这个区域,量化噪声稍大不会影响大局
    • +
    +
  • +
+

采用取对数后均匀量化的方法:

+

+

语音信号的瞬时压扩:

+

+

对数量化

+
    +
  • 正常量化信噪比与信号的分布无关
  • +
  • 过载导致的噪声与信号的分布有关!
  • +
+

记 $\Delta_k$为对数化之前的量化区间, $\Delta_k^\prime = \Delta$ 为对数化之后的量化区间

+

+

实用的对数量化

+

实际工程中,采用另外两个函数(线性放缩,更容易实现):

+
    +
  • A律(欧洲提出,我国采用)
  • +
+
$$ +f(x) = \begin{cases} + \frac{Ax}{1 + \ln A}, 0 \le x \le \frac{1}{A}\\ + \frac{1 + \ln Ax}{1 + \ln A}, \frac{1}{A} \le x \le 1\\ +\end{cases} +$$
+ +
    +
  • ITU G.712建议中取A=87.6

    +
  • +
  • 小信号时,信噪比增加了24dB

    +
  • +
  • μ律(美国提出)

    +
  • +
+
$$ +f(x) = \frac{\ln (1 + \mu x)}{\ln (1 + \mu)}, 0 \le x \le 1 +$$
+ + +
    +
  • ITU G.712建议中取μ=255
  • +
  • 小信号时,信噪比增加了33.5dB
  • +
+

脉冲编码调制(PCM)

+
    +
  • 语音信号的实际压缩编码方式
  • +
  • 包括两个主要步骤
  • +
  • 抽样:$f_s = 8000Hz$
  • +
  • 量化与编码:使用近似对数压扩,每个抽样量化为8位
  • +
  • PCM的输出码率为64kbps
  • +
+

该码率与其推导过程十分重要

+

PCM编码协议

+

基本思想

+
    +
  • 用13折线近似A律
  • +
  • 用15折线近似μ律
  • +
+

+

码字结构:

+
$$ +\mathop{M_1}\limits_{极性码} \quad \underbrace{M_2 \quad M_3 \quad M_4}_{段落码}\quad \underbrace{M_5 \quad M_6\quad M_7 \quad M_8}_{电平码} \quad +$$
+ +

+

例:

+

1250的输出:1 110 0011

+

接收端解码: 1024 + 128 + 64 + 32 = 1248

+

数字基带传输

符号映射

符号集合

+

$M = |\mathcal{A}|$ 为符号集合 $\mathcal{A}$ 的符号数量。

+

bit 承载量
每个符号最多可对应 $r = \log_2|\mathcal{A}|$ 个 bit,称为集合的 bit 承载量

+

数字通信的典型符号:

+
    +
  • ASK
  • +
  • PAM
  • +
  • PSK
  • +
  • QAM
  • +
+

+

邻位最小差错映射:Grey 码

+

相邻符号对应的 bit 串仅有一位差异

+

符号周期(Symbol Period)

+
    +
  • 传输一个符号所需的平均时间
  • +
  • $T_s$
  • +
+

通信速率:

+
    +
  • 符号速率:$R_s = \frac{1}{T_s}$
  • +
  • Bit 速率: $R_b = R_s \log_2 M = \frac{1}{T_s}\log_2 M$
  • +
+

数字调制

基带调制:将时间上离散的符号,加载到时间上形成连续的波形

+

通信信号具有带宽受限特性,因为:

+
    +
  • 自然原因:各类通信线路,如双绞线,同轴电缆,射频功放等均对通过的频率有一定限制
  • +
  • 人为原因:多用户频谱共享通信,如蜂窝无线系统,需约束每路信号的带宽,以免相互干扰
  • +
+

如何产生带限信号?

+

产生一个信号 $s(t) =\sum\limits_{k=-\infty}^{\infty}a_kg(t- k T_s)$,$g(t) = \frac{\sin 2\pi Wt}{2\pi Wt}$是个带限信号。

+
$$ +G(f) = \begin{cases} + 1, |f| \le W,\\ + 0, |f| \gt W +\end{cases} +$$
+ +

让间隔 $T_s$ 的冲击 $a_k\delta(t - kT_s)$ 依次通过冲击响应为 $g(t)$ 的低通滤波器

+

+

Nyquist 准则:无ISI条件

符号间串扰(Inter Symbol Interference, ISI)

+

对 $s(t)$ 采样:

+
$$ +s(nT_s) = a_ng(0) + \underbrace{\sum\limits_{k=-\infty, k\ne n}^{\infty}a_kg\big((n - k)T_s\big)}_{\text{ISI}} +$$
+ +

怎么让 ISI 为0?

+

眼图:观察符号间串扰

+

眼图(Eye Pattern)是直观察看数字基带传输性能的有效方法,用一个示波器

+
$$ +垂直输入 \xrightarrow{接} 匹配滤波器的输出\\ +水平扫描速度 \xrightarrow{设为} 𝑅_𝑠的整数倍 +$$
+ +

alt

+

眼皮的厚度表示 ISI 的失真,眼睛的张开程度表示噪声容限。

+

alt

+

消除 ISI 对带限脉冲的要求

+

时域特征:

+
$$ +\left.\begin{align*} + g(0) &= 1\\ + \sum\limits_{k=-\infty, k\ne n}^{\infty}a_kg\big((n - k)T_s\big) &= 0 +\end{align*}\right\rbrace \Leftrightarrow \sum\limits_{k=-\infty, k\ne n}^{\infty}a_{n - k}g\big(kT_s\big) = 0\\ +\Leftrightarrow g(kT_s) = \begin{cases} + 1, k = 0,\\ + 0, k \ne 0 +\end{cases} \\ +\lrArr g(t)\sum\limits_{n=-\infty}^{\infty}\delta(t + nT_s) = \delta(t) +$$
+ +

从频域提取特征:

+
$$ +g(t)\sum\limits_{n=-\infty}^{\infty}\delta(t + nT_s) = \delta(t) \lrArr G(f) *\sum\limits_{n=-\infty}^{\infty}\frac{1}{T_s}\delta(f + \frac{n}{T_s}) = 1\\ +\lrArr \sum\limits_{n=-\infty}^{\infty}G\left(f + \frac{n}{T_s}\right) = T_s +$$
+ +

Nyquist 准则

+

将带限脉冲的频谱分别平移 $n/T_s$( $n$ 为任意整数)若其叠加的结果对任意频率恒为定值,则 ISI 为0

+

通信速率与带宽效率

理解 Nyquist 准则

+

alt

+

alt

+
    +
  • 最大符号速率受制于带宽 $R_s = \frac{1}{T_s} \le 2W$
  • +
  • 低通发送滤波器应该满足残留对称条件
  • +
+

通信速率与带宽效率

+
$$ +R_s \le 2W\\ +R_b = R_s \log_2 M\\ +\Rightarrow R_b \le 2W \log_2 M +$$
+ +
    +
  • 针对给定形式的低通滤波器,可写出$R_s$与$W$之间的线性函数关系
  • +
+

信号功率与带宽效率

+

设单个符号的能量为 $E_s$

+

则信号功率为单位时间内的能量

+
$$ +P = \frac{E_s}{T_s} = E_sR_s +$$
+ +

无冗余编码时,一个比特的能量为$𝐸_𝑏$,则

+
$$ +P = \frac{E_b\log_2 M}{T_s} = E_bR_b +$$
+ +

带宽效率的定义:单位带宽承载的速率

+
$$ +\eta = \frac{R_b}{W} \le 2\log_2 M +$$
+ + +
    +
  • 为什么不能无限制扩大符号集合?
  • +
+

过大的符号集合对信噪比有更高的要求,噪声容易干扰符号的分辨

+

升余弦滤波器

升余弦滤波器

+

由于理想滤波器难以实现,所以常用满足残留对称条件的非理想低通生成基带脉冲,最常用的就是升余弦滤波器

+

Raised Cosine(要记住)

+
$$ +H(f) = \begin{cases} + T_s, &0 \le |f| \lt \frac{1 - \alpha}{2 T_s}\\ + \frac{T_s}{2}\left\lbrace1 + \cos \left[\frac{\pi T_s}{\alpha}\left(|f| - \frac{1 - \alpha}{2T_s}\right)\right]\right\rbrace, &\frac{1 - \alpha}{2 T_s} \le |f| \le \frac{1 + \alpha}{2 T_s}\\ + 0, & |f| \gt \frac{1 + \alpha}{2 T_s} +\end{cases} +$$
+ +

$\alpha = 2WT_s - 1 \in [0, 1]$ 称为滚降系数,越小坡越陡,越大坡越缓。

+

时域冲激响应:

+
$$ +h(t) = \text{Sa}(\pi t/ T_s)\frac{\cos (\alpha\pi t/ T_s)}{1 - 4(\alpha t/T_s)^2} +$$
+ +

升余弦滤波器的性质:

+

常考性质:

+
$$ +W = \frac{\alpha + 1}{2T_s} = \frac{\alpha + 1}{2}R_s \Rightarrow R_s/2 \le W \le R_s\\ +R_s = \frac{1}{T_s} = \frac{2}{\alpha + 1} W \Rightarrow W \le R_s \le 2W +$$
+ +

带宽效率

+
$$ +\eta_b = \frac{R_s\log_2|\mathcal{S}|}{W} \le 2\log_2|\mathcal S| +$$
+ +

升余弦滤波器的带宽效率

+
$$ +\eta_b = \frac{2\log_2|\mathcal{S}|}{\alpha + 1} +$$
+ +

PCM 语言信号速率 64kbps:8 bit 采样,8 bit 量化,8*8 = 64.

+

例题一:传送一路PCM语音信号

+
    +
  • 若带宽限制为40kHz,采用二元码,则可用滚降系数范围
    是多少?
  • +
  • 若采用四元码,最多需要多少带宽?
  • +
+

解:PCM语音信号是64kbps

+
    +
  • 采用二元码,则所需符号速率为 $R_s = R_b = 64kbps$
  • +
+
    +
  • 则 $\frac{\alpha + 1}{2}64 \le 40$, $0\le \alpha \le 0.25$

    +
  • +
  • 采用四元码:$R_s = \frac{R_b}{\log_24} = 32kbps$

    +
  • +
  • $W \le R_s = 32kHz$

    +
  • +
+

例题二:若传送一路信号$𝑅_𝑏$ = 112kbps,信道带宽𝑊 = 30𝑘bps,
求𝑀和𝛼

+
$$ +\frac{\log_2M}{\alpha} = \frac{R_b}{2W} = \frac{28}{15} \in [1.5, 2]\\ +$$
+ +

认定 $\log_2M = k$ 为整数,则$k = 2 或 3$。对应可解:

+
$$ +\alpha_1 = \frac{1}{14}, M_1 = 4\\ +\alpha_2 = \frac{17}{28}, M_2 = 8 +$$
+ +

通信信号的功率谱计算

功率谱刻画了随机过程的功率在频域上的分布。

+
    +
  • 对于宽平稳过程(自相关只与时差有关),功率谱易于从 $R(\tau)$ 的傅里叶变换得到,即$S(f) = \mathcal{F}[R(\tau)]$
  • +
  • 但是,通信信号一般不是宽平稳过程,而是周期平稳过程:$R(t_1, t_2) = R(t_1 + kT_s, t_2 + kT_s)$
  • +
+

定义

+
$$ +\overline{R}(\tau) = \frac{1}{T_s} \int_{0}^{T_s}R(t+\tau, t)\mathrm dt +$$
+ +

则其功率谱

+
$$ +S(f) = \mathcal{F}[\overline{R}(\tau)] +$$
+ +

若输入信号的功率谱 $S_{AI}(f)$,输出为$S_A(f)$,则对于宽平稳和周期平稳信号均有卷积关系:

+
$$ +S_A(f) = S_{AI}(f)|H(f)|^2 +$$
+ +

证明可以采用样本统计法:假设符号序列的长度为 $2N - 1$.

+
$$ +s_{AI}(t) =\sum\limits_{k=-N}^{N}a_k\delta(t - k T_s)\\ +s_{A}(t) =\sum\limits_{k=-N}^{N}a_kh(t - k T_s)\\ +\hat s_{AI}(f) =\sum\limits_{k=-N}^{N}\exp(-j2k\pi T_sf)\\ +\hat s_{A}(f) = H(f)\sum\limits_{k=-N}^{N}\exp(-j2k\pi T_sf) +$$
+ +

功率谱的定义:

+
$$ +S(f) = \lim\limits_{N\rightarrow\infty} \frac{E(|\hat s(f)|^2)}{(2N + 1)T_s} +$$
+ +

可以验证 $S_A(f) = S_{AI}(f)|H(f)|^2$

+

针对样本统计法,可以算出 $E(|\cdot|^2)$的表达式:

+
$$ +S_A(f) = \frac{|H(f)|^2}{T_s}\sum\limits_{n=-\infty}^{\infty}R_a[n] \exp (-j2n\pi T_s f) +$$
+ +

这里$R_a[m]$ 是输入符号的自相关。

+

先考虑无记忆调制,符号之间相互独立:

+
$$ +R_a[n] = E[a_ia_{i+n}] = \begin{cases} + \sigma_a^2+m_a^2 &n=0\\ + m_a^2 &n\ne 0 +\end{cases} +$$
+ +

其中,$m_a = E[a_n]$,$\sigma_a^2 = E[a_n^2] - m_a^2$

+

于是,重写累加部分:

+
$$ +\begin{align*} + &\sum\limits_{n=-\infty}^{\infty}R_a[n] \exp (-j2n\pi T_s f) \\ + =& \sigma_a^2 + m_a^2\sum\limits_{n=-\infty}^{\infty}\exp\big[-jn(2\pi T_s)f\big]\\ + =& \sigma_a^2 + \frac{1}{T_s}\sum\limits_{n=-\infty}^{\infty}\delta\bigg(f - \frac{n}{T_s}\bigg) +\end{align*} +$$
+ +

从而

+
$$ +S_A(f) = \underbrace{\frac{\sigma_a^2}{T_s}|H(f)|^2}_{连续谱} + \underbrace{\frac{m_a^2}{T_s^2}\sum\limits_{n=-\infty}^{\infty}\bigg|H\bigg(\frac{n}{T_s}\bigg)\bigg|^2 \delta\bigg(f - \frac{n}{T_s}\bigg)}_{线谱} +$$
+ +

此式应用的两个条件:

+
    +
  • 无记忆
  • +
  • 不同符号波形一致
  • +
+

线谱:可用于定时恢复。方便恢复时钟分量。

+

任意波形调制

+

之前将 $a_i$ 映射为 $a_ih(t)$,可以推广:

+
$$ +\forall a_i \ne a_j, s_i(t) \ne s_j(t) +$$
+ +

有时候由于信号功率需要保持稳定(恒包络调制),对不同符号采用不同波形,而不是采用变化幅度的信号。

+

若任意波形二元调制信号 $s(t) =\sum\limits_{k=-\infty}^{\infty}g_k(t)$

+
$$ +g_k(t) = \begin{cases} + s_1(t - kT_s), w.p.\ p\\ + s_2(t - kT_s), w.p.\ \bar p = 1 - p +\end{cases} +$$
+ +

(w. p. = with probability)

+

分解为直流分量和交流分量:

+
$$ +s(t) = \underbrace{E(s(t))}_{DC,记为v(t)} + \underbrace{s(t) - E(s(t))}_{AC, 记q(t)} +$$
+ +

+
$$ +v(t) = \sum\limits_{k=-\infty}^{\infty}[ps_1(t - kT_s) + \bar p s_2(t - kT_s)] +$$
+ +

这是一个周期为$𝑇_𝑠$的确定性周期信号,功率谱由傅里叶展开计算

+
$$ +S_v(f) =\sum\limits_{n=-\infty}^{\infty}|D_n|^2\delta(f - \frac{n}{T_s})\\ +D_n = \frac{1}{T_s}\int_{-T_s/2}^{T_s/2}v(t)e^{-j2\pi t/T_s}\mathrm dt = \frac{1}{T_s}\Big(p\hat s_1\big(\frac{n}{T_s}\big) + \bar p \hat s_2(\frac{n}{T_s}\big)\Big) +$$
+ +
$$ +S_v(f) = \frac{1}{T_s}\sum\limits_{n=-\infty}^{\infty}\bigg|\Big(p\hat s_1\big(\frac{n}{T_s}\big) + \bar p \hat s_2(\frac{n}{T_s}\big)\Big)\bigg|^2 \delta(f - \frac{n}{T_s}) +$$
+ +

用样本统计法计算 $S_q(f)$:

+
$$ +\begin{align*} + S_q(f) =& \lim\limits_{N\rightarrow\infty} \frac{E(|\hat q_N(f)|^2)}{(2N + 1)T_s}\\ + =& \frac{p\bar p}{T_s}|\hat s_1 (f) - \hat s_2(f)|^2 +\end{align*} +$$
+ +
$$ +S(f) = \frac{p\bar p}{T_s}|\hat s_1 (f) - \hat s_2(f)|^2 + \frac{1}{T_s}\sum\limits_{n=-\infty}^{\infty}\bigg|\Big(p\hat s_1\big(\frac{n}{T_s}\big) + \bar p \hat s_2(\frac{n}{T_s}\big)\Big)\bigg|^2 \delta(f - \frac{n}{T_s}) +$$
+ +

基带解调

最佳接收用于在给定发送功率下提高信噪比

+

最佳判决用于在给定信噪比下降低误码率

+

基带传输的噪声模型

alt

+

如何选择解调方案?

+

方案一:直接抽样

+

在信号的峰值位置 $t = kT_s$ 抽样最好。

+

但噪声方差满足:

+
$$ +\sigma^2 = E \lbrace n^2(t_1) \rbrace = R(0) = \frac{n_0}{2}\delta(0) \rightarrow \infty +$$
+ +

(理想的白噪声信号具有无穷大功率)

+

真实的噪声环境下,接收信号质量随着噪声信号功率的增加而变差。如果信号的峰值处恰好噪声很大,则产生严重失真。

+

方案二:能量累积

+

alt

+

噪声信号仍为高斯随机变量:

+
$$ +n = \int_{0}^{T_s}n(t)\mathrm dt +$$
+ +

噪声方差:

+
$$ +\sigma^2 = E\lbrace n^2 \rbrace = \int_{0}^{T_s}\int_{0}^{T_s}\frac{n_0}{2}\delta(t_1 - t_2)\mathrm dt_1\mathrm dt_2 = \frac{n_0T_s}{2} +$$
+ +

信噪比:

+
$$ +\frac{S}{N} = \frac{\left (\int_{0}^{T_s}a_i h(t)\mathrm dt \right)^2}{T_sn_0/2} +$$
+ +

直接积分不是最好的方案。

+

方案三:匹配滤波

+

匹配滤波的基本思想就是对接收值进行加权线性累加,从而最大化抽样时刻信号功率与噪声功率的比值。

+

alt

+

相关器为 $g(t)$。假设信号为实信号。复信号有类似结论。

+
$$ +P_S = \left |\int_{0}^{T_s}a_ih(t)g(t)\mathrm dt \right|^2\\ +P_N = \mathbf E \left [ \left | \int_{0}^{T_s}n(t)g(t)\mathrm dt \right|^2 \right] = \frac{1}{2}n_0 \int_{0}^{T_s}g^2(t)\mathrm dt +$$
+ +

利用 Cauchy-Schwartz 不等式:

+
$$ +\frac{\left |\int_{0}^{T_s}a_ih(t)g(t)\mathrm dt \right|^2}{\frac{1}{2}n_0 \int_{0}^{T_s}g^2(t)\mathrm dt} \le \frac{2}{n_0}\int_{0}^{T_s}a_i^2h^2(t)\mathrm dt +$$
+ +

等号成立当且仅当 $g(t) = kh(t)$。

+

若为复信号,则需要

+
$$ +g(t) = h^*(t) +$$
+ +

如何把相关器写成滤波器形式?

+

(滤波=卷积,相关和卷积就是差一个反褶的关系)

+
$$ +y(t) = [a_ih(t) + n(t)] * h_m(t) = \int_{-\infty}^{\infty}[a_ih(\tau) + n(\tau)]h_m(t - \tau)\mathrm d\tau +$$
+ +

考虑因果系统,一般将符号波形的最高点设置为 $t = T_s$:

+
$$ +y(T_s) = \int_{-\infty}^{\infty}[a_ih(\tau) + n(\tau)]h_m(T_s - \tau)\mathrm d\tau +$$
+ +

与相关器比较得到匹配滤波器的表达式:

+
$$ +h_m(t) = h(T_s - t) +$$
+ +

alt

+

图中的“开关”是抽样。

+

匹配滤波的频域解释:

+
$$ +P_S = \left | \int_{-\infty}^{\infty}H(f)H_m(f)e^{j2\pi fT_s}\mathrm df \right|^2\\ +P_N = \frac{n_0}{2}\int_{-\infty}^{\infty}|H_m(f)|^2\mathrm df\\ +\frac{S}{N} = \frac{\left | \int_{-\infty}^{\infty}H(f)H_m(f)e^{j2\pi fT_s}\mathrm df \right|^2}{\frac{n_0}{2}\int_{-\infty}^{\infty}|H_m(f)|^2\mathrm df} = \frac{2}{n_0}\int_{-\infty}^{\infty}|H(f)|^2\mathrm df +$$
+ +

Cauchy-Schwartz

+
$$ +H_m(f) = H^*(f)e^{-j2\pi fT_s} +$$
+ +

匹配滤波的增益

+

数字传输的优势:数字传输中,基带脉冲h(t)是给定的,在整个码元周期内可以相干累加,而同时让噪声在整个周期内自我抵消

+
$$ +\left (\frac{S}{N} \right)_{\text{match}} \bigg/ \left (\frac{S}{N} \right)_{\text{w.o.match}} = \frac{T_s \int_{0}^{T_s}h^2(t)\mathrm dt}{\left ( \int_{0}^{T_s}h(t)\mathrm dt \right)^2} \ge \frac{T_s \int_{0}^{T_s}h^2(t)\mathrm dt}{\int_{0}^{T_s}1\mathrm dt\int_{0}^{T_s}h^2(t)\mathrm dt} = 1 +$$
+ +

匹配滤波的信噪比

+
$$ +\frac{S}{N} = E \left [ \frac{2}{n_0} \int_{0}^{T_s}a_i^2h^2(t)\mathrm dt \right] = \frac{\int_{0}^{T_s}E[a_i^2]h^2(t)\mathrm dt}{n_0/2} = \frac{E_s}{n_0 / 2} +$$
+ +

分子——传送一个符号的能量

+

分母——噪声谱密度,单位是能量的单位

+

以上采用的是等效基带模型。采用实际物理波形模型:

+
$$ +S = \frac{E_s}{T_s} = E_sR_s\\ +N = Wn_0\\ +\frac{S}{N} = \frac{E_s}{n_0}\frac{R_s}{W}\\ +$$
+ +

两个模型推得的信噪比表达式不同,差异在于等效基带模型使用了匹配滤波器,获得了最优的信噪比:

+
$$ +\frac{R_s}{W} \le 2 \Rightarrow\left (\frac{S}{N} \right)_{\text{max}} = \frac{E_s}{n_0/2} +$$
+ +

从实际物理波形模型来看,上式取等的条件应该是基带脉冲采用的是理想低通(Sa 函数),如果用升余弦滤波

+
$$ +\frac{R_s}{W} = \frac{2}{\alpha + 1} \Rightarrow \left(\frac{S}{N}\right)_{\text{max}} = \frac{E_s}{n_0/2}\frac{2}{\alpha + 1} +$$
+ +

但是,在等效基带模型中,我们考虑的是任意脉冲 $h(t)$,并没有要求它的形状,这两个模型在最优信噪比的产生条件上出现了矛盾?

+

alt

+

alt

+

传送一串符号

alt

+

无 ISI 条件:

+
$$ +h(t)*h_m(t) = h(t) * h(T_s - t)\\ +H(f)H_m(f) = H(f)H^*(f)e^{-j2\pi fT_s} = \left | H(f) \right|^2 e^{-j2\pi fT_s} +$$
+ +

从而有根号奈奎斯特条件:

+
$$ +H(f) = \sqrt{H_{N-I}(f)}e^{-j2\pi fT_s} +H_m(f) = \sqrt{H_{N-I}^*(f)}e^{-j2\pi fT_s} +$$
+ +

这就要求发送和接受滤波器要满足如下要求:

+
$$ +h_T(t) = h_{\sqrt{N}}\left ( t - \frac{T_s}{2} \right)\\ +h_R(t) = h_{\sqrt{N}}\left (\frac{T_s}{2} - t\right) = h_T(T_s - t) +$$
+ +

符号差错模型:

alt

+
$$ +y_i = \bar h a_i + n_i +$$
+ +

alt

+

判决与差错

最佳判决

ima

+

ima

+

alt

+

多元符号的最佳判决

+
$$ +a^* = \argmax_{a\in U} f(y|a)f(a)\\ +f(a) = \frac{1}{M}\\ +a^* = \argmax_{a\in U} f(y|a)\\ +$$
+ +

$y = a + n$ 的条件分布是

+
$$ +f(y|a) = \frac{1}{\sqrt{2\pi\sigma^2}}\exp\left(-\frac{(y - a)^2}{2\sigma^2}\right) +$$
+ +

从而得到

+
$$ +a^* = \argmin_{a\in U} |y - a| +$$
+ +

选择一个符号,让它到接收符号y距离最小,以此作为判决结果!

+

双极性码的判决门限:

+

alt

+

单极性码的判决门限:

+

alt

+

SER & BER

考虑二元符号

+

发送 A 的出错概率:

+
$$ +\int_{-\infty}^{0}f(y|a = A)\mathrm dy = \int_{A/\sigma}^{\infty}\frac{1}{\sqrt{2\pi}}\exp \left ( -\frac{t^2}{2} \right)\mathrm dt = Q \left ( \frac{A}{\sigma} \right) +$$
+ +

发送 -A 的出错概率:

+
$$ +\int_{-\infty}^{0}f(y|a = A)\mathrm dy = Q \left ( \frac{A}{\sigma} \right) +$$
+ +

从而平均符号差错概率:

+
$$ +P_s = \frac{1}{2}\left (Q \left ( \frac{A}{\sigma} \right) + Q \left ( \frac{A}{\sigma} \right) \right) = Q \left ( \frac{A}{\sigma} \right) +$$
+ +

称为符号差错概率(Symbor Error Probability, SEP),其统计结果称为误符号率(Symbol Error Ratio, SER)

+

由于Q是减函数,所以误符号率随A增大而减小,随噪声标准差增大而增大

+

误符号率不关心具体的A或标准差,而是由其比值所决定

+

对于多元而言:

+

对于任意符号集合,只要某判决门限与符号距离为A,则由于超出该判决门限而差错的条件概率就是:

+
$$ +Q \left ( \frac{A}{\sigma} \right) +$$
+ +

计算信噪比:

+

信号平均功率: $S = \frac{1}{M}\sum\limits_{i=1}^{M}|a_i|^2$

+

信号峰值功率: $S_p = \max_{a_i \in U} |a_i|^2$

+

噪声功率: $N = \sigma^2$

+

对于双极性二元符号,平均功率为 $S = A^2$

+

从而信噪比为

+
$$ +\frac{S}{N} = \frac{A^2}{\sigma^2} +$$
+ +

利用等效关系得到误符号率和信噪比的关系

+
$$ +P_s = Q \left ( \frac{A}{\sigma} \right) = Q \left ( \sqrt{\frac{S}{N}} \right) +$$
+ +

更一般的二元码 SER

+
$$ +U = \lbrace D-A, D+A \rbrace\\ +\zeta = \frac{D}{A}\\ +P_s = Q(\sqrt{\frac{S}{(1 + \zeta^2)N}}) +$$
+ +

更一般的 M 元码 SER

+

符号集合为 $\lbrace D - (M - 1)A, \dots, D + (M - 1)A \rbrace$

+
$$ +\zeta = \frac{D}{A\sqrt{\frac{M^2 - 1}{3}}}\\ +P_s = \frac{2(M - 1)}{M}Q \left ( \sqrt{\frac{3}{M^2 - 1}\frac{S}{(1 + \zeta^2)N}} \right) +$$
+ +

双极性 M 元码的 SER (掌握计算方法)

+
$$ +P_s = \frac{2(M - 1)}{M } Q \left ( \sqrt{\frac{3}{M^2 - 1} \frac{S}{N}}\right) +$$
+ +

无论M为奇数还是偶数,结果都是一样的!

+

单极性 M 元码的 SER (掌握计算方法)

+
$$ +P_s = \frac{2(M - 1)}{M } Q \left ( \sqrt{\frac{3}{2(M - 1)(2M - 1)} \frac{S}{N}}\right) +$$
+ + +

要使得双极性和单极性码的 SER 相同,二者的信噪比的比值为

+
$$ +\left ( \frac{S}{N} \right)_d \bigg / \left ( \frac{S}{N} \right)_s = \frac{M^2 - 1}{2(M - 1)(2M - 1)} \approx \frac{1}{4} +$$
+ +

显然,双极性的性能更好,它对信噪比的要求是单极性的四分之一,更能忍受噪声。

+

误比特率(Bit Error Rate, BER):

+
$$ +P_b \approx \frac{P_s}{\log_2M} +$$
+ +

注意这是近似结果,且有成立条件,只对二元码是严格成立的!

+
    +
  • 假设一个符号的错判导致 1bit 的错误,假设成立的条件:
      +
    • Grey 码映射
    • +
    • 信噪比不过于小
    • +
    +
  • +
+

各类符号集合的 BER

+

双极性二元码

+
$$ +P_b = Q \left ( \sqrt{\frac{S}{N}} \right) +$$
+ +

单极性二元码

+
$$ +P_b = Q \left ( \sqrt{\frac{S}{2N}} \right) +$$
+ +

单极性二元码损失了 3 dB.

+

双极性 M 元码

+
$$ +P_b = \frac{2(M - 1)}{M\log_2 M}Q(\sqrt{\frac{3}{M^2 - 1}\frac{S}{N}}) +$$
+ +

单极性 M 元码

+
$$ +P_b = \frac{2(M - 1)}{M\log_2 M} Q \left ( \sqrt{\frac{3}{2(M - 1)(2M - 1)} \frac{S}{N}}\right) +$$
+ +

由于

+
$$ +\frac{S}{N} = 2\log_2 M\frac{E_b}{n_0} +$$
+ +

故可以把 SER 和 BER 用 $E_b/n_0$ 表示:

+

双极性二元码:

+
$$ +P_s = Q \left ( \sqrt{\frac{2E_b}{n_0}} \right)\\ +P_b = Q \left ( \sqrt{\frac{2E_b}{n_0}} \right) +$$
+ +

单极性二元码:

+
$$ +P_s = Q \left ( \sqrt{\frac{E_b}{n_0}} \right)\\ +P_b = Q \left ( \sqrt{\frac{E_b}{n_0}} \right) +$$
+ +

双极性 M 元码:

+
$$ +P_s = \frac{2(M - 1)}{M}Q(\sqrt{\frac{6\log_2 M}{M^2 - 1}\frac{E_b}{n_0}})\\ +P_b = \frac{2(M - 1)}{M\log_2 M}Q(\sqrt{\frac{6\log_2 M}{M^2 - 1}\frac{E_b}{n_0}}) +$$
+ +

单极性 M 元码:

+
$$ +P_s = \frac{2(M - 1)}{M} Q \left ( \sqrt{\frac{3\log_2 M}{(M - 1)(2M - 1)} \frac{E_b}{n_0}}\right)\\ +P_b = \frac{2(M - 1)}{M\log_2 M} Q \left ( \sqrt{\frac{3\log_2 M}{(M - 1)(2M - 1)} \frac{E_b}{n_0}}\right) +$$
+ +

例子:相移键控 MPSK

+
$$ +\begin{align*} + S_{MPSK}(t) =& \sum\limits_{n}^{}g(t - nT_s)A\cos(\omega_c t + \phi_n)\\ + =& \left [\sum\limits_{n}^{}A\cos \phi_n g(t - nT_s) \right]\cos \omega_c t + \left [\sum\limits_{n}^{}A\sin \phi_n g(t - nT_s) \right]( - \sin \omega_c t) +\end{align*} +$$
+ +
    +
  • 所有符号的模相同
  • +
  • 幅角在 $[0, 2\pi]$ 均匀分布
  • +
+

可以用星座图表示:

+

alt

+

根据信号的 $I, Q$ 表示

+

计算 MPSK 的 SER:

+

考虑星座点 $(A, 0)$

+

接收信号的分布函数为

+
$$ +f(a, b) - \frac{1}{2\pi \sigma_n^2}\exp \left ( -\frac{(a - A)^2 + b^2}{2\sigma_n^2} \right) +$$
+ +

变换到极坐标系

+
$$ +f(\rho, \theta) = \frac{\rho}{2\pi\sigma_n^2}\exp \left ( -\frac{\rho^2 + A^2 - 2A\rho\cos\theta}{2\sigma_n^2} \right)\\ +f(\theta) = \int_{0}^{\infty}f(\rho, \theta)\mathrm d\rho = \frac{1}{2\pi}\exp \left ( -\frac{A^2}{2\sigma_n^2}\sin^2\theta \right)\int_{0}^{\infty}\rho\exp \left (-\frac{(\rho - A/\sigma_n\cos\theta)^2}{2} \right)\mathrm d\rho +$$
+ +

误符号率可以表示为

+
$$ +P_{s, MPSK} = 1 - \int_{-\pi/M}^{\pi/M}f(\theta)\mathrm d\theta +$$
+ +

用信噪比表示:

+
$$ +f(\theta) = \int_{0}^{\infty}f(\rho, \theta)\mathrm d\rho = \frac{1}{2\pi}\exp \left ( -\frac{S}{2N}\sin^2\theta \right)\int_{0}^{\infty}\rho\exp \left (-\frac{(\rho - \sqrt{S/N}\cos\theta)^2}{2} \right)\mathrm d\rho +$$
+ +

如果 $S/N$ 很大:

+
$$ +\begin{align*} + \int_{0}^{\infty}\rho\exp \left (-\frac{(\rho - \sqrt{S/N}\cos\theta)^2}{2} \right)\mathrm d\rho \approx& \int_{-\infty}^{\infty}\rho\exp \left (-\frac{(\rho - \sqrt{S/N}\cos\theta)^2}{2} \right)\mathrm d\rho\\ + =& \sqrt{\frac{S}{N}}\cos\theta +\end{align*} +$$
+ +

利用高信噪比近似:

+
$$ +f(\theta) = \sqrt{\frac{S}{2\pi N}}\cos\theta \exp \left ( -\frac{S}{2N}\sin^2\theta \right) +$$
+ +

当 M 比较大时:

+
$$ +\begin{align*} + P_{s, MPSK} =& 1 - \int_{-\pi/M}^{\pi/M}\sqrt{\frac{S}{2\pi N}}\cos\theta \exp \left ( -\frac{S}{2N}\sin^2\theta \right)\mathrm d\theta\\ + \approx& \frac{2}{\sqrt{\pi}}\int_{\pi/M}^{\infty}\sqrt{\frac{S}{2N}}\cos\theta\exp \left ( -\frac{S}{2N}\sin^2\theta \right)\mathrm d\theta\\ + =& \frac{2}{\sqrt{2\pi}}\int_{\pi/M}^{\infty}\exp \left ( -\frac{S}{2N}\sin^2\theta \right)\mathrm d\sqrt{\frac{S}{N}}\sin\theta\\ + =& \frac{2}{\sqrt{2\pi}} \int_{\sqrt{S/N}\sin\pi/M}^{\infty}\exp \left ( -\frac{u^2}{2} \right)\mathrm du\\ + =& 2Q \left ( \sqrt{\frac{S}{N}}\sin\frac{\pi}{M} \right) +\end{align*} +$$
+ +

换算成 BER, $E_b/n_0$

+
$$ +P_{b, MPSK} = \frac{2}{\log_2M}Q \left ( \sqrt{2\log_2M\frac{E_b}{n_0}}\sin\frac{\pi}{M} \right) +$$
+ +

一个简单的方法:

+

看起来像是先射箭后画靶。

+

alt

+

例子2:正交幅度调制 QAM

+

信号表示

+
$$ +\begin{align*} + S_{MQAM}(t) =& \left [\sum\limits_{n}^{}a_n g(t - nT_s) \right]\cos \omega_c t + \left [\sum\limits_{n}^{}b_n g(t - nT_s) \right]( - \sin \omega_c t) +\end{align*} +$$
+ +

I,Q 两路的电平集合:

+
$$ +a_n\in \lbrace \pm A, \dots, \pm(M - 1)A \rbrace\\ +b_n\in \lbrace \pm A, \dots, \pm(M - 1)A \rbrace\\ +$$
+ +

QAM是一种典型的星座图,它分布于复平面的格点上,其符号的实虚部均为奇数(便于分析)

+

解调过程:

+

I 路信息提取:乘以同相载波 $\cos\omega_c t$,再低通滤波

+

Q 路信息提取:乘以同相载波 $-\sin\omega_c t$,再低通滤波

+

差错分析:

+

alt

+

(通过后面的分析可以发现,降低误码率的关键是将符号间的最小距离最大化)

+

计算各符号的差错概率:

+

四个角:

+
$$ +P_s = 1 - \left [ 1 - Q \left ( \frac{A}{\sigma} \right) \right]^2 +$$
+ +

$4(L - 2)$ 个边点:

+
$$ +P_s = 1 - \left [ 1 - Q \left ( \frac{A}{\sigma} \right) \right]\left [ 1 - 2Q \left ( \frac{A}{\sigma} \right) \right] +$$
+ +

$(L - 2)^2$ 个内点:

+
$$ +P_s = 1 - \left [ 1 - 2Q \left ( \frac{A}{\sigma} \right) \right]^2 +$$
+ +

计算平均 SEP:

+
$$ +\begin{align*} + P_s =& \frac{1}{L^2}\lbrace 4(2Q - Q^2) + 4(L - 2)(3Q - 2Q^2) + (L - 2)^2(4Q - 4Q^2) \rbrace\\ + \approx& \frac{4L^2 - 4L}{L^2}Q \left ( \frac{A}{\sigma_n} \right) +\end{align*} +$$
+ +

省略了 $Q$ 的高阶量。

+

计算平均功率:

+
$$ +S = 2 \times \frac{2A^2}{L}[1^2 + 3^2 + \dots + (L - 1)^2] = \frac{2(L^2 - 1)}{3}A^2 +$$
+ +

是同A的LPAM功率的两倍。因为MQAM有两路LPAM

+

得到 SEP:

+
$$ +P_s = \frac{4M - 4L}{M} Q \left (\sqrt{\frac{3}{2(M - 1)}\frac{S}{N}} \right)\\ +M = L^2 +$$
+ +

得到 BEP:

+
$$ +P_b = 4 \left (1 - \frac{1}{\sqrt M} \right) Q \left (\sqrt{\frac{3\log_2M}{2(M - 1)}\frac{E_b}{n_0}} \right) \approx 4Q\left (\sqrt{\frac{3\log_2M}{2(M - 1)}\frac{E_b}{n_0}} \right)\\ +$$
+ +

注意到MQAM可以看成两路正交的MPAM

+
$$ +\begin{align*} + P_{s, MQAM} =& 1 - (1 - P_{LPAM})^2\\ + \approx& 2P_{LPAM}\\ + =& 4 \left ( 1 - \frac{1}{\sqrt M} \right)Q \left ( \sqrt{\frac{3}{(M - 1)}\frac{S/2}{N}} \right) +\end{align*} +$$
+ +

这个推导方式更简单。

+

QAM 是在独立解映射条件下最好的方案。但是距离高斯信道容量还有一定距离。要达到更好的信道容量,可以采用联合解映射,将译码过程联合起来。

+

例子3:频移键控 FSK

+

一般来说,信号表达式和调制框图的相互反演是比较容易做的

+

相对于PAM,PSK和QAM,FSK占用更大的频带,

+

相干解调

+

Coherent Demodulation

+
    +
  • 反思FSK非相干解调方式,如果对每个频率的载波进行匹配,则可以提高信噪比

    +
  • +
  • 这种方法需要本地子载波

    +
  • +
  • 解调器的结构和非相干解调很像

    +
  • +
  • 无法用星座图方法表示,但是可以用类似的信号空间表示

    +
  • +
  • 若MFSK载频等间隔,则调制阶数约高,占用带宽越大

    +
  • +
  • 如果每次可以选择多个载频,甚至控制载频幅度,则可承载的符号量可以获得极大提升。由此便引申出OFDM技术

    +
  • +
+
    +
  • 通过调制FSK的每个载波的幅度相位,可以承载更多的信息
  • +
+

星座图没法表述 FSK. 可以使用信号空间方法来表示。

+

差错分析:

+

FSK 的判决门限为棱锥形状:

+

alt

+

根据对称性,可以只考虑一个符号的差错概率。

+

考虑 FSK 信号

+
$$ +[A, 0, \dots, 0] +$$
+ +

匹配滤波的输出为

+
$$ +[A + n_1, n_2, \dots, n_M] +$$
+ +

正确判决:信号落在本棱锥中

+
$$ +A + n_1 \gt n_i, i = 2, \dots, M +$$
+ +

被判决符号的条件分布为

+
$$ +f_{[A + n_1, n_2, \dots, n_M]}(\vec r) = \frac{1}{\sqrt{2\pi \sigma^2}}\exp \left ( -\frac{(r_1 - A)^2}{2\sigma^2} \right)\prod_{i = 2}^M\frac{1}{\sqrt{2\pi \sigma^2}}\exp \left ( -\frac{r_i^2}{2\sigma^2} \right) +$$
+ +

不满足正确判决条件的概率为

+
$$ +\begin{align*} + P_s =& 1 - \int_{-\infty}^{\infty}\frac{1}{\sqrt{2\pi \sigma^2}}\exp \left ( -\frac{(r_1 - A)^2}{2\sigma^2} \right)\prod_{i = 2}^M \int_{-\infty}^{r_1}\frac{1}{\sqrt{2\pi \sigma^2}}\exp \left ( -\frac{r_i^2}{2\sigma^2} \right)\mathrm dr_i\mathrm dr_1\\ + =&1 - \int_{-\infty}^{\infty}\frac{1}{\sqrt{2\pi \sigma^2}}\exp \left ( -\frac{(r_1 - A)^2}{2\sigma^2} \right)\left (\int_{-\infty}^{r_1}\frac{1}{\sqrt{2\pi \sigma^2}}\exp \left ( -\frac{r_i^2}{2\sigma^2} \right)\mathrm dr_i \right)^{M - 1}\mathrm dr_1 +\end{align*} +$$
+ +

记 $x = \frac{r_1}{\sigma}$

+
$$ +\begin{align*} + P_s =& 1 - \int_{-\infty}^{\infty}\frac{1}{\sqrt{2\pi }}\exp \left ( -\frac{(x - A/\sigma)^2}{2} \right)\left (1 - Q(x)\right)^{M - 1}\mathrm dx\\ + =& 1 - \frac{1}{\sqrt{2\pi }}\int_{-\infty}^{\infty}\exp \left ( -\frac{u^2}{2} \right)\left (1 - Q \left (u + \frac{A}{\sigma} \right)\right)^{M - 1}\mathrm du +\end{align*} +$$
+ +
$$ +\frac{A}{\sigma} = \sqrt{\frac{S}{N}} = \sqrt{\log_2M\frac{2E_b}{n_0}} +$$
+ +

可得 SEP 的表达式

+
$$ +\begin{align*} + P_s =& 1 - \frac{1}{\sqrt{2\pi }}\int_{-\infty}^{\infty}\exp \left ( -\frac{u^2}{2} \right)\left (1 - Q \left (u + \sqrt{\frac{S}{N}} \right)\right)^{M - 1}\mathrm du\\ + =& 1 - \frac{1}{\sqrt{2\pi }}\int_{-\infty}^{\infty}\exp \left ( -\frac{u^2}{2} \right)\left (1 - Q \left (u + \sqrt{\log_2M\frac{2E_b}{n_0}} \right)\right)^{M - 1}\mathrm du +\end{align*} +$$
+ +

另一种简单估界:

+

alt

+

正交 2FSK 信号在最佳接收条件时的错误概率为

+
$$ +P_{b,NCFSK} = Q(\sqrt{E_b/n_0}) +$$
+ +

随着 M 的增加,MFSK 的差错性能渐优,这是以带宽的占用为代价的。

+

PAM, QAM, ASK 等技术随着符号个数的增加,差错性能是越来越差。

+

FDM——Frequency Division Multiplexing

+
    +
  • 先将各路信号调制到不同频段,然后复用整个
    通信带宽
  • +
  • 信道的非线性会在FDM系统中产生交调失真与
    高次谐波,引起路际串话,因此,对信道的非
    线性失真要求很高。此外,FDM用到的模拟滤
    波器设计较为复杂。
  • +
+

OFDM 基本原理

Orthogonal Frequency division multiplexing

+
    +
  • 把一串高速数据流分解为若干速率低得多的子数据流。
  • +
  • 将每个子数据流放置在对应的子载波上。
  • +
  • 将多个子载波合成,一起并行传输。
  • +
  • 优点:频谱利用率高。
  • +
+

正交性的定义:

+
$$ +\int_{0}^{T}S_1(t)S_2(t)\mathrm dt = 0 +$$
+ +

设相邻子载波的频率间隔为 $1 / T$,$T$ 为 OFDM 符号的持续时间,则
任意一对子载波的内积满足

+
$$ +\frac{1}{T}\int_{0}^{T}e^{j2\pi \frac{k_1}{T}t}e^{-j2\pi \frac{k_2}{T}t}\mathrm dt = \begin{cases} + 1, k_1 = k_2\\ + 0, k_1 \ne k_2 +\end{cases} +$$
+ +

带宽 $W$ 和 $B$ 的区别:

+

物理带宽 $W$

+

信号带宽 $B$:半功率带宽(3dB),等效噪声带宽,谱零点带宽,功率比例带宽,最低功率谱带宽

+

带通信号的表示方法

$$ +x(t) = A(t) \cos [\omega_c t + \varphi (t)]\\ +$$
+ +

同相分量:$x_I(t) = A(t) \cos(\varphi(t))$

+

正交分量:$x_Q(t) = A(t) \sin(\varphi(t))$

+

与幅度相位的关系:

+
$$ +A(t) = \sqrt{x_I^2(t) + x_Q^2(t)}\\ +\varphi(t) = \tan^{-1} \left [ \frac{x_Q(t)}{x_I(t)} \right] +$$
+ +

带通信号的基带表示的方法

+
$$ +x_{bb}(t) = x_I(t) + jx_Q(t)\\ +$$
+ +

解析信号表示

+
$$ +x_A(t) = x_{bb}(t)e^{j\omega_ct}\\ +x(t) = \real \lbrace {x_A(t)} \rbrace = \real \lbrace x_{bb}(t)e^{j\omega_ct} \rbrace +$$
+ +

原始带通信号是解析信号的实部

+

从带通信号恢复基带信号?

+
$$ +\breve{x}(t) = x(t) \circledast h(t)\\ +h(t) = \frac{1}{\pi t}\\ +\breve{x}(t) = \frac{1}{\pi} \int_{-\infty}^{\infty}\frac{s(\tau)}{t - \tau}\mathrm d\tau\\ +H(f) = -j \cdot \text{sgn}(f) = \begin{cases} + -j, &f\gt 0\\ + 0, &f=0\\ + j, &f < 0 +\end{cases} +$$
+ +

构造解析信号

+
$$ +x_A(t) = x(t) + j\breve{x}(t)\\ +$$
+ +

频谱分析

+
$$ +X_A(\omega) = [1 + \text{sgn}(\omega)]X(\omega) = \begin{cases} + 2X(\omega), &\omega \gt 0\\ + X(0) = 0, &\omega = 0\\ + 0, &\omega \lt 0 +\end{cases}\\ +X_{bb} = X_A(\omega + \omega_c) +$$
+ +

带通信道

+

具有实数值的信道冲激响应(CIR) $h(t)$

+

等效的解析冲激响应 $h_A(t) = h(t) + j\breve{h}(t)$

+

任意载波频率 $\omega_c$ 的等效基带冲激响应CIR

+
$$ +h_{bb}(t) = h_A(t) \cdot e^{-j\omega_c t} +$$
+ +

带通收发信号关系 $y(t) = x(t) * h(t)$,则

+
$$ +Y(\omega) = H(\omega) X(\omega)\\ +Y_A(\omega) = H_A(\omega)X_A(\omega)\\ +Y_A(\omega) = [H(\omega) \cdot \frac{1}{2}\left (1 + \text{sgn}(\omega) \right)]X_A(\omega) = \left [ \frac{1}{2}H_A(\omega) \right]X_A(\omega) +$$
+ +

$H_A(\omega)$ 只有正半轴部分

+
$$ +Y_{bb}(\omega) = Y_A(\omega + \omega_c) = \left [ \frac{1}{2}H_A(\omega + \omega_c) \right]X_A(\omega + \omega_c) = H(\omega + \omega_c) X_{bb}(\omega) +$$
+ +

基带等效系统

+
$$ +y_{bb}(t) = \frac{1}{2}h_{bb}(t) * x_{bb}(t)\\ +Y_{bb}(\omega) = H(\omega + \omega_c) X_{bb}(\omega) +$$
+ +

基带时域转移函数 $\frac{1}{2}h_{bb}(t)$

+

基带频域转移函数 $H(\omega + \omega_c)$

+

用正交基观点构造了信号波形

+
$$ +x(t) = \sqrt{2}\cos 2\pi f_c t \sum\limits_{k=-\infty}^{\infty}x^I_kg(t - kT_s) + \sqrt{2}\sin 2\pi f_c t \sum\limits_{k=-\infty}^{\infty}x^Q_kg(t - kT_s) +$$
+ +

投影后的噪声:

+
$$ +E \lbrace n_k^In_l^Q \rbrace = 0\\ +E \lbrace n_k^In_l^I \rbrace = \delta_{kl}\\ +E \lbrace n_k^Qn_l^Q \rbrace = \delta_{kl} +$$
+ +

等效符号差错模型

+
$$ +y_k = x_k + n_k\\ +n_k \sim \mathcal{CN}(0, n_0) +$$
+ +

差错控制

差错控制的分类:

+
    +
  • 检错重发 (ARQ)
  • +
  • 前向纠错 (FEC)
  • +
+

前向纠错的分类:

+
    +
  • 线性码,非线性码
  • +
  • 分组码(重点),卷积码
  • +
  • 系统码,非系统码
  • +
+

编码增益

+

给定误比特率的情况下,采用纠错编码后,$E_b/n_0$的减小量称为编码增益。

+

简单例子:

+

重复编码

+

BSC 重传三次:

+
$$ +3p_e^2(1 - p_e) + p_e^3 \approx 3p_e^2 +$$
+ +

信道编码:通过合理得增加冗余信息,纠正信道传输中可能出现的错误

+
    +
  • 又称为纠错码(Error Correction Coding)
  • +
+

理想信道编码的局限性:

+
    +
  • 码长无穷大
  • +
  • 没发现代数结构,复杂度太大
  • +
+

如何实用化:

+
    +
  • 有限长。代价:误码率非零,效率低
  • +
  • 有代数结构。优点:便于译码
  • +
+

评价标准

+
    +
  • 误比特率:评价可靠性
  • +
  • 码率:评价有效性
  • +
+

分组码

奇偶监督码

+
    +
  • 检错,而非纠错
  • +
  • 电路实现简单
  • +
+

漏检概率:

+
$$ +P_m =\sum\limits_{i=1}^{\lfloor\frac{n}{2}\rfloor}\binom{n}{2i}\varepsilon^{2i}(1 - \varepsilon)^{n - 2i} +$$
+ +

群计数码

+
    +
  • 累计信息码元中1的个数,以二进制形式放在信息码元后面
  • +
  • 检错能力
      +
    • 强于奇偶校验码
    • +
    • 当{1变0数量=0变1数}时,无法检出
    • +
    +
  • +
+

纠错码的直观表示

+
    +
  • 码字
      +
    • 对应 $n$ 维空间的点
    • +
    +
  • +
+

Hamming 距离:两个码字之间不同码元的个数

+

Hamming 距离

+
    +
  • $x_m$ 和 $x_m^\prime$ 中不同取值的位置数 $d_H(\mathbf x_m, \mathbf x_m^\prime)$
  • +
  • 即模2和中1的个数
  • +
+

汉明码重

+
    +
  • 二进制向量 $\mathbf x_m$ 1的个数 $w(\mathbf x_m)$
  • +
+

最小距离

+

一个分组码中任意两个码字的最小汉明距离 $d_{\text{min}}$

+

(n,k)纠错码

$$ +B = E + A, \forall A \in \chi\\ +S = BH^T = EH^T\\ +$$
+ +

$S$ 与 $A$ 无关,$A$ 只是无用的陪同(coset)。

+

陪集首:上述陪集的特征由 $S = EH^T$ 标识,我们称 $E$ 为陪集首。

+

陪集首一般选择集合中 “1” 最少的元素,这是为了优先标识错误数量较小的差错,这一类差错发生的概率较大。

+

码重:

+
$$ +w(A) =\sum\limits_{i=1}^{n}\mathbf 1 \lbrace a_i = 1 \rbrace = d_H(A, 0) +$$
+ +

001 -> 0,0,0,0,0,1 -> 101

+

010 -> 0,0,0,0,1,0 -> 011

+

011 -> 0,0,0,1,0,0 -> 110

+

100 -> 0,0,1,0,0,0 -> 001

+

101 -> 0,1,0,0,0,0 -> 010

+

110 -> 1,0,0,0,0,0 -> 100

+

111 -> 0,1,0,0,0,1 -> 111

+

交织器

线性码的改进:

+
    +
  • 上述线性码,均适合于纠正零散错误
  • +
  • Hamming码对于2个以上的差错就无能为力
  • +
  • 若差错总是成对出现,则Hamming码基本没用
  • +
  • 在通信系统中,往往存在不可抗拒的突发错误
  • +
+

例如:无线信道的衰落引起的误码

+

抗突发误码的方法:交织器

+

基本原理

+
    +
  • 为了对付突发的信道差错,交织器改变发送码元的时
    间顺序
  • +
  • 将原本相邻的码元在时间上的距离最大化
  • +
  • 例子:考虑一个(n, k)分组码,其交织后的输出为
  • +
+

将突发误码转换成零星误码

+

交织器的性能:

+

宽度

+
    +
  • 就是分组码的码长n
  • +
  • 决定于所采用的分组码
  • +
+

深度

+
    +
  • 深度m决定了相邻码元交织后的间隔
  • +
  • m又称交织深度
  • +
  • 若分组码能纠b个突发错误,则交织后能纠mb个突发错误
  • +
+

解交织:

+
    +
  • 从另一个角度来看,解交织打散了突发误码
  • +
  • 化整为零后的零散误码,就可以交给解码器对付了
  • +
+

卷积码

输入无限长的激励,则输出信号无限长,

+

若冲激响应有限,则输出只与某一段输入有关

+

卷积码的参数 $n, k, N$

+

约束长度,信息码位,每次输出

+

使用树状图进行分类讨论

+

树状图的冗余:

+
    +
  • 树状图具有很多冗余表示
  • +
+

树状图的应用:计算最小码距

+
    +
  • 分组码的最小码距定义为非零码字的最小码重
  • +
  • 和分组码不同,卷积码没有分组的概念
  • +
  • 约束长度隐含了某种独立性,可以只考虑 $kN$ 的信息比特编码后的非零码字,也就是考虑 $nN$ 个非零的编码输出位
  • +
+

状态图的应用

+
    +
  • 自由距:无限长信息序列编码后的最小汉明距离
  • +
  • 自由距不等于最小距
  • +
+

自由距等于寄存器从零状态开始,经过非零状态,然后回到零状态的输出1的个数的最小值

+

卷积码的译码

+

维特比译码

网格图

+

最大似然下的最优译码

+
    +
  • 低复杂度
  • +
  • 采用最小汉明距离作为代价函数
  • +
+

采用动态规划的卷积码译码成为 viterbi 译码

+
    +
  • viterbi 译码的起始状态是 0 状态
  • +
  • viterbi 译码没有确定的代价函数,
  • +
+

分组码译码可以知道是否译码错误了。通过校验矩阵来校验就行了。

+

但是 viterbi 译码并不能肯定译码结果是否正确。

+

硬判决和软判决

硬判决:任务是检测和矫正误码

+

软判决:应用于卷积/ Viterbi 译码器,迭代译码

+

检错重发 ARQ

$P_c = (1 - \varepsilon)^n$ 为正确概率

+

$P_d$ 检出错误概率

+

$P_m$ 漏检概率

+
$$ +P_c + P_d + P_m = 1 +$$
+ +

总分组差错概率

+
$$ +P_b = P_m + P_dP_m + P_d^2P_m + \dots = \frac{P_m}{1 - P_d} = \frac{P_m}{P_c + P_m} +$$
+ +

停等ARQ

收到上一个 ACK/NAK 再发送下一个包或者重传上一个包

+

假设发送方一直传输(一次就能传输成功),吞吐量的上限为

+
$$ +\eta_{sw, 0} = \frac{k}{T_DR}\\ +T_D = T_m + 2 T_d + T_c + T_a = T_m + T_{dca} = \frac{k}{n + T_{dca}R} +$$
+ +

若有完美的差错检出能力 $P_d = 1 - (1 - \varepsilon)^n$

+

+
$$ +\eta_{sw} = \frac{k/n}{1 + T_{dca}R/n}(1 - \varepsilon)^n +$$
+ +

返回 N-ARQ

不等 ACK/NAK 返回就传下一个包,若检错则重传从错误开始的所有包

+
$$ +\eta_{GBN, 0} = \frac{k}{n} +$$
+ +
\ No newline at end of file diff --git a/2023/09/20/Digital-Signal-Processing/index.html b/2023/09/20/Digital-Signal-Processing/index.html new file mode 100644 index 00000000..1220acd8 --- /dev/null +++ b/2023/09/20/Digital-Signal-Processing/index.html @@ -0,0 +1,1234 @@ +Digital Signal Processing | Guo_Yun + + + + + + + + + + + + + + + + + + +

Digital Signal Processing

绪论

信号

信号是某种随时间或/和空间变化的物理量,其包含有从信源到信宿的某种信息。

+

信号可以根据时间和幅度的取值方式分类

+
    +
  • 连续时间信号
  • +
    • +
    • 在时间和幅度上均可以连续取值的信号
    • +
    +
  • +
  • 离散时间信号
  • +
    • +
    • 仅在离散时间点上取值,但可在幅度上连续取值的
      信号
    • +
    +
  • +
  • 数字信号
  • +
    • +
    • 仅在离散时间点上取值,且在幅度上只能离散取值
      的信号
    • +
    +
  • +
+

系统

    +
  • 由若干相互作用和相互依赖的事物组合而成的具有特
    定功能的整体
  • +
  • 具有它自身的结构、行为和性质,通过输入和输出与
    其所处的环境进行交互,通常实现一定的功能
  • +
  • 可通过分析给定输入下输出的性质,来研究其行为和
    性质
  • +
+

信号处理系统

+
    +
  • 对信号进行某种操作的单元或模块
  • +
  • 从数学上看,可视为作用于函数上的算子
  • +
+

通常根据信号处理单元而非输入输出信号性质分类

+
    +
  • 连续(模拟)信号处理系统
  • +
    • +
    • 由电阻、电容、电感和放大器等组成的模拟电路完成信号处
      理功能
    • +
    +
  • +
    • +
    • 直接处理连续信号
    • +
    +
  • +
  • 离散信号处理系统
  • +
    • +
    • 由CCD、电容和放大器等组成的离散电路完成信号处理功能
    • +
    +
  • +
    • +
    • 处理由连续信号采样而来的离散时间信号
    • +
    +
  • +
  • 数字信号处理系统
  • +
    • +
    • 信号处理功能由数字逻辑电路或通用计算机来完成
    • +
    +
  • +
    • +
    • 处理数字信号(例如来源于对连续信号的采样和量化)
    • +
    +
  • +
+

模拟 -> 采样量化 -> 数字信号处理系统 -> 模拟重建 -> 模拟输出信号

+

数字信号处理的局限

    +
  • ADC和DAC器件的处理能力
  • +
    • +
    • 是否能够准确提取出原连续信号中的信息首先决定于
      ADC:采样率、量化位数、时钟抖动、线性度等
    • +
    +
  • +
  • 精度受量化和舍入误差影响
  • +
    • +
    • 有限字长效应:数字系统中数字表示和计算精度受字
      长限制
    • +
    +
  • +
  • 适合于数字处理的信号带宽受处理能力的限制
  • +
    • +
    • 例如,信号带宽10MHz、采样率20MHz、FIR滤波器阶
      数为500,则所需计算量为每秒10G次的乘累加
    • +
    +
  • +
    • +
    • 如果带宽为1GHz呢?
    • +
    +
  • +
+

数字信号处理的发展

    +
  • 20世纪初至50年代有许多前期的研究工作,从采样
    定理的建立到声码器的数字仿真实验等,奠定了理论
    基础
  • +
  • 1965年FFT的提出,是DSP发展的里程碑 (但其源头
    可追溯到高斯时代)
  • +
  • 离散变换的进展:65年FFT,70年代余弦变换,80年
    代中后期小波变换
  • +
  • 滤波器设计技术:IIR、FIR数字滤波器,多采样处理
    和滤波器组理论,专用滤波器设计,小波滤波
  • +
  • 统计和自适应信号处理,阵列处理等,从统计学引入
    信号处理发展的另一条主线——现代信号处理
  • +
  • 器件和系统的发展对数字信号处理有积极推动
  • +
+

从模拟到数字

模拟信号的数字化:ADC

+

采样:本课程主要考虑均匀采样。

+
$$ +x[n] = x_a(nT) -\infty \lt n \lt \infty\\ +f_s = 1/T\\ +\Omega_s = 2\pi f_s +$$
+ +

采样的实现:采样保持电路

+

采样周期:与被采样信号的频带参数一起决定了采样过程是否会发生混叠。

+

采样过程的模糊性:采样过程可看作一种由连续信号空间到离散信号空间的多对一映射;对于给定的采样周期,仍存在无穷多个连续信号与同一离散信号对应。需要施加某种约束条件。

+

采样过程的基本问题:

+
    +
  • 采样过程是否会引起被采样信号的信息丢失?
  • +
  • 被采样的连续信号是否能从采样样本中完全恢复?
  • +
  • 采样过程的频域分析可获得上述问题的答案
  • +
    • +
    • 推导得到采样后离散信号和采样前连续信号频谱间的数学关系
    • +
    +
  • +
    • +
    • 确定可以消除采样过程模糊性的条件
    • +
    +
  • +
    • +
    • 为实际数字信号处理系统设计中采样频率的选择、抗混叠前置滤波器的设计提供指导
    • +
    +
  • +
+

采样的数学表示:

+
$$ +s(t) = \sum_{n = -\infty}^{\infty}\delta(t - nT)\\ +x_s(t) = x_a(t) \cdot s(t)\\ +x[n] = x_a(nT) +$$
+ +

对连续信号进行采样,其频谱是原始信号的周期延拓,延拓周期为采样频率

+
$$ +\begin{align*} +\text{时域} & \quad \quad \text{频域} \\ +x_a(t) & \quad \quad X_a(j\Omega)\\ +s(t) & \quad \quad S(j\Omega) = \frac{2\pi}{T} \sum_{k=-\infty}^{+\infty} \delta(\Omega - k\Omega_s)\\ +x_a(t) \cdot s(t) & \quad \quad X_S(j\Omega) = \frac{1}{T} \sum_{k=-\infty}^{+\infty} X_a\bigg(j(\Omega - k\Omega_s)\bigg) +\end{align*} +$$
+ +

带限信号和带通信号:

+
    +
  • 带限信号:$X_a(j\Omega) = 0, |\Omega| \ge \Omega_H$
  • +
  • 带通信号:$X_a(j\Omega) = 0, |\Omega| \ge \Omega_H\text{ or }|\Omega| \le \Omega_L$
  • +
+

带限信号的采样:

+ + +
$$ +X_S(j\Omega) = \frac{1}{T} \sum_{k=-\infty}^{+\infty} X_a[j(\Omega - k\Omega_S)], \Omega_s \ge 2\Omega_H +$$
+ +

对应的离散时间序列:

+
$$ +X(e^{j\Omega T}) = X_S(j\Omega) = \frac{1}{T} \sum_{k=-\infty}^{+\infty} X_a[j(\Omega - k\Omega_S)]\\ +\Rightarrow X(e^{j\omega}) = X_S(j\Omega) = \frac{1}{T} \sum_{k=-\infty}^{+\infty} X_a[j(\omega - 2\pi k)/T]\\ +$$
+ +

带通采样让时间以$T \rightarrow 1$的形式进行归一化,频率以$\Omega_s \rightarrow 2\pi$的形式进行归一化。

+

Nyquist 采样定理:

+
$$ +X_a(j\Omega) = 0, \forall |\Omega| \ge \Omega_H\\ +\Omega_s = 2\pi / T \gt 2\Omega_H +$$
+ +

或者归一化频率

+
$$ +\omega_H = \Omega_H T < \pi +$$
+ +

Remark:

+
    +
  • $𝑥_𝑎(𝑡)$ 是基带、带限信号
  • +
  • Nyquist是充分条件,即对被采样信号无其他假设
  • +
  • 在仅知道连续信号最高频率时,Nyquist采样定理给出
    了由采样信号唯一确定(或恢复)原信号的条件
  • +
    • +
    • 已知连续信号最高频率,可用于确定最低采样频率
    • +
    +
  • +
    • +
    • 已知采样频率,可确定无混叠连续信号的最高频率
    • +
    +
  • +
+

带通信号的采样:

+
$$ +\frac{2f_H}{m+1} \le f_s \le \frac{2f_L}{m}, m\in \N ,m \le f_L/B +$$
+ +

带限连续信号的重建:

+
    +
  • 由离散序列𝑥[𝑛]和采样周期𝑇,恢复原连续信号$𝑥_𝑟(𝑡)$
  • +
  • 由序列到冲激串转换和重建滤波两个步骤构成
  • +
  • 重建后的信号表示为
  • +
+
$$ +x_r(t) = \sum_{x = -\infty}^{\infty}x[n]h_r(t - nT) +$$
+ +

如选择截止频率$\Omega_c = \pi/T$的理想低通滤波器:

+
$$ +x_r(t) = \sum_{x = -\infty}^{\infty}x[n]\frac{\sin[\pi(t - nT)/T]}{\pi(t - nT)/T} +$$
+理想低通滤波器通过对冲激串信号的内插重建了原来的连续信号 + +

Summary

+

原信号:

+
$$ +x_c(t) \leftrightarrow X_c(j\Omega) +$$
+ +

采样后的信号:

+
$$ +\sum\limits_{n=-\infty}^{\infty}x[n]\delta(t - nT_s) = \sum\limits_{n=-\infty}^{\infty}x_c(t)\delta(t - nT_s) \leftrightarrow \frac{1}{T_s}X(e^{j\Omega T_s}) = \frac{1}{T_s}\sum\limits_{n=-\infty}^{\infty}X_c(j(\Omega - n\Omega_s)) +$$
+ +

数字域:

+
$$ +x[n] \leftrightarrow X(e^{j\omega}) = \frac{1}{T_s} X_c(j\omega /T_s) +$$
+ +

恢复信号:

+
$$ +h_r(t) \leftrightarrow H_r(j\Omega) = \begin{cases} + T_s, &|\Omega| \le \pi / T_s, \\ + 0, &|\Omega| \gt \pi / T_s +\end{cases}\\ +\begin{align*} + x_r(t) &= \sum\limits_{n=-\infty}^{\infty}x[n]\delta(t - nT_s) * h_r(t)\\ + &= \sum\limits_{n=-\infty}^{\infty} x_c(nT_s)h_r(t - nT_s)\\ + &= x_c(t) +\end{align*}\ \leftrightarrow\ \begin{align*} + X_r(j\Omega) &= T_s X(e^{j\Omega T_s})H_r(j\Omega)\\ + &= X_c(j\Omega) +\end{align*} +$$
+ +

数字时域和模拟时域之间的关系:

+
$$ +n = \frac{t}{T_s} = tf_s +$$
+ +

数字频域和模拟频域之间的关系:

+
$$ +\omega = \Omega T_s = \frac{2\pi f}{f_s} +$$
+ +

信号的表示

离散信号的时域表示

    +
  • 时域表示方法
      +
    • 数学表达式:可表示基本信号,但大多数实际信号无解析表达式
    • +
    • 图形表示:直观、易理解,但不适用于刻画复杂信号
    • +
    • 数据表示:离散信号最一般的表示方法
    • +
    +
  • +
+

离散信号的变换域表示

    +
  • 定义:假设离散时间信号为𝑥[𝑛] ,定义映射𝑇{·},那么信号的变换域表示可以写作𝑋 = 𝑇{𝑥[𝑛]}
      +
    • 𝑇{·}是从函数空间到函数空间的映射
    • +
    • 𝑋并不要求一定定义在整数域上
    • +
    +
  • +
  • 常用情形:级数表示
      +
    • 将信号分解成有限项或无穷多项基本信号加权和的形式,由和式中每个基本信号的加权值组成的序列形成了原信号的变换域表示
    • +
    • 傅里叶级数展开 $x[n] = \sum_k a_k e^{j2\pi kn /T}$
    • +
    +
  • +
+

离散信号的正交函数表示

    +
  • 使用信号空间的完备正交基来表示离散信号,
    $$ +\lbrace\ldots ,\varphi_0[n] ,\varphi_1[n] ,\varphi_2[n] , \ldots\rbrace +$$
  • +
  • 正交性:
    $$ +\sum_{n} \varphi_k^*[n] \varphi_l[n] = \delta_{kl} +$$
    +其中,$k \neq l$。
  • +
+
    +
  • 完备性
      +
    • 任何一个信号都可由这组基函数通过线性叠加而构成
    • +
    +
  • +
  • 加权系数的计算
      +
    • 对基函数的投影:
    • +
    +
  • +
+
$$ +c_k = \frac{\langle x[n], \phi_k[n]\rangle}{||\phi_k[n]||^2} +$$
+ +

DFT 的定义如下:

+
$$ +X[k] = \sum_{n=0}^{N-1} x[n]e^{-j2\pi kn/N} +$$
+其中,$x[n]$为输入信号的离散样本,$N$为采样点数,$X[k]$为输出的频域样本。 + +

DCT 的定义如下:

+
$$ +X[k] = \sum_{n=0}^{N-1} x[n]\cos\left(\frac{\pi}{N}(n + 0.5)k\right) +$$
+其中,$x[n]$为输入信号的离散样本,$N$为采样点数,$X[k]$为输出的频域样本。 + +

离散信号的特征域(量)表示

    +
  • 特征量表示指由信号的时域或频域表示来计算用
    于表征信号的特征量
      +
    • 例如能量、功率、均值、相关函数、功率谱
    • +
    • 特征量表示通常是单向性的,由特征量表示一般不能完整地恢复原信号的所有取值
    • +
    • 实践中,经常用特征量来表示随机信号
    • +
    +
  • +
+

离散信号的单位抽样信号表示:

单位抽样信号的移位作为基信号:

+
$$ +\varphi_k[n] = \delta[n - k], \quad k \in (-\infty, \ldots, -1, 0, 1, \ldots, \infty) +$$
+ +

• 正交性验证:

+
$$ +\langle\varphi_k[n],\varphi_l[n]\rangle = \sum_{n=-\infty}^{\infty} \delta[n - k] \delta[n - l] = \delta[k - l] +$$
+ +

• 系数计算:

+
$$ +c_k = \frac{\langle x[n],\varphi_k[n]\rangle}{\varphi_k[n]^2} = x[k] +$$
+ +

• 离散信号的单位抽样表示为:

+
$$ +x[n] = \sum_{k=-\infty}^{\infty} c_k\varphi_k[n] = \sum_{k=-\infty}^{\infty} x[k] \delta[n - k] +$$
+ +

离散信号的复指数信号表示如下:

+

• 复指数信号作为基信号:

+
$$ +\varphi_\omega[n] = e^{j\omega n}, \quad 0 \leq \omega < 2\pi +$$
+ +

• 正交性验证:

+
$$ +\langle\varphi_{\omega_1}[n],\varphi_{\omega_2}[n]\rangle = \sum_{n=-\infty}^{\infty} e^{j\omega_1 n} e^{-j\omega_2 n} = \begin{cases} +0, & \omega_1 \neq \omega_2 \\ +\infty, & \omega_1 = \omega_2 +\end{cases} +$$
+ +

• 系数计算:

+
$$ +X(e^{j\omega}) = \langle x[n], e^{j\omega n} \rangle = x[n] e^{-j\omega n} +$$
+ +

• 离散信号的复指数信号表示为:

+
$$ +x[n] = \frac{1}{2\pi} \int_{-\pi}^{\pi} X(e^{j\omega}) e^{j\omega n} d\omega +$$
+ +

有限长离散信号的正交函数表示

• 对于长度为$N$的有限长离散序列,选择以下$N$个序列作为基信号:

+
$$ +\varphi_k[n] = e^{j\frac{2\pi}{N}kn}R_N[n], \quad k = 0,1,2,\ldots,N-1 +$$
+ +

• 正交性验证:

+
$$ +\langle \varphi_k[n],\varphi_l[n] \rangle = \sum_{n=0}^{N-1} e^{j\frac{2\pi}{N}(k-l)n} = \begin{cases} +N, & k = l \\ +0, & k \neq l +\end{cases} +$$
+ +

• 系数计算:

+
$$ +X[k] = \sum_{n=0}^{N-1} x[n] e^{-j\frac{2\pi}{N}kn}, \quad k = 0,1,2,\ldots,N-1 +$$
+ +

• 有限长离散序列可以表示为:

+
$$ +x[n] = \frac{1}{N} \sum_{k=0}^{N-1} X[k] e^{j\frac{2\pi}{N}kn}, \quad n = 0,1,2,\ldots,N-1 +$$
+ +
    +
  • 离散信号的因果性:
      +
    • 𝑥[𝑛] = 0,for 𝑛 < 0
    • +
    +
  • +
+

因果连续信号抽样后一定是因果离散信号。

+
    +
  • 离散信号的对称性:
  • +
+

• 共轭对称性:

+
    +
  • 正对称:$x[n] = x^*[-n]$
  • +
  • 反对称:$x[n] = -x^*[-n]$
  • +
+

• 任意信号都可以表示为奇分量和偶分量的和:
$x[n] = x_o[n] + x_e[n]$
其中,$x_o[n] = \frac{1}{2}(x[n] - x^*[-n])$为奇分量,$x_e[n] = \frac{1}{2}(x[n] + x^*[-n])$为偶分量。

+

• 若信号具有实因果性,可以通过奇分量或偶分量来恢复原信号:

+
$$ +x[n] = \begin{cases} +0, & n < 0 \\ +x_e[n], & n = 0 \\ +2x_e[n], & n > 0 +\end{cases} +$$
+ +
    +
  • 离散信号的周期性:
      +
    • $𝑥[n] = 𝑥[𝑛 + N]$
    • +
    +
  • +
+

周期连续信号均匀采样后一定是周期离散信号。

+
$$ +\omega_0 = \Omega_0T = 2\pi\frac{T}{T_0} +$$
+ +

离散余弦信号的数字角频率 $\omega_0$ 由采样周期和连续信号周期的比值决定。该比值决定了采样后的信号是否具有周期性。

+

离散系统的表示

离散系统的表示可以使用以下公式来描述:

+
$$y[n] = \sum_{k=-\infty}^{\infty} h[k]x[n-k]$$
+ +

其中,$y[n]$表示系统的输出,$x[n]$表示系统的输入,$h[k]$表示系统的单位冲激响应。这个公式是卷积的离散形式,也称为离散卷积。

+

对于因果性,一个离散系统被称为因果性系统,如果它对任何$n < 0$的输入信号$x[n]$都产生$y[n] = 0$的输出。这意味着输出只依赖于当前和过去的输入。

+

对于稳定性,一个离散系统被称为稳定系统,如果对于有界的输入信号$x[n]$,输出$y[n]$仍然是有界的。

+

LTI(线性时不变)系统是指具有线性性质和时不变性质的系统。线性性质意味着系统满足叠加原理,即对于输入信号$x_1[n]$和$x_2[n]$,系统的输出满足$y_1[n] + y_2[n]$。时不变性质意味着系统的单位冲激响应$h[k]$与输入信号$x[n]$的延迟无关。

+

单位冲激响应是指当输入信号为单位冲激函数$\delta[n]$时,系统的输出。单位冲激响应通常用$h[n]$表示。

+

LTI系统可完全由单位冲激响应来表征。

+

因果性判据:单位冲激响应是一个因果信号。
稳定性判据:$S = \sum_{k = -\infty}^\infty |h[k]| \lt +\infty$

+

特征函数与特征值

+
$$ +T\lbrace s[n]\rbrace = \lambda s[n] +$$
+ +

LTI系统的特征函数与特征值

+
$$ +T\lbrace e^{j\omega n}\rbrace =\sum\limits_{k=-\infty}^{\infty}h[k]e^{j\omega (n - k)} = \underbrace{e^{j\omega n}}_{特征函数}\cdot\underbrace{\sum\limits_{k=-\infty}^{\infty}h[k]e^{-j\omega k}}_{特征值} +$$
+ +

$y[n]$ 可看作 $x[n]$ 经过特征信号分解、加权、求和的结果:

+
$$ +y[n] = \frac{1}{2\pi} \int_{-\pi}^\pi H(e^{j\omega})X(e^{j\omega})e^{j\omega n}\mathrm d\omega +$$
+ +
    +
  • 频率响应函数:单位冲激响应的DTFT
  • +
+
$$ +H(e^{j\omega}) =\sum\limits_{n=-\infty}^{\infty}h[n]e^{-j\omega n} +$$
+ +
    +
  • 系统函数
  • +
+
$$ +H(z) =\sum\limits_{n=-\infty}^{\infty}h[n]z^{-n} +$$
+ +
    +
  • 系统差分方程
  • +
+
$$ +\sum\limits_{k=0}^{N} a_ky[n - k] =\sum\limits_{k=0}^{M} b_kx[n - k] +$$
+ +
    +
  • 系统状态空间
  • +
+
$$ +\lambda[n + 1] = A\lambda[n] + Bx[n]\\ +y[n] = C\lambda[n] + Dx[n] +$$
+ +

DTFT 与 DFT

DTFT

$$ +\begin{cases} + X(e^{j\omega}) =\sum\limits_{n=-\infty}^{\infty}x[n]e^{-j\omega n}\\ + x[n] = \frac{1}{2\pi} \int_{-\pi}^{\pi}X(e^{j\omega})e^{j\omega n}\mathrm d\omega +\end{cases} +$$
+ +

与连续频谱的关系:

+
$$ +X(e^{j\omega}) = \frac{1}{T}\sum\limits_{k=-\infty}^{\infty}X_a\left[j\left(\frac{\omega}{T} - k\frac{2\pi}{T}\right)\right]\\ +\omega = \Omega T +$$
+ +

基本性质:

+
    +
  • 周期性
  • +
+
$$ +X(e^{j\omega}) = X(e^{j\omega + 2k\pi}), k\in \Z +$$
+ +
    +
  • 线性
  • +
+
$$ +ax[n] + by[n] \lrarr aX(e^{j\omega}) + bY(e^{j\omega}) +$$
+ +
    +
  • 频域求导
  • +
+
$$ +nx[n] \lrarr j\frac{\mathrm dX(e^{j\omega})}{\mathrm d\omega} +$$
+ +
    +
  • Parseval 定理:
  • +
+
$$ +\sum\limits_{n=-\infty}^{\infty}||x[n]||^2 = \frac{1}{2\pi}\int_{-\pi}^{\pi}||X(e^{j\omega})||^2\mathrm d\omega +$$
+ +
    +
  • 序列的调制
  • +
+
$$ +x[n]e^{j\omega_0 n} \lrarr X(e^{j(\omega - \omega_0)}) +$$
+ +

实现数字变频:

+
$$ +x_B[n] = x[n]e^{-j\frac{\pi}{2}n} +$$
+ +
    +
  • 序列的平移
  • +
+
$$ +x[n - n_0] \lrarr e^{-j\omega n_0}X(e^{j\omega}) +$$
+ +
    +
  • 共轭对称性
  • +
+
$$ +x_e[n] \lrarr \text{Re}\lbrace X(e^{j\omega}) \rbrace +$$
+ +
$$ +x_o[n] \lrarr \text{Im}\lbrace X(e^{j\omega}) \rbrace +$$
+ +

下面是修正后的表格:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
序列 $x[n]$DTFT $X(e^{j\omega})$
$x[n]$$X(e^{j\omega})$
$x^*[n]$$X^*(e^{-j\omega})$
$x^*[-n]$$X^*(e^{j\omega})$
$x_R[n]$$X_e(e^{j\omega})$
$jx_I[n]$$X_o(e^{j\omega})$
$x_e[n]$$X_R(e^{j\omega})$
$x_o[n]$$jX_I(e^{j\omega})$
以下为实信号
$x[n] = x^*[n]$,$X(e^{j\omega}) = X^*(e^{-j\omega})$
$x_e[n] = \frac{1}{2}(x[n] + x[-n])$$X_R(e^{j\omega})$ 实、偶函数
$x_o[n] = \frac{1}{2}(x[n] - x[-n])$$jX_I(e^{j\omega})$ 虚、奇函数
+
    +
  • 卷积与相关性质
      +
    • 时域卷积: $x[n] * y[n] \lrarr X(e^{j\omega})\cdot Y(e^{j\omega})$
    • +
    • 频域卷积:$x[n] \cdot y[n] \lrarr \frac{1}{2\pi}X(e^{j\omega}) * Y(e^{j\omega})$
    • +
    • 时域相关:
        +
      • 互相关:$r_{xy}[k] =\sum\limits_{k=-\infty}^{\infty}x[n]y^*[n - k]$
      • +
      • 自相关:$r_{xx}[k] =\sum\limits_{k=-\infty}^{\infty}x[n]x^*[n - k]$
      • +
      • $R_{xy}(e^{j\omega}) = X(e^{j\omega}) \cdot Y^*(e^{j\omega})$
      • +
      • $R_{xx}(e^{j\omega}) = X(e^{j\omega}) \cdot X^*(e^{j\omega})$
      • +
      +
    • +
    +
  • +
+

DTFT的存在条件:

+

取决于 $\sum\limits_{n=-\infty}^{\infty}x[n]e^{-j\omega n}$ 的收敛性

+

有限和序列 $X_N(e^{j\omega}) =\sum\limits_{n=-N}^{N}x[n]e^{-j\omega n}$

+
    +
  • 若 $x[n]$ 绝对可和,则 DTFT 存在,且一致收敛
  • +
  • 若序列满足平方可和,则 DTFT 满足均方收敛性
      +
    • 截断误差的能量趋于0,但是某些点的误差的绝对值不一定趋于0(例如理想低通滤波器,有吉布斯现象,在截止频率附近存在一个独立于 $N$ 的震荡,即使 $N$ 趋于无穷,在某些频率点上还是存在9%左右的误差)
    • +
    +
  • +
+

特殊信号的 DTFT

+
    +
  • 符号序列
  • +
+
$$ +\text{sgn}[n] = \begin{cases} + 1, &n\gt 0,\\ + 0, &n = 0\\ + -1, &n \lt 0 +\end{cases} \lrarr \text{SGN}(e^{j\omega}) = \frac{1}{j} \cot \left(\frac{\omega}{2}\right) +$$
+ +
    +
  • 阶跃序列
  • +
+
$$ +u[n] = \frac{1}{2}(\text{sgn}[n] + 1) + \frac{1}{2} \delta[n] \lrarr U(e^{j\omega}) = \frac{1}{1 - e^{-j\omega} + \pi} + \pi\sum\limits_{k=-\infty}^{\infty}\delta(\omega - 2\pi k) +$$
+ +
    +
  • 离散周期单位冲激串
  • +
+
$$ +x[n] =\sum\limits_{k=-\infty}^{\infty}\delta[n - kN]\lrarr X(e^{j\omega}) =\sum\limits_{k=-\infty}^{\infty}e^{-j\omega k N} = \frac{2\pi}{N}\sum\limits_{k=-\infty}^{\infty}\delta(\omega - \frac{2k\pi}{N}) +$$
+ +

离散时限信号与周期单位冲激串的卷积,在频域上表现为对 DTFT 的采样,这正是从 DTFT 到 DFT 的过渡。

+

DFT

DTFT给出了离散信号频域的全部信息,但在实际应用中存在如下困难:

+
    +
  • 实际信号往往没有解析表达式,无法计算其DTFT
  • +
  • 实际物理装置只能采集有限长度的数据
  • +
  • DTFT给出的频谱是连续的,无法用数字设备记录和存储全部的值
  • +
+

DFT 的定义

$$ +\begin{cases} + X[k] =\sum\limits_{n=0}^{N - 1}x[n]W_N^{nk}, &k = 0, 1, 2, \dots, N - 1\\ + x[n] =\frac{1}{N}\sum\limits_{n=0}^{N - 1}x[n]W_N^{-nk}, &k = 0, 1, 2, \dots, N - 1\\ +\end{cases} +$$
+ +

其中,

+
$$ +W_N = e^{-j\frac{2\pi}{N}} +$$
+ +

理解 DFT

DFT 是 DTFT 的频域采样

+
$$ +X(e^{j\omega}) =\sum\limits_{n=-\infty}^{\infty}x[n]e^{j\omega n}\\ +X[k] = X(e^{j\omega})\big |_{\omega_k = \frac{2\pi}{N}k} =\sum\limits_{n=-\infty}^{\infty}x[n]e^{-j\frac{2\pi}{N}kn} +$$
+ +
    +
  • 频域乘积等价于时域卷积,因此对离散序列在频域上以2𝜋/𝑁为周期进行采样,等效于离散信号在时域上进行周期延拓,延拓周期为𝑁

    +
  • +
  • 为保证离散序列频域采样对应的时域序列不发生混叠,要求原离散序列为有限长且长度不超过𝑁。

    +
  • +
+

DFT 的频域重构

    +
  • 首先需要 $N \ge L$
  • +
+
$$ +\begin{align*} + X(e^{j\omega}) &=\sum\limits_{n=0}^{N - 1}x[n]e^{-j\omega n} =\sum\limits_{n=0}^{N - 1}\bigg[\frac{1}{N}\sum\limits_{n=0}^{N - 1}X[k]e^{j\frac{2k\pi}{N}n}\bigg]e^{-j\omega n}\\ + &=\sum\limits_{k=0}^{N - 1}X[k]\bigg[\frac{1}{N}\sum\limits_{n=0}^{N - 1}e^{-j(\omega - \frac{2k\pi}{N}n)}\bigg]\\ + &=\sum\limits_{k=0}^{N - 1} X[k]P\bigg(\omega - \frac{2k\pi}{N}\bigg) +\end{align*} +$$
+ +

其中,内插函数

+
$$ +P(\omega) = \frac{1}{N}\sum\limits_{n=0}^{N - 1} e^{-j\omega n} = \frac{1}{N}\frac{\sin (\omega N / 2)}{\sin (\omega / 2)}e^{-j \frac{N - 1}{2}\omega} +$$
+ +

理解 DFT II

离散正交变换的定义:

+
    +
  • 定义变换矩阵 $A$, 若 $A$ 满足 $A^HA = cI$,其中$c$为常数,则称 $X = Ax$ 为离散正交变换。若 $c = 1$,则称变换是归一化的。
  • +
  • 归一化的离散正交变换满足 Parseval 定理:$||X||^2 = X^HX = x^HA^HAx = x^Hx = ||x||^2$
  • +
+

DFT 是对离散时间信号的加权求和,其向量形式

+
    +
  • $X[k] = w_k^Hx$, $w_k = [e^{j\frac{2\pi0k}{N}}, e^{j\frac{2\pi1k}{N}}, \dots, e^{j\frac{2\pi(N - 1)k}{N}}]^T$
  • +
  • $X = [X[0], X[1], \dots, X[N - 1]]^T$,则有$X = [w_0, w_1, \dots, w_{N - 1}]^Hx = W_Nx$
  • +
+
$$ +X = W_Nx\\ +x = \frac{1}{N} W_N^HX +$$
+ +

DFT 的周期延拓

• DFT本意是用有限个离散频域样本来表示有限长离散序列

+

– 时域采样对应着频域周期延拓,频域采样对应着时域周期延拓

+

• 由于周期延拓,DFT总是面对着周期序列

+

– 在DFT计算和应用中,总是选择时域和频域的主值区间

+

– DFT这种隐含的周期性决定了其与DTFT具有不同的性质

+

周期延拓的数学表示

+
$$ +\big((n)\big)_N +$$
+ +

周期延拓可以表示为:

+
$$ +\tilde X[k] = X\bigg[\big((k)\big)_N\bigg] +\tilde x[n] = X\bigg[\big((n)\big)_N\bigg] +$$
+ +

也可表示为卷积和:

+
$$ +\tilde{X}[k] = X[k] *\sum\limits_{m=-\infty}^{\infty}\delta[k - mN] =\sum\limits_{m=-\infty}^{\infty}X[k - mN]\\\tilde{x}[n] = x[n] *\sum\limits_{m=-\infty}^{\infty}\delta[n - mN] =\sum\limits_{m=-\infty}^{\infty}x[n - mN] +$$
+ +

DFT 性质

    +
  • 线性性
      +
    • 前提:变换长度 $N$ 相同
    • +
    • 如果不相同,补零到长度 $N \ge \max(N_1, N_2)$
    • +
    +
  • +
  • 反转性质:若时域循环反转,则频域循环反转
      +
    • $\text{DFT} \Bigg\lbrace x\big[\big((-n)\big)_N\bigg] R_N[n]\Bigg\rbrace = X\bigg[\big((-k)\big)_N\bigg] R_N[k]$
    • +
    • 0 时刻不变,其余前后反转
    • +
    +
  • +
  • 共轭性质:若时域共轭,则频域共轭且循环反转
      +
    • $\text{DFT}\lbrace x^*[n]\rbrace = X^*[N - k]$
    • +
    +
  • +
  • 对偶性质:序列的DFT的DFT
      +
    • $\text{DFT}\lbrace X[n]\rbrace = NX^*[N - k]$
    • +
    +
  • +
  • 周期序列的共轭对称性:
      +
    • 共轭对称:$x_{ep}[n] = x^*_{ep}\bigg[\big((-n)\big)_N\bigg]$
    • +
    • 共轭反对称:$x_{ep}[n] = -x^*_{ep}\bigg[\big((-n)\big)_N\bigg]$
    • +
    • 任意有限长序列的周期延拓总可以分解为周期共轭对称和反对称的分量和的形式
        +
      • $x[n] = x_{ep}[n] + x_{op}[n]$
      • +
      • $x_{ep}[n] = \frac12 (x[n] + x^*\bigg[\big((-n)\big)_N\bigg])$
      • +
      • $x_{op}[n] = \frac12 (x[n] - x^*\bigg[\big((-n)\big)_N\bigg])$
      • +
      +
    • +
    • 实序列的DFT是周期共轭对称序列
    • +
    • 虚序列的DFT是周期共轭反对称序列
    • +
    • 周期共轭对称序列的DFT是实的
    • +
    • 周期共轭反对称序列的DFT是虚的
    • +
    +
  • +
  • 循环卷积性质:
      +
    • 有限长循环移位的 DFT 可以由原序列 DFT 乘上一个线性的相位因子得到:$\text{DFT}\Bigg \lbrace\bigg[x\big((n - m)\big)_N\bigg]\Bigg \rbrace = X[k]e^{-j\frac{2\pi k}{N}m}$
    • +
    • 在 DTFT 中:$x[n] * y[n] = \text{IDTFT}\lbrace X(e^{j\omega}) \cdot Y(e^{j\omega})\rbrace$
    • +
    • DFT 中:$x[n] \circledast y[n] =\sum\limits_{m=0}^{N - 1}x[m]y\bigg[\big((n - m)\big)N\bigg] =\sum\limits{m=0}^{N - 1}x\bigg[\big((n - m)\big)_N\bigg]y[m]$
    • +
    +
  • +
  • Parseval 定理:
      +
    • $\sum\limits_{n=0}^{N - 1}|x[n]|^2 = \frac{1}{N}\sum\limits_{k=0}^{N - 1}|X[k]|^2$
    • +
    +
  • +
+

FFT

FFT 算法是一大类 DFT 快速算法的总称。

+
    +
  • 基 2 FFT 算法:$N = 2^m$
  • +
  • 基 4 FFT 算法:$N = 4^m$
  • +
  • 分裂基算法:基本蝶形是倒 L 型,$N = 2^m$
  • +
  • 组合数 FFT 算法:变换点数为组合数,即$N = N_1N_2$
  • +
+

根据处理基本蝶形的结构特点,可以分为:

+
    +
  • DIT (Decimation-In-Time)
  • +
  • DIF (Decimation-In-Frequency)
  • +
+

基 2 DIT-FFT 算法

按照奇偶时间拆分成两个短序列。

+

长序列的 DFT 可以由两个短序列的 DFT 组合得到。

+
$$ +X[k] = \sum\limits_{m=0}^{N/2 - 1}x[2m]W_N^{2mk} + \sum\limits_{m=0}^{N/2 - 1} x[2m + 1]W_N^{(2m + 1)k}\\ +f_1[n] = x[2n], f_2[n] = x[2n + 1]\\ +X[k] = F_1[k] + W_N^kF_2[k]\\ +X[k + N/2] = F_1[k] - W_N^kF_2[k] +$$
+ +

反复抽取,变成2点 DFT:

+
$$ +\begin{bmatrix} + X[0]\\ + X[1] +\end{bmatrix} = \begin{bmatrix} + x[0] + x[1]\\ + x[0] - x[1] +\end{bmatrix} +$$
+ +

alt

+

计算复杂度:

+
    +
  • 乘法次数为$\frac{N}{2}\log_2N$,$m_a = Nm = N\log_2 N$
  • +
+

输入和输出序列的顺序关系:二进制下的倒序关系。

+
    +
  • 每次均分时,输入序列按照奇偶性划分,输出序列按照是否过半划分
  • +
  • 输入序列的奇偶性等价于最低位为1还是0,输出序列是否过半等价于最高位为1还是0
  • +
  • 因此输入映射到输出序列是低位映射到高位的关系。
  • +
+

数字频谱分析

DFT 谱分析的基本概念

频谱:信号经过傅里叶变换转换到频域后,其频域表示的幅度和相位随频率变化的关系分别称为信号的幅度谱和相位谱

+

基于 DFT 的数字频谱分析

+

利用离散信号 DFT 结果 $X[k]$ 与原连续信号频谱 $X_a(j\Omega)$ 之间存在对应关系来获得连续信号的频谱。

+
$$ +X[k] = X(e^{j\omega})|_{\omega = \frac{2\pi}{N}k} +$$
+ +
$$ +X(e^{j\omega}) = \frac{1}{T_s}X_a(j\Omega)|_{\Omega = \frac{\omega}{T_s}} +$$
+ +
$$ + X_a(j\Omega_k)= T_s X[k] +$$
+ +

利用 DFT 结果获得连续信号的频谱:

+
$$ +X_a(j\Omega_k) = X_a \left ( j\frac{2\pi k}{NT_s} \right) = \begin{cases} + T_sX[k], 0 \le k \le \lceil \frac{N}{2} \rceil, \\ + T_sX[k + N], - \lceil \frac{N - 1}{2} \rceil\le k \lt 0 +\end{cases} +$$
+ +

基于DFT的频谱分析方法存在的问题

+
    +
  • 理论上连续正弦信号的频谱应为冲激函数,但DFT结果为有限值
  • +
  • DFT结果在连续正弦信号频谱幅度为0的位置却不为零
  • +
+

DFT 谱分析的一般过程

抗混叠滤波

alt

+

采样

提高采样率

+
    +
  • 优点:能够无混叠分析的信号带宽增大
  • +
  • 缺点:数据率提高,系统复杂度增加,成本上升
  • +
+

加窗

由于DFT只能处理有限长序列,需要对输入信号
通过加窗进行截断

+
    +
  • 窗长可根据频率分辨率、实时性和设备存储能力的要
    求来权衡
  • +
  • 窗函数的形式也可根据主瓣宽度和旁瓣电平进行选择
  • +
+
$$ +w_R[n] = \begin{cases} + 1, 0 \le n \lt M\\ + 0, \text{others} +\end{cases} +$$
+ +
$$ +x_w[n] = x[n]w_R[n] +$$
+ +

DFT计算、插值及频谱输出

DFT计算

+
    +
  • 可能需要补零,以获得更密集的频域采样,以及使变换点数𝑁满足FFT算法的要求(基2-FFT、基4-FFT)
  • +
+

插值

+
    +
  • 由DFT结果获得DTFT的估计值
  • +
  • 插值方法:
      +
    • 精确插值: $X(e^{j\omega}) =\sum\limits_{k=0}^{N - 1} X[k] P \left ( \omega - \frac{2\pi k}{N} \right)$, $P(\omega) = \frac{\sin(\omega N/2)}{\sin(\omega/2)}e^{-j\frac{N-1}{2}\omega}$
    • +
    • 近似插值:线性插值,二次插值
    • +
    +
  • +
+

连续信号频谱输出
– 通过坐标变换得到连续信号频谱 $X_a(j\Omega) = T_sX(e^{j\Omega T_s})$

+

DFT 谱分析问题

谱分析滤波器

$$ +s(t) = \frac{1}{2\pi} \int_{-\infty}^{\infty}S(j\Omega)e^{j\Omega t}\mathrm d\Omega\\ +s(nT_s) = \frac{1}{2\pi} \int_{-\infty}^{\infty}S(j\Omega)e^{j\Omega nT_s}\mathrm d\Omega\\ +x[n] = \begin{cases} + s(nT_s), n = 0, 1, \dots, M - 1,\\ + 0, M, M + 1, \dots, N - 1 +\end{cases}\\ +X[k] =\sum\limits_{n=0}^{N - 1}x[n]e^{-j\frac{2\pi nk}{N}} = \frac{1}{2\pi}\int_{-\infty}^{\infty}\sum\limits_{n=0}^{M - 1}e^{j(\Omega T_s - 2\pi k/N)n}\mathrm d\Omega +$$
+ +

令 $\theta = T_s(\Omega - \Omega_k)$,

+
$$ +\varphi_k(M, \theta) = \sum\limits_{n=0}^{M - 1}e^{j(\Omega T_s - 2\pi k/N)n} = \frac{\sin(M\theta / 2)}{\sin(\theta/2)} e^{j\frac{M - 1}{2}\theta} +$$
+ +

梳状滤波特性

+

alt

+

周期内存在多个过零点,把滤波器响应分割成多个区间

+
    +
  • 主瓣:谱分析滤波器频率响应最大的那个区间
  • +
  • 主峰:主瓣中最大频率响应点 $Ω = \frac{2\pi k}{NT_s}$处,高度为𝑀
  • +
  • 主瓣宽度:主瓣两边过零点之间的距离4𝜋⁄𝑀𝑇𝑠
  • +
  • 旁瓣:除响应最大的那个区间外的其它区间
  • +
+

DFT频谱分析方法能否反映连续信号的频谱?

+
    +
  • DFT的结果主要给出了连续信号落在相应谱分析滤波器主瓣内的那部分信号的频域信息
  • +
  • 由于相邻谱分析滤波器主瓣间有交叠,同一个信号可能会在相邻两个谱分析滤波器都有响应
  • +
  • 谱分析滤波器的旁瓣会在其他谱分析滤波器的主瓣位置出现,其对应的DFT结果不可避免的包含了其他滤波器主瓣位置处的信号成分
  • +
+

DFT 可用于连续信号的频谱分析,但由于其谱分析滤波器频率分割不理想的本质,必须对其输出结果进行小心的解释

+

DFT谱估计得到的是对加窗后序列DTFT的采样

+
$$ +x_w[n] = x[n]w_R[n]\\ +X_w(e^{j\omega}) = \frac{1}{2\pi}\int_{-\pi}^{\pi}X(e^{j\omega})W_R(e^{j(\omega - \theta)})\mathrm d\theta +$$
+ +

对于矩形窗:

+
$$ +W_R(e^{j\omega}) = \text{DTFT}(w_R[n]) = \frac{\sin(M\omega / 2)}{\sin(\omega/2)} e^{-j\frac{M - 1}{2}\omega} +$$
+ +

频率分辨力的定义:两个等幅单频信号能够被区分开的最小频率间隔

+

矩形窗的主瓣宽度为 $4\pi/MT_s$

+

实际工程中,采用 3dB带宽并加上适当余量作为频率分辨力

+
    +
  • 矩形窗的数字角频率分辨力为 $\Delta \omega = 2\pi / M$
  • +
  • 连续信号的分辨力为 $\Delta f = f_s/M$
  • +
+

分辨力仅决定于信号时长 $MT_s$。

+

混叠效应

+

混叠效应本质上由采样过程引起

+
    +
  • 混叠效应带来的问题
  • +
  • 如果采样过程带来了混叠,DFT结果无法将已混叠的频
    率分量分开
  • +
  • 采样之前作抗混叠滤波,把带外频率成分滤除
  • +
  • 增大采样频率(减小采样周期)
    – 无法仅从DFT结果中判读原连续信号的模拟频率
  • +
  • 需要原连续信号频率分布或抗混叠滤波通带的先验
    知识
  • +
+

栅栏效应

+
    +
  • DFT 无法精确表示不在离散采样点的频率值
  • +
  • 频率估计的最大误差为 $\pi / N$
  • +
  • 可以通过加窗补零(增大 $N$)的方法改善
  • +
  • 通过局部插值的方法获得更精确的频率估计:精确插值,线性插值,二次插值
  • +
+

DFT 的应用

线性卷积的计算

假设有限长因果序列 $h[n]$ 和 $x[n]$,长度分别为 $P$ 和 $L$,均扩展到 $N$ 个点进行卷积

+
    +
  • 当 $N \ge P + L - 1$ 时,两种卷积的结果相等
  • +
  • 当 $N \lt P + L - 1$ 时,循环卷积出现混叠
  • +
+

基于 DFT 的 FIR 滤波器实现

+

FIR 滤波器需要计算有限长序列和无限长序列的线性卷积

+
    +
  • $h[n]$ 有限
  • +
  • $x[n]$ 无限
  • +
+

方法1:重叠相加法

+
$$ +x[n] =\sum\limits_{r=0}^{\infty}x_r[n - rL]\\ +y[n] = h[n] * \sum\limits_{r=0}^{\infty}x_r[n - rL] = \sum\limits_{r=0}^{\infty}h[n] * x_r[n - rL]\\ +$$
+ +

整个序列的线性卷积等于各段线性卷积后的移位加和

+

IDFT 后,需要一个专门的加法器进行重叠部分的相加运算

+

方法二:重叠保留法

+

取 $L$ 点 $x[n]$ 与扩展的 $P$ 点 $h[n]$ 做循环卷积,取结果的后 $L - P + 1$ 个点作为结果。

+

两种方法、直接计算线性相关的计算量对比?

+

线性调频 z 变换

CZT 的定义

+
$$ +X_{cz}(z)|_{z = z_k} =\sum\limits_{n=0}^{N - 1}x[n]z_k^{-n}\\ +z_k = AW^{-k} = (A_0e^{j\theta_0})(W_0e^{-j\varphi_0})^{-k} +$$
+ +

一种广义的 DFT,在复平面螺旋线上的采样。

+

CZT 的计算

+
    +
  • 利用定义直接计算
  • +
  • 利用卷积计算,而卷积可以利用 FFT 计算
  • +
+
$$ +X_{cz}(z_k) = W^{\frac{k^2}{2}}\sum\limits_{n=0}^{N - 1}f[n]h[k - n]\\ +f[n] = x[n]A^{-n}W^{\frac{n^2}{2}}\\ +h[n] = W^{-\frac{n^2}{2}} +$$
+ +

短时傅里叶变换

问题:基于傅里叶的频谱分析可以指导信号观测窗内的频率成分,但是无法得知这些频率成分何时出现,何时消失,持续多久

+

定义

+
$$ +\text{STFT}(t^\prime, \Omega) = \int_{-\infty}^{\infty}x(\tau)g^*(\tau - t^\prime)e^{-j\Omega\tau}\mathrm d\tau +$$
+ +
    +
  • 窗的长度
      +
    • 窗长需要足够短,确保落入窗的信号近似平稳
    • +
    • 窗越长,频率分辨率越高,窗越短,时间分辨率越高
        +
      • 窗无限长,退化成 FT
      • +
      • 无限短,退化成 $s(t^\prime)e^{-j\Omega t^\prime}$
      • +
      +
    • +
    +
  • +
  • 窗的类型
      +
    • 矩形窗,汉明窗,布莱克曼窗
    • +
    • 主瓣宽度与旁瓣电平之间的权衡
    • +
    +
  • +
+

不确定性原理

+
$$ +\Delta t \cdot \Delta \Omega \ge \frac{1}{2} +$$
+ + +

LTI 系统

LTI 系统的时域分析——冲激响应

根据冲激响应长度不同:

+
    +
  • FIR:用 $h[n]$ 表示系统
  • +
  • IIR:用系统函数或者差分方程表示
  • +
+

LTI 系统的时域分析——冲激响应

复指数序列是 LTI 系统的特征函数

+
$$ +T \lbrace e^{j\omega n} \rbrace = H(e^{j\omega})e^{j\omega n} +$$
+ +

频率响应函数的表示方式

+
    +
  • $H(e^{j\omega}) = H_R(e^{j\omega}) + jH_I(e^{j\omega})$
  • +
  • $H(e^{j\omega}) = |H(e^{j\omega})|e^{j\angle H(e^{j\omega})}$
  • +
  • 幅频特性:
      +
    • $|H(e^{j\omega})|$
    • +
    • $20\log |H(e^{j\omega})|$,单位 dB
    • +
    +
  • +
  • 相频特性
      +
    • $arg(H(e^{j\omega}))$:连续相位
    • +
    • $Arg(H(e^{j\omega}))$:主值相位
    • +
    • 无卷绕相位:$\angle H(e^{j\omega}) = \tan^{-1}\frac{H_I(e^{j\omega})}{H_R(e^{j\omega})}$
    • +
    • 定义主值区间 $arg(H(e^{j\omega})) = ARG[H(e^{j\omega})] + 2\pi r(\omega)$,$r(\omega)$是补偿函数,仅取整数
    • +
    +
  • +
+

相位延迟

+

群延迟

+
$$ +-\frac{\mathrm d}{\mathrm d\omega}\text{arg}[H_{id}(e^{j\omega})] +$$
+ +

可以表征窄带信号的相位失真(或者延迟)

+
$$ +x[n] = a[n]e^{j\omega_c n}\\ +a[n] = c_1e^{j\omega_1n}\\ +y[n] \approx |H(e^{j\omega_c})|c_1e^{j(\omega_1 + \omega_c)n + j\varphi(\omega_1 + \omega_c)} \approx |H(e^{j\omega_c})|\underbrace{a[n - \tau_g(\omega_c)]}_{群延迟给出了包络延迟}\underbrace{e^{j\omega_c[n - \tau_p(\omega_c)]}}_{相位延迟\tau_p(\omega_c) = \varphi(\omega_c)} +$$
+ +

LTI 系统的零极点分析

$$ +\sum\limits_{k=0}^{N}a_ky[n - k] =\sum\limits_{k=0}^{M}b_kx[n - k]\\ +H[z] = \frac{\sum\limits_{k=0}^{M}b_kz^{-k}}{\sum\limits_{k=0}^{N}a_kz^{-k}} = \left ( \frac{b_0}{a_0} \right)\frac{\prod_{k = 1}^M(1 - c_kz^{-1})}{\prod_{k = 1}^N(1 - d_kz^{-1})} +$$
+ +

$z = 0, z = \infty$ 也可能是零点!求解的时候不要忘了。

+

系统稳定性的条件:绝对可和。或者说 $H(z)$ 的极点在单位圆内。

+

可逆性的条件:$h[n] * h_i[n] = \delta[n]$, $H(8z)H_i(z) = 1$

+
    +
  • 逆系统的极点和零点就是原系统的零点和极点
  • +
  • 逆系统和原系统必须有重叠的 ROC,因此可以确定逆系统的 ROC
  • +
+

频率响应

+

群延迟

+
$$ +\text{grd}[] =\sum\limits_{k=1}^{N}\frac{|d_k|^2 - \Re{d_ke^{-j\omega}}}{1 + |d_k|^2 - 2\Re{d_ke^{-j\omega}}} - \sum\limits_{k=1}^{M}\frac{|c_k|^2 - \Re{c_ke^{-j\omega}}}{1 + |c_k|^2 - 2\Re{c_ke^{-j\omega}}} +$$
+ +

IIR滤波器

$$ +y[n] =\sum\limits_{k=1}^{N}a_ky[n - k] +\sum\limits_{k=0}^{M}b_kx[n - k]\\ +H(z) = \frac{\sum\limits_{k=0}^{M}b_kz^{-k}}{1 -\sum\limits_{k=1}^{N}a_kz^{-k}} +$$
+ +

直接 I 型

+

直接 II 型:交换次序,合并延迟单元

+

级联形式:

+
$$ +H(z) = K \prod_{k = 1}^{N_s} \frac{b_{0k} + b_{1k}z^{-1} + b_{2k}z^{-2}}{1 - a_{1k}z^{-1} - a_{2k}z^{-2}} +$$
+ +

考虑到有限字长效应,级联形式可以以更加灵活的方式减小有限字长的影响。可以控制零点和极点的位置。

+

级联形式也可以用直接 I, II 型实现。

+

多径衰落就是一个 FIR 滤波器,因此具有频率选择特性。

+

并联形式

+
$$ +H(z) =\sum\limits_{k=0}^{N_p}C_kz^{-k} +\sum\limits_{k=1}^{N_2}\frac{e_{0k}+e_{1k}z^{-1}}{1 - a_{1k} - a_{2k}z^{-2}} +$$
+ +

各子系统的计算误差互不影响,防止误差传递和放大,可控极点位置

+

流图转置定理:支路方向取反,系数不变,输入和输出交换位置

+

FIR 滤波器

$$ +H(z) =\sum\limits_{n=0}^{N - 1}h[n]z^{-n} +$$
+ +

抽头延迟线 or 横向滤波器结构

+

具有转置形式

+

级联形式

+
$$ +H(z) = \prod_{k = 1}^{M_1}(f_{0k} - f_{1k}z^{-1}\prod_{k = 1}^{M_2}(b_{0k} + b_{1k} z^{-1} + b_{2k}z^{-2}) +$$
+ +

线性相位特性

+
$$ +H(e^{j\omega}) = A(e^{j\omega})e^{-j\omega\alpha} +$$
+ +
$$ +h[n] = h[M - n] (I, II)\\ +h[n] = - h[M - n] (III,IV) +$$
+ +

线性相位 FIR 滤波器的直接形式

+

偶数

+
$$ +y[n] = \begin{cases} + \sum\limits_{k=0}^{M/2 - 1}h[k](x[n - k] + x[n - M + k]) + h[M/2]x[n - M/2], &I type + \sum\limits_{k=0}^{M/2 - 1}h[k](x[n - k] - x[n - M + k]), &III type +\end{cases} +$$
+ +

奇数

+
$$ +y[n] = \begin{cases} + \sum\limits_{k=0}^{(M - 1)/2}h[k](x[n - k] + x[n - M + k]), &II type + \sum\limits_{k=0}^{(M - 1)/2}h[k](x[n - k] - x[n - M + k]), &IV type +\end{cases} +$$
+ +

级联形式

+

对应四种零点分布情况,有四种网络结构

+
$$ +H(z) = 1 \pm z^{-1}\\ +H(z) = 1 - 2\cos(\theta)z^{-1} + z^{-2}\\ +H(z) = (1 - rz^{-1})(1 - r^{-1}z^{-1})\\ +H(z) = 1 + bz^{-1} + cz^{-2} + bz^{-3} + z^{-4} +$$
+ +

FIR 滤波器的频率取样结构

$$ +H(z) =\sum\limits_{n=0}^{N - 1}h[n]z^{-n} = \frac{1}{N}(1 - z^{-N})\sum\limits_{k=0}^{N - 1}\frac{H(k)}{1 - W_N^{-j}z^{-1}} +$$
+ +

$H(k)$ 是 FFT 变换。

+

若冲激响应是实序列,可以用共轭对称性将成对的一阶子系统合称为二阶子系统

+
$$ +H_k(z) + H_{-k}(z) = 2|H(k)| \frac{\cos\theta(k) - (\cos(\theta(k) - \frac{2\pi}{N}k))z^{-1}}{1 - 2\cos(\frac{2\pi}{N}k)z^{-1} + z^{-2}} +$$
+ +

其中 $\theta(k)$ 是 $H(k)$ 的相位

+

不成对的子系统?

+
$$ +H_0(z) = \frac{H(0)}{1 - z^{-1}}\\ +H_{N/2}(z) = \frac{H(0)}{1 + z^{-1}} +$$
+ +

FIR 滤波器的时分复用结构

+

离散希尔伯特变换

$$ +h[n] = \begin{cases} + \frac{1 - \cos(n\pi)}{n\pi}, n \ne 0\\ + 0, n = 0 +\end{cases} +$$
+ +

典型数字信号处理系统及其误差源

    +
  • 引起有限字长的误差源
      +
    • AD 变换引入的误差
    • +
    • 有限精度引起的误差
    • +
    • 限制乘法运算位数的误差
    • +
    • 防止加法溢出压缩信号电平的误差
    • +
    +
  • +
+

量化误差的统计分析模型

$$ +Q_B \lbrace x[n] \rbrace = x[n] + e[n]\\ +$$
+ +

$e[n]$ 是各态历经的平稳随机序列,与 $x[n]$ 相互统计独立,具有白噪声的性质,不同时刻的取值相互独立,是均匀分布的。

+
\ No newline at end of file diff --git "a/2023/09/20/\346\225\260\345\255\227\347\263\273\347\273\237\350\256\276\350\256\241/index.html" "b/2023/09/20/\346\225\260\345\255\227\347\263\273\347\273\237\350\256\276\350\256\241/index.html" new file mode 100644 index 00000000..f3a491ee --- /dev/null +++ "b/2023/09/20/\346\225\260\345\255\227\347\263\273\347\273\237\350\256\276\350\256\241/index.html" @@ -0,0 +1,493 @@ +数字系统设计 | Guo_Yun + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

数字系统设计

绪论

软硬件协同,制作深度学习硬件

+

理论课,讲座,Lab

+

专用电路

+

目标:做一个类似于Google TPU中的某计算模块

+

benchmark: ML

+

每4周一个Lab,无期中期末

+

作业:

+

AlexNet Paper

+

Quantization of CNN

+

DNN

Training & Inference

Training: forward and backward

+

Inference: backward

+

Model

+

五类算子:

+

+

特征提取器:卷积层,池化层;

+

分类器:全连接层

+

线性卷积层

+

边界扩充(Padding):在图像周围扩展一圈0,避免多次卷积导致数据尺寸越来越小

+

卷积步长(Stride):卷积核每次跳的步数。可以用来让数据尺寸快速变化

+

非线性函数-激活函数

+

非线性-正则化函数

+

非线性-池化函数

+

池化层

+

池化层减小图片的尺寸,从而减小参数的数量和计算量。

+

最大池化:在池化窗口内取最大值作为输出。

+
    +
  • 复杂度低,硬件实现容易
  • +
  • 最为常用
  • +
+

平均池化:取池化窗口内的平均值作为输出。

+

$L^2$ 池化法:对所有的数计算平方后累加求和再开平方。

+
    +
  • 计算复杂度高
  • +
  • 几何平均池化的复杂度更高
  • +
+

线性全连接层

+

将特征图映射为分类结果

+

Softmax 层

+

有的模型在输出层使用softmax对输出进行归一化:

+
$$ +f(z_j) = \dfrac{e^{z_j}}{\sum_{i = 0}^n e^{z_j}} +$$
+ +
    +
  • 输入和输出规模相同
  • +
  • 归一化计算,让较大的值凸显,让较小的值被抑制,从而决定分类概率
  • +
+

卷积神经网络的总体结构

+

Dataset

数据集的建立:数据采集,数据标签,数据清洗,数据增强,数据分割

+

Cost function

Optimization

    +
  • 梯度下降法
  • +
  • SGD
  • +
  • 动量法:计算过去的平均梯度
  • +
  • AdaGrad法:累加梯度方差
  • +
  • RMSProp:按时间降低学习率
  • +
  • Adam 算法:指数加权移动平均值计算梯度动量和二次矩
  • +
  • SGD简单,但是训练过程边长,自适应算法会更高效
  • +
+

Evaluation

回归问题指标

+

PSNR

+
$$ +PSNR = 10 \cdot \log_{10}(\frac{MAX_I^2}{MSE}) +$$
+ +

分类问题指标

+
    +
  • Top1 accuracy
  • +
  • Top5 accuracy
  • +
+

IoU

+

Intersection of Union?

+
$$ +\text{IoU} = \frac{|A\cap B|}{|A \cup B|} +$$
+ +

检测任务评价指标 mAP

+

mean average precision

+

真阳性TP: 预测为真,实际为真

+

假阳性FP:预测为真,实际为假

+

假阴性FN:预测为假,实际为真

+

查全率(召回率,Recall)和查准率(准确率,Precision)

+
$$ +\text{Precision} = \frac{TP}{TP + FP}\\ +\text{Recall} = \frac{TP}{TP + FN} +$$
+ +

置信度衡量的是模型认为有效的自信程度。我们先将结果按照置信度从高到低排序。

+

mAP是不同查全率下,最高查准率的平均值。

+

网络结构的发展和讨论

分类任务

+

AlexNet

+
    +
  • 使用多个卷积层,有效提取图像特征
  • +
  • ReLU 提高训练速度
  • +
  • Dropout、数据增强扩大训练集,防止过拟合
  • +
+

VGG

+
    +
  • 使用 3 * 3 的卷积核取代 AlexNet 的大卷积核
      +
    • 提升收敛速度
    • +
    • 参数量更少
    • +
    • 可以构建更深的网络,有更多的非线性变换,还有更强的表征能力
    • +
    +
  • +
  • 参数预初始化策略
  • +
+

ResNet

+

?

+

目标检测

+

Two-stage v.s. One-stage

+

Two-stage

+

先画框,再分类

+

MS CoCo Dataset

+
    +
  • 用的最多的还是目标检测任务
  • +
+

R-CNN

+
    +
  • 输入图像
  • +
  • 提取候选框
  • +
  • 每一个候选框提取单独的特征
  • +
  • 进行分类
  • +
+

Fast R-CNN

+
    +
  • 输入图像
  • +
  • 一次特征提取
  • +
  • 提取候选框
  • +
  • 进行分类
  • +
+

Faster R-CNN

+
    +
  • 输入图像
  • +
  • 一次特征提取
  • +
  • 提取候选框
  • +
  • 进行分类
  • +
+

One-stage

+

YOLO

+

五代发展,最广泛的目标检测算法

+

对于每一个像素,都会输出一个对应的特征向量,包含:

+
    +
  • 二分类:是物体中心的置信度
  • +
  • 回归:偏离物体中心的长度 $\Delta x$ 和 $\Delta y$
  • +
  • 分类:对应的物体分类以及置信度
  • +
  • 回归:该像素所代表的物体的长宽,YOLO有一些基础框(anchor),输出值是相对基础框的形变 $\Delta h$ 和 $\Delta w$
  • +
+

NMS (Non-Maximum Suppression)
Bounding boxes for one instance may overlap.
Method: For each type, use NMS to eliminate redundant bounding boxes (greedy approach).
Workflow:

+
    +
  1. Sort candidate bounding boxes by classification confidence.
  2. +
  3. Adding the boxes b with most confidence to output list, and delete it from the candidate boxes.
  4. +
  5. Calculate IoU between b and other boxes bi. If > threshold, delete bi.
  6. +
  7. Repeat until no candidate bounding boxes.
  8. +
+

序列模型(Serial Model)

+

to process Speech, text, video, audio, etc.

+

Feature:

+
    +
  1. The data input is in the time sequence.
  2. +
  3. There is a correlation between the data before and after.
  4. +
+

So the model should have the ability to “store” information.

+

Speech dataset: TIMIT

+
    +
  1. It consists of recordings of 630 speakers of 8 dialects of American English each reading 10 phonetically-rich sentences.
  2. +
  3. It also comes with the word and phone-level transcriptions of the speech.
  4. +
+

Video dataset: DAVIS

+

The Densely Annotation Video Segmentation dataset (DAVIS) is a high quality and high resolution densely annotated video segmentation dataset under two resolutions, 480p and 1080p.

+

There are 50 video sequences with 3455 densely annotated frames in pixel level. 30 videos with 2079 frames are for training and 20 videos with 1376 frames are for validation.

+

NLP dataset: GLUE

+

General Language Understanding Evaluation (GLUE) benchmark: Standard split of data totrain, validation, test, where labels for the test set is only held in the server.

+
    +
  • Sentence pair tasks
      +
    • MNLI, Multi-Genre Natural Language Inference
    • +
    • QQP, Ouora Ouestion Pairs
    • +
    • QNLI, Ouestion Natural Language Inference
    • +
    • STS-B The Semantic Textual Similarity Benchmark
    • +
    • MRPC Microsoft Research Paraphrase Corpus
    • +
    • RTE Recognizing Textual Entailment
    • +
    • WNLI Winograd NLI is a small natural language inference
    • +
    +
  • +
  • datasetSingle sentence classification
      +
    • SST-2 The Stanford Sentiment Treebank
    • +
    • CoLA The Corpus of Linguistic Acceptability
    • +
    +
  • +
+

Models

+

RNN: Recurrent Neural Network

+
    +
  • one to one
  • +
  • one to many
  • +
  • many to one
  • +
  • many to many
  • +
  • many to many
  • +
+

+

损失函数的计算:

+

单个时刻:

+
$$ +L^{(t)} = -\mathbf y^{(t)} \ln \mathbf {\hat {y}}^{(t)} +$$
+ +

整个序列:

+
$$ +L = \sum\limits_{t=1}^{\tau}L^{(t)} = - \sum\limits_{t=1}^{\tau} \mathbf y^{(t)} \ln \mathbf {\hat {y}}^{(t)} +$$
+ +

然后可求梯度:

+

alt

+

循环神经网络存在梯度爆炸或梯度消失,因此无法处理长期的依赖关系。

+

LSTM: Solving the Gradient

+

Transformer

+

Self attention:

+
$$ +\text{Attention}(Q, K, V) = \text{softmax}(\frac{QK}{\sqrt d_k})V +$$
+ +

Quantization

Fixed-point and floating-point representation

Fixed Point arithmetic

$$ +\underbrace{0}_{\text{Sign bit}}\ \ \underbrace{10\dots01}_{n\text{ bit integer part}}\ \ .\underbrace{10\dots01}_{m\text{ bit fractional part}} +$$
+ +

Fixed point with slope and bias

+

apply a linear transform on fixed point:

+
$$ +y = s*x + z +$$
+ + + +

Floating-poing arithmatic

alt

+

IEEE 754 Floating Point Standard

+
    +
  • Called Biased Notation, where bias is number subtracted to get real number.
  • +
  • IEEE 754 uses bias of 127 for single precision, 1023 for double precision.
  • +
+

alt

+
$$ +(-1)^S \times (1 + m) \times 2^{(E - \text{Bias})} +$$
+ +

fp15(helf precision)

+

alt

+

Hardware implications

alt

+

加法下定点数比浮点数功耗小得多,但是乘法下定点数和浮点数的性能差不多。

+

Low bit Fixed-point representations on digital system

+

Quantization for deep learning

    +
  • Post-training quantization
  • +
  • Quantization-aware training
  • +
+

Post-training quantization

+
$$ +r = S(Q - Z)\\ +OA[i, k] =\sum\limits_{j=1}^{N}(W[i, j] * IA[j, k])\\ +q_{OA}^{(i, k)} = Z_{OA} + \frac{S_W * S_{IA}}{S_{OA}}\sum\limits_{j=1}^{N} (q_W^{(i, j)} * q_{IA}^{(j, k)}) +$$
+ +

Choose the optimal threshold

+

No saturation is bad

+

Classic research for quantization methods

Basic structure

+

Weight Quantization & Activation Quantization

+

alt

+

Dorefa Net

+
    +
  • quantization for gradient
  • +
  • normalize data to ensure the data distribution not change after quantization
  • +
  • uniform noise to offset the quantization noise for gradient
  • +
  • replace accumulate with bitcount operation
  • +
  • result is that gradient precision is most sensitive in TAQ(G > A > W)
  • +
+

INQ

+
    +
  • quantization first half and freeze the other, then unfreeze other to train normally
  • +
  • exchange the first half and second half, and repeat above
  • +
+

alt

+

Pact

+
    +
  • clipping the activation before quantization is better
  • +
+
$$ +PACT(x) = 0.5(|x| - |x - \alpha| + \alpha) = \begin{cases} + 0, x<0,\\ + x, 0\le x \lt \alpha,\\ + \alpha, x \ge \alpha +\end{cases} +$$
+ +

Different layers need different α

+

alpha should be learnable

+

Outlier quantization

+
    +
  • Use different quantized bits to quantize different weights. Some weight can have higher precision while others not.
  • +
+

alt

+

Quantization interval learning

+
    +
  • Most of the weights are very small. Minor weights can have too large value.
  • +
+

alt

+

a should be pruned, c should be clipped, only b worths quantizing.

+

Binary neural networks (BNN)

+
    +
  • Networks with weights composed of {-1, 1}
  • +
+

alt

+
    +
  • 计算时长跟精度有平方反比的关系,优化是平方的
  • +
  • 存储跟精度只有线性的关系,优化是线性的,由于BNN bit数少,总的参数量更多,实际上存储没怎么优化
  • +
  • BNN 大幅优化了计算,但是存储没变,此时存储成为了瓶颈
  • +
+

State-of-the-art hardware support for low
precision DNNs

+

alt

+

Pruning

稀疏矩阵是指矩阵中大部分元素都是0的矩阵。获得稀疏矩阵,有助于加速训练和推理速度。

+

Sparsity: New Dimension For Efficiency

稀疏性的来源:

+
    +
  • 剪枝 - 权重
  • +
  • ReLU - 激活
  • +
  • Domain Specific
  • +
+

Weight Sparsity: Pruning

剪枝方法:

+
    +
  • 很多参数其实是很接近0的数
  • +
  • 因此,低于某一阈值时,直接将其赋0.但是这样会影响精度。
  • +
  • 还可以用添加正则项的方法(Weight decay):
      +
    • $CF = MSE_{train} + \lambda \sum_i w_i^2$
    • +
    • $CF = MSE_{train} + \lambda \sum_i |w_i|$
    • +
    +
  • +
+

Activation Sparsity: ReLU

Weight Sparsity Perspective

不同的稀疏程度:

+

alt

+

Unstructured Sparsity

Han Song@NIPS2015 的剪枝策略:

+

alt

+

第一轮训练后,将所有接近0的神经元剪除,再重新对剩下的进行训练(retrain)。

+
    +
  • 压缩比很高,而准确率几乎不下降
  • +
  • 对于硬件并不友好,虽然有很多0,但是硬件上没法把它们压缩掉。
  • +
  • 计算速度并没有提高,甚至降低了
  • +
+

Structural Sparsity

SSL 剪枝策略(Structured weight pruning)

+
    +
  • 不是剪一个神经元,而是把一行/一列/一个通道全部剪掉。(不过,不是真的剪枝,而是修改代价函数的正则项)
  • +
  • 规则化的剪枝对硬件更加友好
  • +
+

代价函数的表达式:

+

alt

+
    +
  • 成功在一般设备上加速了
  • +
+

Pattern Pruning

+

研究卷积核内非0的权重是如何分布的。

+

alt

+

如果某个“分布模式”反复的出现,就可以对它进行压缩存储:

+

alt

+

这一方面的成果:

+
    +
  • Flexible-Length Pattern Pruning:用概率统计方法得到特定的模式
  • +
  • Fixed-Length Pattern Pruning:约束了模式里面非0元素的个数
  • +
+

Unstructured vs. structured

剪枝技术基本上已经成熟:

+
    +
  • Non-stuctured pruning
      +
    • 高压缩率
    • +
    • 只能在特定设备上来降低功耗,但是性能其实没什么提升
    • +
    +
  • +
  • Structured pruning
      +
    • 对硬件更友好
    • +
    • 低压缩率
    • +
    +
  • +
+

(压缩率指的是训练的速度,即将数据“压缩”为神经网络的内蕴知识的能力。)

+

Frequency-Domain Sparsity

采用循环的卷积核

+
    +
  • 因为循环出现的元素,存储降低
  • +
  • 计算等价为循环卷积,可以转换为 FFT 频域相乘,获得更高效的计算
  • +
+

Activation Sparsity Perspective

Inter-Frame Sparsity

一段序列的相邻帧之间具有相似性。因此只需要存储帧与帧之间的差值就行了。

+

Yuan Z@ISSCC 2020 的结论:

+
    +
  • 差分帧并不是稀疏的
  • +
  • 差分帧的数值集中于低的bit位,分布集中
  • +
  • 而高bit位很多都是0,非常稀疏
  • +
+

因此,可以对低 bit 位和高 bit 位拆分处理。

+

ROI Spasity:Input Dependent

ROI: Region of Interest

+

图像里包含的信息,有的丰富,有的贫乏,有的容易识别,有的很难识别。

+
    +
  • 稠密的输入用大核,稀疏的输入用小核?
  • +
+

基于不同的输入,采用不同的网络:

+
    +
  • 图像中难度高的区域通过更深的网络层
  • +
  • 难度低的区域通过更浅的网络层
  • +
+

Leveraging Sparsity in Storage

如何压缩稀疏矩阵的存储空间?

+

Bitmask Compression

alt

+

Run-Length Encoding

游程编码
(matlab警告)

+

alt

+

Compressed Sparse Row (CSR)

alt

+

Compressed Sparse Column (CSC)

alt

+

The Taco Notation

?

+

讲座

量化

Uniform & Non-uniform

+

Non-uniform quantization is not efficient for hardware deployment

+

Symmetric vs Asymmetric Quantization

+

Quantization Granularity: Layer-wise vs Channel-wise

+

Dynamic vs Static Quantization

+

静态的更常用,因为量化本身就是为了加快速度,动态量化却一边训模型一边更新量化区间的范围,反而减慢了速度。不过也有使用动态量化的时候(Mid Journey 生成图像)。

+

什么是mixed-precsion quantization?

+
\ No newline at end of file diff --git "a/2023/09/20/\351\207\217\347\255\222/index.html" "b/2023/09/20/\351\207\217\347\255\222/index.html" new file mode 100644 index 00000000..207acf76 --- /dev/null +++ "b/2023/09/20/\351\207\217\347\255\222/index.html" @@ -0,0 +1,1152 @@ +量筒 | Guo_Yun + + + + + + + + + + + + + + + + + + + + + + + + + +

量筒

量子力学

第一章 引言

光的粒子性:

+
    +
  • 黑体辐射
  • +
  • 光电效应
  • +
  • 康普顿散射
  • +
+

原子模型:能级和跃迁

+

电子衍射:例子的波动性

+

黑体辐射的解释:

+

普朗克公式

已知

+
$$ +P(\varepsilon_\nu = nh\nu) \propto e^{-\varepsilon_{\nu}/kT} +$$
+ +

平均光子数

+
$$ +\overline{n} = \frac{1}{e^{hv/kT} - 1}\\ +$$
+ +

又知一个光子的能量$h\nu$,模式密度(单位频率间隔的模式数)$8\pi\nu^2/c^3$,故单位体积单位频率间隔之间的能量为

+
$$ +\rho(v) = \frac{8\pi \nu^2}{c^3}\overline{n}h\nu +$$
+ +

de Broglie的物质波假说和薛定谔方程

$\hbar = h/2\pi$

+
$$ +\vec{k} = \frac{\vec p}{\hbar}, \omega = \frac{E}{\hbar} +$$
+ +

注:非相对论粒子的能量$E = p^2/2m$,光子的能量$E=cp$

+

自由粒子波函数

+

经典波改写:

+
$$ +\Psi(\vec r, t) = Ae^{-i(\omega t - \vec k \cdot \vec r)} = A e^{-i(Et - \vec p \cdot \vec r)/\hbar} +$$
+ +

满足$E = p^2/2m$.

+

试探得到,自由粒子波函数是薛定谔方程的解:

+
$$ +\begin{align*} +\vec p \Psi &= -i \hbar \nabla\Psi\\ +\Rightarrow p^2\Psi &= -\hbar^2\nabla^2\Psi\\ +\Rightarrow i\hbar\frac{\partial \Psi}{\partial t} &= E\Psi = \frac{p^2\Psi}{2m} = H\Psi\\ +(H &= -\frac{\hbar^2}{2m}\nabla^2) +\end{align*} +$$
+ +

由于$E$可以被$\vec p$表示,故可以写成$\vec p$的函数:

+
$$ +\Psi_{\vec p}(\vec r, t) = Ae^{-i[E(\vec p) t - \vec p \cdot \vec r]/\hbar} +$$
+ +

$\Psi(\vec r, t) = \sum_{\vec p} C_{\vec p}\Psi_{\vec p}(\vec r, t)$满足薛定谔方程。

+

如果有势能项,薛定谔方程改为:

+
$$ +i\hbar\frac{\partial \Psi}{\partial t}= H\Psi = -\frac{\hbar^2}{2m}\nabla^2\Psi(\vec r, t) + V(\vec r)\Psi(\vec r, t)\\ +$$
+ +

这里

+
$$ +H = -\frac{\hbar^2}{2m}\nabla^2 + V(\vec r) \equiv \frac{\hat p^2}{2m} + V(\vec r) +$$
+ +

引入了动量算符(量子化假设)$\hat p = -i\hbar \nabla$

+

注:从薛定谔方程的形式可以得知,其解的表达式里$t$前面的系数肯定含$-i$。如果含$i$,是不满足薛定谔方程的。

+

从经典到量子的过渡

以一维单粒子为例:

+

牛顿力学:

+
$$ +p \equiv m\dot{q}\\ +f = ma = m\ddot{q} +$$
+ +

保守力:

+
$$ +f = -\frac{\partial V}{\partial q} +$$
+ +

定义哈密顿量:

+
$$ +H(q, p) = \frac{p^2}{2m} + V(q) +$$
+ +

从而牛顿力学可以用正则方程代替:

+
$$ +\dot p = -\frac{\partial H}{\partial q}, \dot{q} = \frac{\partial H}{\partial p} +$$
+ +

推广到体系:

+

假设一个体系的运动可以用广义坐标$q_i$ $(i=1,2,\dots,n)$ 描述,拉格朗日函数为 $L(q_i, \dot{q}_i, t)$。根据哈密顿原理,体系的运动满足哈密顿正则方程。

+

哈密顿正则方程可表示为:

+

$\frac{\partial H}{\partial p_i} = \dot{q}_i, \quad \frac{\partial H}{\partial q_i} = -\dot{p}_i$

+

其中,$H(p_i, q_i, t)$ 是哈密顿函数,定义为:

+

$H(p_i, q_i, t) = \sum_{i=1}^{n} p_i\dot{q}_i - L(q_i, \dot{q}_i, t)$

+

其中,$p_i$ 是广义动量,定义为:

+

$p_i = \frac{\partial L}{\partial \dot{q}_i}$

+

哈密顿正则方程描述了体系在广义坐标和广义动量空间中的运动行为,从而完整地描述了体系的运动。

+

哈密顿函数H是否正确的判据:

+

如果正则方程与已知的经典力学方程一致,则此哈密顿函数是正确的。

+

量子化(单粒子情况)

+
$$ +i\hbar\frac{\partial \Psi}{\partial t}= H\Psi = \left(-\frac{\hbar^2}{2m}\nabla^2 + V(\vec r)\right)\Psi\\ +$$
+ +

$|\Psi^2|$给出了粒子在空间中的位置概率。波函数结果数学变换,还能够给出各个力学量的概率分布(例如动量概率密度分布)。

+

多粒子体系:

+

对于全同多粒子体系,还需要引入新假设(对波函数施加新限制,后面讲)。

+

统计物理怎样描述粒子运动?

+

统计物理中需要引入新假设描述极大量粒子的热运动,这种运动不能由通常的量子力学给出。

+

混合态:热运动的无规性会造成状态不能用一个确定的波函数描述,这种状态称为混合态(统计物理中体系的状态一般都是混合态)。

+

纯态:量子力学部分都默认波函数是确定的,称为纯态(它是极特殊的情况)。单个粒子的叠加态依然是纯态。

+

第二章 薛定谔方程和一维运动问题

波函数及其统计解释

波函数及其统计解释

+

Born 对双缝干涉的解释:$|\Psi(\vec r, t)|^2$与概率密度成正比

+

$\Psi(\vec r, t)$称为概率幅,完全描写了状态(这种描写具有统计的特征),它决定了各可观测的物理量的几率分布。

+

波函数本身不能被直接观测。

+

波函数的归一化

+

$|\psi(x, y, z, t)|^2$是相对几率密度。

+

$|\psi(x, y, z, t)|^2\mathrm{d}x\mathrm{d}y\mathrm{d}z$是t时刻出现在$x, y, z$处$\mathrm{d}x\mathrm{d}y\mathrm{d}z$体积元内的相对几率。

+
$$ +\int_{全空间}|\psi(x, y, z, t)|^2\mathrm{d}x\mathrm{d}y\mathrm{d}z = 1 +$$
+ +

为了归一化,选择新的波函数$\Psi(x, y, z, t)$

+
$$ +\Psi(x, y, z, t) = C\psi(x, y, z, t) +$$
+ +

可得

+
$$ +|C| = \frac{1}{\sqrt{\int_{全空间}|\psi(x, y, z, t)|^2\mathrm{d}x\mathrm{d}y\mathrm{d}z}} +$$
+ +

Remark:

+
    +
  • 归一化的波函数仍然有一个位相因子不能确定。习惯上取C为正实数(相角为0)
  • +
  • 有的波函数不能(有限地)归一。例如平面波$\Psi(x, t) = e^{-i(Et - px)/\hbar}$。$|\Psi(x, t)|^2 = 1$代表了在各处出现的机率相等。
  • +
+

态的叠加原理(重要)

+

若$\Psi_1, \Psi_2$是体系的可能状态,那么

+
$$ +\Psi = c_1\Psi_1 + c_2\Psi_2 +$$
+ +

也是体系的可能状态。

+

干涉效应:

+ + +
$$ +|\Psi|^2 = |c_1\Psi_1|^2 + |c_2\Psi_2|^2 + \underbrace{ c_1^*c_2\Psi_1^*\Psi_2 + c_1c_2^*\Psi_1\Psi_2^*}_{干涉项} +$$
+ +

因此,态相加不等于几率相加。

+

关于相位:

+
    +
  • 绝对常数相位没有意义
  • +
  • 相对常数相位才有意义
  • +
+
$$ +\Psi = c_1\Psi_1 + c_2\Psi_2 = e^{i\phi_1}(|c_1|\Psi_1 + |c_2|e^{\phi_2 - \phi_1}\Psi_2)\\ +$$
+ +

$|\Psi|^2$依赖于$\phi_2 - \phi_1$

+

变化的相位是有意义的。(常数相因子可以扔掉)

+
$$ +\Psi(\vec r, t) = |\Psi(\vec r, t)|e^{i\varphi(\vec r, t)} +$$
+ +

$\varphi(\vec r, t)$在空间几率密度上无法反映,但是在动量几率分布上可以反映出来。

+

态叠加原理的一般性描述

+

对于一个指定的量子体系,如果我们找到了它的“完备的基本状态集合”,那么任何状态都可以由这些基本状态叠加而得到。

+
$$ +\Psi = \sum_n c_n \Psi_n +$$
+ +

考虑自由粒子平面波的叠加:

+
$$ +\Psi_{\vec p}(\vec r, t) = Ae^{-i(Et - \vec p \cdot \vec r)/\hbar} +$$
+ +

自由电子的任何状态都可以写成:

+
$$ +\Psi = \sum_{\vec p} c_{\vec p} \Psi_{\vec p}(\vec r, t) +$$
+ +

又由于动量是连续分布的,改为积分:

+
$$ +\Psi = \int_{\infty} c({\vec p}) \Psi_{\vec p}(\vec r, t)\mathrm d^3 \vec p +$$
+ +

改写成另一种形式,把时间移到系数中:

+
$$ +\Psi = \int_{\infty} c({\vec p, t}) \Psi_{\vec p}(\vec r)\mathrm d^3 \vec p +$$
+其中 +
$$ +c(\vec p,t) = c(\vec p)e^{-iEt/\hbar}\\ +\psi_{\vec p}(\vec r) = Ae^{i\vec p \cdot \vec r/\hbar} +$$
+ +

基底称为动量本征函数,满足本征方程:$-ih\nabla \psi_{\vec p}(r) = \vec p \psi_{\vec p}(\vec r)$。$|c(\vec p,t)|^2$就是概率密度。

+

非自由粒子不能做第一种展开,因为含有$V(\vec r)$项。

+

固定时刻 $t = t_1$, 此刻波函数为$\Psi(\vec r, t_1) = \Psi(\vec r)$

+

+
$$ +\Psi(\vec{r}) = \int\limits_{\infty}^{}c(\vec p)\Psi_{\vec p}(\vec r)\mathrm d^3\vec p +$$
+ +

利用傅里叶变换计算$c(\vec{p})$。

+

首先定义delta函数,其满足

+
$$ +\delta(x - a) = \begin{cases} + 0, &x\ne a\\ + +\infty, &x = a +\end{cases}\\ +\int\limits_{\infty}^{}\delta(x - a)\mathrm dx = 1 +$$
+ +

或者定义为

+
$$ +\int\limits_{\infty}^{}f(x)\delta(x - a)\mathrm dx = f(a)\int\limits_{\infty}^{}\delta(x - a)\mathrm dx = f(a) +$$
+ +

其中$\int_\infty = \int_{-\infty}^{\infty}$

+

delta 函数性质:

+
$$ +\delta(x) = \frac{1}{2\pi}\int\limits_{\infty}^{0}\exp(ikx)\mathrm dk\\ +\delta(\lambda x) = \frac{1}{|\lambda|}\delta(x)\ (\delta \ne 0) +$$
+ +

利用delta函数进行傅里叶变换:

+
$$ +\begin{align*} +\Psi(x) &= \int\limits_{\infty}^{}\Psi(x)\delta(x - x^\prime)\mathrm dx^\prime\\ +&=\int\limits_{\infty}^{}\Psi(x^\prime)\left(\frac1{2\pi}\int\limits_{\infty}^{}e^{ik(x - x^\prime)}\mathrm dk\right)\mathrm dx^\prime\\ +&= \int\limits_{\infty}^{}\left(\int\limits_{\infty}^{}\frac1{2\pi}\Psi(x^\prime)e^{-ikx^\prime}\mathrm dx^\prime\right)e^{ikx}\mathrm dk +\end{align*} +$$
+ +

因而

+
$$ +c(k) = \int\limits_{\infty}^{}\frac1{2\pi}\Psi(x)\exp({-ikx})\mathrm dx\\ +\Psi(x) = \int\limits_{\infty}^{}c(k)\exp(ikx)\mathrm dk +$$
+ +

记$\psi_p = \frac{1}{ \sqrt{2\pi \hbar} }\exp\left(i\frac{p}{\hbar}x\right)$

+

+
$$ +\Psi(x) = \int\limits_{-\infty}^{\infty}c(p)\psi_p(x)\mathrm dp\\ +c(p) = \int\limits_{-\infty}^{\infty}\psi_p^*(x)\Psi(x)\mathrm dx +$$
+ +

推广到三维:

+
$$ +\Psi(\vec r) = \int\limits_{\infty}^{}c(\vec p)\Psi_{\vec p}(\vec r)\mathrm d^3\vec p\\ +\psi_{\vec p} = \frac{1}{\sqrt{2\pi \hbar}^3}\exp\left(i\frac{\vec p}{\hbar} \cdot \vec r\right)\\ +c(\vec p) = \int\limits_{-\infty}^{\infty}\psi_{\vec p}^*(\vec r) \Psi(\vec r)\mathrm dx\mathrm dy\mathrm dz +$$
+ +

加入时间:

+
$$ +\Psi(\vec r, t) = \int\limits_{\infty}^{}c(\vec p, t)\Psi_{\vec p}(\vec r)\mathrm d^3\vec p\\ +\psi_{\vec p} = \frac{1}{\sqrt{2\pi \hbar}^3}\exp\left(i\frac{\vec p}{\hbar} \cdot \vec r\right)\\ +c(\vec p, t) = \int\limits_{-\infty}^{\infty}\psi_{\vec p}^*(\vec r) \Psi(\vec r, t)\mathrm dx\mathrm dy\mathrm dz +$$
+ +

已知$c(\vec p, t)$可以求出动量概率密度和坐标概率密度。

+

薛定谔方程

几率流密度

+

几率密度:

+
$$ +w(\vec{r}, t) = |\Psi(\vec{r}, t)|^2 +$$
+ +

几率密度的时间变化率与某种“流”有关,类比电荷守恒方程:电荷密度的变化率等于电流密度散度的相反数。我们从薛定谔方程推导几率流密度:

+
$$ +\begin{align*} +i\hbar \frac{\partial \Psi}{\partial t} &= -\frac{\hbar^2}{2\mu} \nabla^2\Psi + U\Psi \Rightarrow\\ + \frac{\partial w}{\partial t} &= \Psi^*\frac{\partial \Psi}{\partial t} + \Psi\frac{\partial \Psi^*}{\partial t} \\ + &= \frac{i\hbar}{2\mu}(\Psi^*\nabla^2\Psi - \Psi\nabla^2\Psi^*)\\ + &= \frac{i\hbar}{2\mu} \nabla \cdot (\Psi^*\nabla\Psi - \Psi\nabla\Psi^*)\\ +\end{align*} +$$
+ +
$$ +\frac{\partial w}{\partial t} + \nabla \cdot \vec J = 0 +$$
+ +

从而可以定义

+
$$ +\vec J = \frac{i\hbar}{2\mu} (\Psi\nabla\Psi^* - \Psi^*\nabla\Psi) +$$
+ +

对应的可以推积分形式:

+
$$ +\frac{\mathrm dW_v}{\mathrm dt} = - \oint_S \vec{J} \cdot \mathrm{d} \vec S +$$
+ +

$\vec J$便于记忆可写成

+
$$ +\vec J = \text{Re}\left[\Psi^* \mathrm {\hat v} \Psi\right] +$$
+ +

其中 $\mathrm{\hat v} = \frac{\vec{p}}{\mu}$ 称为速度算符。

+

可以计算电流密度

+
$$ +\vec J_e = e\vec J = e\frac{i\hbar}{2\mu} (\Psi\nabla\Psi^* - \Psi^*\nabla\Psi) +$$
+ +

可以计算原子内部电子的电流,计算超导体等量子系统的电流。

+

例:平面波的几率流密度为$\vec J = w \vec v$

+

全空间总几率守恒:

+ +
$$ +\frac{\mathrm d}{\mathrm dt} W = -\oint_\infty \vec J \cdot \mathrm{d}\vec S = -\frac{i\hbar}{2\mu} \oint(\Psi\nabla\Psi^* - \Psi^*\nabla\Psi) \cdot \mathrm{d}\vec S = 0 +$$
+ +

这里认为波函数在无穷远处为0.

+

如果粒子波函数在开始时刻是归一化的,则以后一直有归一化。

+

定态

+

定态波函数=定态薛定谔方程乘以时间因子

+
$$ +\Psi(\vec r, t) = e^{-\frac{i}{h} Et}\psi(\vec r) +$$
+ +

$\psi(\vec r)$满足 $H\psi(\vec r) = E\psi(\vec r)$

+

定态薛定谔方程

+
$$ +H\psi(\vec r) = E\psi(\vec r) +$$
+ +

$E$ 称为 $H$ 的本征值,$\psi(\vec r)$ 称为 $H$ 的本征函数。

+

含薛定谔方程的一般解

+

含时方程:$i\hbar \frac{\partial \Psi}{\partial t} = H\Psi$

+

定态方程: $H\psi(\vec r) = E\psi(\vec r)$

+

一般解:$\Psi(\vec r, t) = \sum_n c_n\psi_n(\vec r)e^{-\frac{i}{h}E_n t}$

+

定态下几率密度,几率流密度,力学几率分布和平均值都不随时间变化。

+

一维自由粒子定态的基本解:

+
$$ +\psi = e^{i\frac{p}{\hbar}x} = e^{\pm ikx}(p = \pm \hbar k, k = \sqrt{\frac{2\mu E}{\hbar})} +$$
+ +

能量给定后,状态并非唯一的(能量的简并),但是动量给定后,状态却是唯一的。

+

波函数应当满足以下三个条件

+
    +
  • 单值性
  • +
  • 有限性
  • +
  • 连续性
  • +
+

连续性一般意味着 $\Psi$ 和 $\nabla\Psi$ 都连续,但是在势能无穷大的地方,允许 $\nabla\Psi$ 不连续。

+

一维无限深势阱

alt

+

注意,这里的能量本征态不是动量本征态!这里的动量是连续的。因为波函数在0到a的范围内为三角函数,而在范围外为0,并不是周期函数,做傅里叶变换可知动量的图谱是连续的。

+

一维谐振子

alt

+

势垒穿透

alt

+

第三章

动量算符和角动量算符

厄米算符

+
$$ +\int_{}^{}\psi^*(\hat F \varphi) \cdot \mathrm d\tau = \int_{}^{}(\psi\hat F)^*\varphi \cdot \mathrm d\tau +$$
+ +

厄米算符的本征值都是实数。

+

一维动量本征函数

+
$$ +\hat p = -i\hbar \frac{\mathrm d}{\mathrm dx},\\ +\hat p \psi_p = p \psi_p,\\ +\psi_p = C \exp\big(\frac{ipx}{\hbar}\big) +$$
+ +

三维动量本征函数

+
$$ +\psi_{\vec p}(\vec r) = \frac{1}{\sqrt{(2\pi\hbar^3)}}\exp\bigg(\frac{i}{\hbar}\vec p \cdot \vec r\bigg)\\ +\int_{\infty}^{}\psi_{\vec p}^*(\vec r)\psi_{\vec p}(\vec r)\mathrm d\tau = \delta^3(\vec p - \vec p^\prime) +$$
+ +

箱归一化本征函数:

+
$$ +\psi_{p}(-L / 2) =\psi_{p}(L/2)\\ +p = \frac{2\pi \hbar}{n}, n=0, \pm1, \pm2, \dots\\ +\int_{-L/2}^{L/2}\psi_{p}^*(x)\psi_{p}(x)\mathrm dx = \delta_{pp^\prime}\\ +L \rightarrow \infty +$$
+ +

角动量算符

+

角动量算符的定义是:

+
$$ +\hat {\vec L} = \hat{\vec r} \times \hat{\vec p} = -i\hbar \vec r \times \nabla\\ +\hat{L_x} = +$$
+ +

球坐标形式:

+

球坐标单位向量用直角坐标表示:

+
$$ +\hat L_z = -i\hbar \frac{\partial }{\partial \varphi} +$$
+ +

本征函数:

+
$$ +\psi_{m}(\varphi) = C \exp(im\varphi) +$$
+ +

由于单值性 $\psi_m(\varphi + 2\pi) = \psi_m(\varphi)$:

+
$$ +m = 0, \pm1, \pm2, \dots +$$
+ +

归一化:$C = \frac{1}{\sqrt{2\pi}}$

+

结论:

+
$$ +\hat L_z \psi_m = m\hbar \psi_m\\ +m = 0, \pm1, \pm2, \dots +\psi_m(\varphi) = \frac{1}{\sqrt{2\pi}} \exp(im\varphi) +$$
+ +

由于空间的任意一个方向都可以为z方向,因此角动量的任一分量都可以量子化。

+
$$ +\hat L^2 = -\hbar^2\bigg[\frac{1}{\sin \theta}\frac{\partial }{\partial \theta}\bigg(\sin\theta\frac{\partial }{\partial \theta}\bigg) + \frac{1}{\sin^2\theta}\frac{\partial^2}{\partial \varphi^2}\bigg] +$$
+ +
$$ +\hat L^2Y = \lambda \hbar^2Y\\ +Y(\theta, \varphi) = P(\theta)\exp(im\varphi) +$$
+ +

省流:球谐函数

+
$$ +Y_{lm}(\theta, \varphi) = N_{lm}P_l^m(\cos \theta)\exp(im\varphi) +$$
+ +

归一化系数

+
$$ +N_{lm} = (-1)^m\sqrt{\frac{(2l + 1)}{4\pi}\frac{(l - |m|)!}{(l + |m|)!}} +$$
+ +

勒让德函数:

+
$$ +P(w) = \frac{1}{2^l l!}(1 - w^2)^{|m| / 2}\frac{\mathrm d^{l+|m|}}{\mathrm dw^{l+|m|}}(w^2 - 1)^l +$$
+ +

前几个球谐函数:

+
$$ +Y_{00} = \sqrt{\frac{1}{4\pi}}\\ +Y_{10} = \sqrt{\frac{3}{4\pi}}\cos \theta\\Y_{1, \pm1} = \mp \sqrt{\frac{3}{8\pi}}\sin \theta \exp(\pm i\varphi)\\ +$$
+ +

$l = 1$,是 $L^2$ 和 $L_z$ 的共同本征态,但不是 $L_x$ 和 $L_y$ 的本征态,(不确定性原理决定了这三个分量不能同时有本征态)

+

球谐函数的性质

+
$$ +\hat L^2 Y_{lm} = l(l+1)\hbar^2 Y_{lm}\\ +\hat L_z Y_{lm} = m\hbar Y_{lm}\\ +l = 0, 1, 2, \dots\\ +m = l, l - 1, \dots, -l. +$$
+ +

正交归一性:

+
$$ +\int Y^*_{l^\prime m^\prime}(\theta, \varphi)Y_{lm}(\theta, \varphi) \mathrm d\Omega = \delta_{l^\prime l}\delta_{m^\prime m} +$$
+ +
$$ +Y^*_{lm}(\theta, \varphi) = (-1)^m Y_{l, -m}(\theta, \varphi) +$$
+ +

中心力场的运动,氢原子

经典:

+
$$ +H = \frac{1}{2}m_N\dot{\vec r_N^2} + \frac{1}{2}m_e\dot{\vec r_e^2} + U(|\vec r_e - \vec r_N|) +$$
+ +

采用质心坐标和相对坐标:

+
$$ +\vec R = \frac{m_N\vec r_N + m_e \vec r_e}{m_N + m_e}\\ +\vec r = \vec r_e - \vec r_N\\ +M = m_N + m_e\\ +\mu = \frac{m_Nm_e}{M} +$$
+ +
$$ +H = \frac{1}{2}M\dot{\vec R^2} + \frac{1}{2}\mu \dot{\vec r^2} + U(r)\\ +\rArr H = \frac{\vec p_R^2}{2M} + \frac{\vec p^2}{2\mu} + U(r) +$$
+ +

量子化:

+
$$ +H = -\frac{\hbar^2}{2M}\nabla_R^2 - \frac{\hbar}{2\mu}\nabla^2 + U(r) +$$
+ +

相对运动的动量意义是什么?

+

求解氢原子波函数时,将哈密顿量分解为质心的哈密顿算符和相对坐标的哈密顿算符,然后分别求解。相对坐标对应的哈密顿算符求解得到的才是氢原子波函数。因此,得到的氢原子的能量不包括质心运动的能量。

+

省流:氢原子波函数

+
$$ +\psi_{nlm} = R_{nl}(r) Y_{lm}(\theta, \phi) +$$
+ +

其中径向函数

+
$$ +R_{nl}(r) = \frac{u_{nl}(r)}{r}, \rho = \alpha r\\ +u_{nl}(r) = N_{nl} \rho^{l + 1}(\rho) v_{nl}(\rho) \exp(-\frac{1}{2}\rho) +$$
+ +
$$ +主量子数\quad n = 1, 2, 3,\dots, \rightarrow E_n = \frac{E_1}{n^2}\\ +角量子数\quad l = 0, 1, \dots, n -1, \rightarrow L^2 = l(l + 1)\hbar^2\\ +磁量子数\quad m = l, l - 1, \dots, -l, \rightarrow L_z = m\hbar\\ +简并度\quad g_n =\sum\limits_{l=0}^{n - 1}(2l + 1) = n^2 +$$
+ +

定态波函数的宇称性质:

+
$$ +R_nl(r) 偶函数, +$$
+ +

alt

+

alt

+

alt

+

alt

+

电子云有方向性吗?

+

以 $n = 2$ 为例,$Y_{00}, Y_{10}, Y_{11}, Y_{1, -1}$ 的模平方之和为常数。若氢原子随机等概率激发到 $Y_{00}, Y_{10}, Y_{11}, Y_{1, -1}$ 之一,则无方向性。但如果是相干叠加,则有方向性。

+

为什么 $m$ 叫做磁量子数?

+

alt

+
$$ +\vec J_e = (-e) \vec J +$$
+ +

本征函数系的一般性质

正交与归一

+

正交性定理

+

同一个厄密算符 $\hat F$ 的属于不同本征值的本征函数是彼此正交的。

+
$$ +\int_{}^{}\psi_1^*\psi_2\mathrm d\tau = 0 +$$
+ +

本征函数的正交“归一”性

+

离散情况:

+
$$ +\int_{}^{}\phi_k^*(\vec r) \cdot \phi_l(\vec r)\mathrm d\tau = \delta_{kl} = \begin{cases} + 0, k\ne l\\ + 1, k = l +\end{cases} +$$
+ +

连续情况:

+
$$ +\int_{}^{}\phi_{\lambda^\prime}^*(\vec r) \cdot \phi_{\lambda}(\vec r)\mathrm d\tau = \delta(\lambda - \lambda^\prime) +$$
+ +

并非真正的归一化,但是依然满足正交性:例如 $\frac{1}{\sqrt{2\pi \hbar}}e^{\frac{i}{\hbar}px}$。

+

共同本征函数(重点)

+

定义对易括号

+
$$ +[\hat F, \hat G] \equiv \hat F\hat G - \hat G \hat F +$$
+ +

+
$$ +[\hat F, \hat G] = 0 +$$
+ +

则两算符对易。

+

定理:

+
$$ +[\hat F, \hat G] = 0 \Rightarrow 两个算符有组成完全系的共同本征函数 +$$
+ +
$$ +[\hat {p_z}, \hat {p_x}] = [\hat {p_x}, \hat {p_y}] = [\hat {p_y}, \hat {p_z }] = 0 +$$
+ +

它们有共同的本征函数。

+
$$ +[\hat {xp}, \hat {px}] = i\hbar +$$
+ +

没有共同的本征函数。

+

如果 $[\hat {F}, \hat {G}] \ne 0$,则不一定没有共同本征态。例如角动量的本征态 $Y_{00}$。

+
$$ +[\hat {L^2}, \hat {L_i}] = 0\\ +[\hat {L_x}, \hat {L_y}] = i\hbar \hat L_z +$$
+ +

性质:

+
$$ +[A, BC] = [A, B]C + B[A, C] +$$
+ +

简并:力学量 $F$ 的一个本征值对应多个线性无关的本征函数。

+

力学量完全集(完备算符集)

+

为了消除简并,可以选取一组彼此对易的力学量 $F_1, F_2, F_3, \dots$,使得它们的本征值组 $\lambda_1, \lambda_2, \dots$ 对应唯一一个线性无关的共同本征函数 $\psi_{\lambda_1, \lambda_2, \dots}(\vec r)$

+

称 $F_1, F_2, F_3, \dots$ 为力学量完全集。

+
$$ +F_k \psi_{\lambda_1, \lambda_2, \dots}(\vec r) = \lambda_k \psi_{\lambda_1, \lambda_2, \dots}(\vec r) +$$
+ +

实现了正交化:力学量完全集的共同本征函数必然为正交函数系,因为任意两个本征函数,对应的本征值必然不同,由正交性定理得知,两个本征函数必然正交。

+

常见的选取方式

+

对于三维空间的单粒子,可以选取为:

+
    +
  • $(x, y, z)$
  • +
  • $(p_x, p_y, p_z)$
  • +
  • $(H, L^2, L_z)$(对于氢原子适用)
  • +
+

考虑自旋后,还需要增加自旋力学量构成完全集。

+

力学量的平均值公式

$$ +\overline{F(t)} = \int_{}^{}\psi^*(x, t) \hat F \psi(x, t)\mathrm dx +$$
+ +

若没有归一化:

+
$$ +\overline F = \frac{\int_{}^{}\psi^*(x, t) \hat F \psi(x, t)\mathrm dx}{\int_{}^{}\psi^*(x, t) \psi(x, t)\mathrm dx} +$$
+ +

实际上, 利用本征函数的正交性

+
$$ +\int_{}^{}\psi^*(x, t) \hat F \psi(x, t)\mathrm dx =\sum\limits_{n}^{}\lambda_n |c_n|^2 = \overline{F} +$$
+ +

几率幅函数

+
$$ +c_n(t) = \int_{}^{}\phi_n^*(x)\psi(x, t)\mathrm dx +$$
+ +

例题:

+
$$ +\psi = Ae^{ikx} + Be^{-ikx}\\ +$$
+ +

动量值 $\hbar k$ 与 $-\hbar k$ 的概率比值为 $\frac{|A|^2}{|B|^2}$

+
$$ +\bar p = \hbar k \frac{|A|^2}{|A|^2 + |B|^2} + (-\hbar k ) \frac{|B|^2}{|A|^2 + |B|^2} = \frac{|A|^2 - |B|^2}{|A|^2 + |B|^2}\hbar k +$$
+ +

不确定关系

一维谐振子为例:

+
$$ +\psi_(x) = \sqrt{\frac{\alpha}{\sqrt \pi}} e^{-\frac{1}{2}\alpha^2 x^2}\\ +c_p = \sqrt{\frac{\beta}{\sqrt \pi}}e^{-\frac{\beta^2p^2}{2}}\\ +\frac{1}{\alpha} \cdot \frac{1}{\beta} = \frac{1}{\hbar}\\ +\alpha = \sqrt{\frac{\mu \omega}{\hbar}} +$$
+ +

不确定关系的数学表达以及证明

+

如果两个力学量F和G的算符彼此不对易,则它们有不相容性,测量精确度(不确定度)上一般是相互制约的。

+
$$ +\Delta \hat F = \hat F - \overline{ } F\\ +\overline{(\Delta \hat F)^2} = \overline{(\hat F - \overline{F})^2} = \overline{\hat F^2} - \overline{F}^2 +$$
+ +

记 $[\hat F, \hat G] \equiv \hat F\hat G - \hat G\hat F = i\hat C$,则在任意一个状态下

+
$$ +\overline{(\Delta \hat F)^2} \cdot \overline{(\Delta \hat G)^2} \ge \frac{1}{4}\overline{(\Delta \hat C)^2} +$$
+ +

这里 $\hat F$ 与 $\hat G$ 都是厄密算符,所以 $\overline{\hat C}$ 为实数

+

引入

+
$$ +I(\xi) = \int_{}^{}\left | (\xi\Delta \hat F - i\Delta \hat G )\psi^2\right|^2\mathrm d\tau \ge 0 +$$
+ +
$$ +\begin{align*} + I(\xi) =& \xi^2\int_{}^{}(\Delta \hat F \psi)^* (\Delta \hat F \psi)\mathrm d\tau - i\xi \int_{}^{}[(\Delta \hat F \psi)^*(\Delta \hat G \psi) - (\Delta \hat G \psi)^*(\Delta \hat F \psi)]\mathrm d\tau + \int_{}^{}(\Delta \hat G\psi)^*(\Delta \hat G\psi)\mathrm d\tau\\ + =& \xi^2 \int_{}^{}\psi^*(\Delta \hat F)^2\psi\mathrm d\tau - i\xi \int_{}^{}\psi^*\Delta\hat F\Delta \hat G\psi - \psi^*\Delta \hat G\Delta \hat F\psi\mathrm d\tau + \int_{}^{}\psi^*(\Delta \hat G)^2 \psi\mathrm d\tau\\ + =& \overline{(\Delta \hat F)^2} \cdot \xi^2 - i\overline{\Delta \hat F\Delta \hat G - \Delta \hat G \Delta \hat F}\cdot \xi + \overline{(\Delta \hat G)^2}\\ + =& \overline{(\Delta \hat F)^2} \cdot \xi^2 - i [\hat {\Delta F}, \hat {\Delta G}]\xi + \overline{(\Delta \hat G)^2}\\ + =& \overline{(\Delta \hat F)^2} \cdot \xi^2 - i [\hat { F}, \hat { G}]\xi + \overline{(\Delta \hat G)^2}\\ + =& \overline{(\Delta \hat F)^2} \cdot \xi^2 - i [\hat {\Delta F}, \hat {\Delta G}]\xi + \overline{(\Delta \hat G)^2}\\ + =& \overline{(\Delta \hat F)^2} \cdot \xi^2 - \overline{\hat C}\xi + \overline{(\Delta \hat G)^2} +\end{align*} +$$
+ +

由于此式恒正,判别式大于0:

+
$$ +I(\xi) \ge 0 \Rightarrow \overline{(\Delta \hat C)}^2 - 4\overline{(\Delta \hat F)^2}\cdot \overline{(\Delta \hat G)^2} \ge 0 +$$
+ +
$$ +\overline{(\Delta \hat F)^2} \cdot \overline{(\Delta \hat G)^2} \ge \frac{1}{4}\overline{(\Delta \hat C)^2} +$$
+ +

如果要满足取等号条件:

+
$$ +(\xi \Delta \hat F - i \Delta \hat G)\psi = 0 +$$
+ +

此时的波包称为最小不确定波包

+

位置动量不确定关系:

+
$$ +\overline{(\Delta \hat x)^2} \overline{(\Delta \hat p_x) ^2} \ge \frac{\hbar^2}{4} +$$
+ +

非零的“零点能”是不确定性关系的结果。

+
$$ +\overline E = \frac{1}{2\mu}\overline{(\Delta \hat p_x)^2} + \frac{1}{2}\mu \omega\overline{(\Delta \hat x)^2} \ge \frac{1}{2}\hbar\omega\\ +\overline E_{min} = \frac{1}{2}\hbar\omega\\ +$$
+ +

势垒穿透问题:谈论某一点的动能 T 和总能量 E 没有意义,因为 $\hat x, \hat T, \hat H$ 彼此不对易。

+

$H, T, U$ 三个物理量之间彼此不对易,不能同时具有确定的值。故 $H = T + U$ 只是一个算符的等式。

+
    +
  • 若为定态,则 $H$ 确定而 $T, U$ 不确定
  • +
  • 若位置确定,则 $U$ 确定但是 $T$ 和 $E$不确定
  • +
+

求平均值:

+
$$ +\overline H = \overline{ T} + \overline U +$$
+ +

$T$ 的本征值为非负实数,所以

+
$$ +\overline{H} \ge \overline{ U} +$$
+ +

角动量 $Y_{00}$ 情形下,三个分量都具有确定的取值,三个角动量分量都为 0,还是满足不确定性关系。

+

守恒量

要求任意态下 $F$ 平均值不变。

+

平均值的时间演化

+
$$ +\hat H = i\hbar \frac{\partial }{\partial t} +$$
+ +

若算符 $\hat F$ 不显含时间,则

+
$$ +\frac{\mathrm d}{\mathrm dt} \overline{F} = \frac{1}{i\hbar} \overline{[\hat {F}, \hat {H}]} +$$
+ +

若 $\hat F(t)$ 显含时间,则

+
$$ +\frac{\mathrm d}{\mathrm dt} \overline{F} = \frac{1}{i\hbar} \overline{[\hat {F}, \hat {H}]} + \overline{\frac{\partial }{\partial t}\hat F(t)} +$$
+ +

第四章

狄拉克算符和谐振子升降算符

计算本征值问题

+

谐振子:

+
$$ +H = \hbar \omega \frac{1}{2} \left ( \frac{p^2}{m\hbar\omega} + \frac{m\omega^2x^2}{\hbar\omega} \right)\\ +\alpha \equiv \sqrt{\frac{m\omega}{\hbar}}\\ +p^\prime = \frac{1}{\hbar \alpha}p\\ +x^\prime = \alpha x\\ +[\hat {x^\prime}, \hat {p^\prime}] = i +$$
+ +
$$ +H = \hbar\omega\frac{1}{2}[(x^\prime - ip^\prime)(x^\prime + ip^\prime) + 1]\\ +p^\prime = -i \frac{\mathrm d}{\mathrm dx^\prime} +$$
+ +

基态满足

+
$$ +(x^\prime + ip^\prime)\psi_0(x) = 0 +$$
+ +

通过升算符算出激发态

+
$$ +\psi_n = C_n (x^\prime - ip^\prime)^n\psi_0(x) +$$
+ +

换元:

+
$$ +a = \frac{x^\prime + ip^\prime}{\sqrt{2}}\\ +a^+ = \frac{x^\prime - ip^\prime}{\sqrt{2}}\\ +H = \hbar \omega(a^+a + \frac{1}{2}) = \hbar \omega(\hat N + \frac{1}{2})\\ +[a, a^+] = 1 +$$
+ +

设 $\hat N$ 的本征矢为 $\ket{n}$,称$n$为占有数。可以看出这本征矢也是能量的本征态。

+

接下来计算 $\hat N$ 的本征矢:

+
$$ +\langle \hat N \rangle = \bra{n}a^+a\ket{n} \ge 0\\ +\bra{n}a^+a\ket{n} = n \langle n|n \rangle\\ +\Rightarrow n \ge 0 +$$
+ +

如果存在 $n = 0$ 的态:

+
$$ +\bra{0}a^+a\ket{0} = 0\\ +\Rightarrow a\ket{0} = 0 +$$
+ +

这就是基态满足的微分方程。解出基态的坐标表象:

+
$$ +(\alpha x + \frac{1}{\alpha} \frac{\mathrm d}{\mathrm dx})\psi_0(x) = 0 +$$
+ +

重点:升降性质

+

$a\ket{n} = \ket{\phi} = \ket{n - 1}$ 也是本征态。

+
$$ +\hat N \ket{\phi} = (a^+a)\ket{\phi} = (aa^+ - 1)\ket{\phi} = (aa^+ - 1)a\ket{n} = aa^+a\ket{n} - a\ket{n} = a\hat N\ket{n} - a\ket{n} = na\ket{n} - a\ket{n} = (n - 1)\ket{\phi} +$$
+ +

归一化:

+
$$ +\ket{\phi} = c\ket{n - 1}\\ +1 = \langle n - 1 |n - 1 \rangle = \frac{1}{|c|^2}(an, an) = \frac{1}{|c|^2}\bra{n}a^+a\ket{n} = \frac{n}{|c|^2}\\ +取 c = \sqrt{n}\\ +a\ket n = \sqrt{n}\ket{n - 1} +$$
+ +

升降算符(重点):

+
$$ +a\ket n = \sqrt{n}\ket{n - 1}\\ +a\ket{0} = 0\\ +a^+\ket{n} = \sqrt{n + 1}\ket{n + 1} +$$
+ +

$n$ 必为整数。

+

能级:

+
$$ +H = \hbar \omega(a^+a + \frac{1}{2})\\ +E_n = \hbar\omega(n + \frac{1}{2}) +$$
+ +

波函数:

+
$$ +\ket n = \frac{1}{\sqrt{n}}a^+\ket{n - 1} = \frac{1}{\sqrt{n!}}a^{+n}\ket{0}\\ +\psi_n(x) = \frac{1}{\sqrt{n!}}\left (\frac{1}{\sqrt{2}}\left (\alpha x - \frac{1}{\alpha}\frac{\mathrm d}{\mathrm dx} \right) \right)^n \frac{\sqrt{\alpha}}{\pi^{1/4}}e^{-\alpha^2x^2/2} +$$
+ +

相干态:满足 $\hat a \ket \beta = \beta \ket \beta$ 的 $\ket \beta$。

+

海森堡方程

力学量算符含时,波函数不含时

+
$$ +\bra{\psi(t)} F\ket {\psi(t)} \rightarrow \bra{\psi_H}F_H(t)\ket{\psi_H} +$$
+ +

不同图景在物理上等价

+
$$ +\Psi(\vec r, t) = e^{-\frac{i}{\hbar}Ht}\Psi(\vec r, 0)\\ +\ket{\psi(t)} = U\ket {\psi(0)} +$$
+ +

力学量平均值

+
$$ +\overline{F} = \bra{\psi(t)}F\ket{\psi(t)} = \bra{\psi(0)}U^+FU\ket{\psi(0)} = \bra{\psi_H}F_H(t)\ket{\psi_H} +$$
+ +

海森方程

+
$$ +F_H = U^+(t)FU(t), U = e^{-\frac{i}{\hbar}Ht}, U^+ = e^{\frac{i}{\hbar}Ht}\\ +\frac{\mathrm d}{\mathrm dt}U = \frac{1}{i\hbar}HU, \frac{\mathrm d}{\mathrm dt}U^+ = -\frac{1}{i\hbar}HU^+, \\ +\frac{\mathrm d}{\mathrm dt}F_H = \frac{1}{i\hbar}[F_H, H]\\ +\frac{\mathrm d\ket{\psi}_H}{\mathrm dt} = 0 +$$
+ +
$$ +HU = UH +$$
+ +

从经典到量子:

+
$$ +\dot q = \frac{1}{i\hbar}[q, H]\\ +\dot p = \frac{1}{i\hbar}[p, H]\\ +[q, p] = i\hbar +$$
+ +

自旋

用标量波函数 $\Psi(\vec r, t)$ 描述是否完整?

+

经典力学给出了轨道磁矩和磁势能

+
$$ +\vec M_L = -\frac{e}{2m_e}\vec L\\ +U = - \vec M \cdot \vec B +$$
+ +

磁矩的最小单元(Bohr磁子)

+
$$ +M_B \equiv \frac{e\hbar}{2m_e} +$$
+ +

Stern-Gerlach 实验:即使是 $l = 0$ 的 $s$ 态原子也会在磁场中偏转。认为电子除了轨道磁矩,还有自旋磁矩。

+

自旋磁矩只有两个可能的值:

+
$$ +M_B \equiv \frac{2\hbar}{2m_e}\\ +M_z = \pm M_B +$$
+ +

Uhlenbeck-Goudsmit假设(1925):电子有内禀(自旋)角动量,其投影只能取两个值:

+
$$ +S_i = \pm \frac{\hbar }{2}, i = x, y , z +$$
+ +

自旋磁矩:

+
$$ +\hat {\vec M_s} = -\frac{e}{m_e}\hat{\vec S} +$$
+ +

自旋有纯量子力学的起源。没有经典对应,独立于之前学过的所有力学量。

+

自旋的分量只有两个可能的测量值,因此可以使用 $2\times 2$ 的矩阵描写。

+

$S_z$的本征值为 $\pm \frac{\hbar}{2}$,采用 $S_z$ 表象,则 $S_z = \frac{\hbar}{2}\begin{pmatrix}
1 &0\
0 &-1
\end{pmatrix}$

+

根据角动量的对易关系(假设的)

+
$$ +[S_x, S_y] = i\hbar S_z\\ +[S_y, S_z] = i\hbar S_x\\ +[S_z, S_x] = i\hbar S_y +$$
+ +

可以导出 $S_x$ 和 $S_y$

+
$$ +S_x = \frac{\hbar}{2}\begin{pmatrix} + 0 & 1\\ + 1 & 0 +\end{pmatrix}\\ +S_y = \frac{\hbar}{2}\begin{pmatrix} + 0 & -i\\ + i & 0 +\end{pmatrix}\\ +S_z = \frac{\hbar}{2}\begin{pmatrix} + 1 & 0\\ + 0 & -1 +\end{pmatrix}\\ +$$
+ +

三个分量不对易,最多只有一个分量具有确定的取值

+
$$ +S_x^2 = S_y^2 = S_z^2 = \frac{\hbar^2}{4}\\ +S^2 = \frac{3\hbar^2}{4} = s(s + 1)\hbar^2\\ +(s = \frac{1}{2})\\ +[S^2, S_i] = 0 +$$
+ +

自旋是内部基本构造,不同于先前学过的力学量,不能写成 $F(\vec r, \vec p)$ 的形式

+

自旋也不能简单看成绕自身某个轴的旋转(电子被当作“点粒子”,自旋不同于经典物体的旋转,量子自旋没有经典的对应)

+

带有自旋的电子波函数(自旋 + 空间坐标)

+
$$ +v_+ = \begin{pmatrix} + 1\\0 +\end{pmatrix} +v_- = \begin{pmatrix} + 0\\1 +\end{pmatrix} + +

\Psi(\vec r, t) \cdot v_+ + \Psi_2(\vec r, t) \cdot v_-
$$

+

波函数有两个自旋分量(类比于电磁波有两个偏振分量)

+

又被称为旋量波函数

+
$$ +\Psi = \begin{pmatrix} + \Psi_1(\vec r, t)\\ + \Psi_2(\vec r, t) +\end{pmatrix}\\ +w(\vec r, t) = \Psi^+\Psi = |\Psi_1|^2 + |\Psi_2|^2\\ +\int_{}^{}\Psi^+\Psi\mathrm d\tau = \int_{}^{}(|\Psi_1|^2 + |\Psi_2|^2)\mathrm d\tau = 1 +$$
+ +

自旋角动量的几率分布

+
$$ +W \left ( \frac{\hbar}{2} \right) = \int_{}^{}|\Psi_1|^2\mathrm d\tau\\ +W \left ( -\frac{\hbar}{2} \right) = \int_{}^{}|\Psi_2|^2\mathrm d\tau\\ +$$
+ +

第五章 微扰论

$$ +\hat H \psi_n = E_n \psi_n\\ +\hat H = \hat H^{(0)} + \hat H^\prime +$$
+ +

作逐级展开:

+
$$ +\psi_n = \psi_n^{(0)} + \psi_n^{(1)} + \psi_n^{(2)} + \cdots\\ +E_n = E_n^{(0)} + E_n^{(1)} + E_n^{(2)} + \cdots\\ +$$
+ +

得到零级,一级,二级方程

+
$$ +\hat H^{(0)} \psi_n^{(0)} = E_n^{(0)}\psi_n^{(0)}\\ +(\hat H^{(0)} - E_n^{(0)}) \psi_n^{(1)} = -(\hat H^\prime - E_n^{(1)})\psi_n^{(0)}\\ +(\hat H^{(0)} - E_n^{(0)}) \psi_n^{(2)} = -(\hat H^\prime - E_n^{(1)})\psi_n^{(1)} + E_n^{(2)}\psi_n^{(0)}\\ +$$
+ +

能量的非简并情形

结论:能级一级修正

+
$$ +E_n^{(1)} = H^\prime_{nn} = \int_{}^{}\psi_n^{(0)*}\hat{H}^\prime\psi_n^{(0)}\mathrm d\tau +$$
+ +

波函数一级修正

+
$$ +\psi_n(x) = \psi_n^{(0)}(x) + \psi_n^{(1)}(x)\\ +\psi_n^{(1)}(x) =\sum\limits_{m\ne n}^{}\frac{H_{mn}^\prime}{E_n^{(0)} - E_m^{(0)}}\psi_m^{(0)}(x) +$$
+ +

适用条件:

+
$$ +\frac{H_{mn}^\prime}{E_n^{(0)} - E_m^{(0)}} << 1 +$$
+ +

二级能量修正公式:

+
$$ +E_n^{(2)} =\sum\limits_{m\ne n}^{}\frac{|H_{mn}^\prime|^2}{E_n^{(0)} - E_m^{(0)}} +$$
+ +

零级能量的简并情形

需要确定适当的零级波函数,可以通过对初始的0级波函数进行表象变换得到。

+
$$ +\psi_{ni}^{(0)} =\sum\limits_{l=1}^{k}c_{li}^{(0)}\phi_{nl}^{(0)} +$$
+ +

通过哈密顿量的修正值 $H^\prime$ 来确定 0 级波函数的选取。1级方程左右同乘 $\phi_l^{(0)*}$ 并积分,可得(下面的方程没有写n,表示都是同一个能级,系数c的下标对应1~k)

+
$$ +H^\prime C^{(0)} = E_n^{(1)}C^{(0)}\\ +H^\prime_{ji} = \int_{}^{}\phi_j^{(0)*}\hat H^\prime\phi_i^{(0)}\mathrm d\tau\\ +C^{(0)} = \begin{pmatrix} + c_1^{(0)}\\c_2^{(0)}\\\dots\\c_k^{(0)} +\end{pmatrix} +$$
+ +

对所有的 $l$ 做上述操作,求出所有的新的零级波函数。

+

$H^\prime$ 在 $E_n^{(0)}$ 对应的简并态子空间的 $k$ 个本征向量决定新的零级波函数 $\psi_n^{(0)}$。对应的 $k$ 个本征值表示一级能量修正 $E_n^{(1)}$。这些一级能量互不相同,使得 $E_n^{(0)} + E_n^{(1)}$有 $k$ 个不同的值,也就是说零级加一级能量是“非简并态”。

+

(这样做有什么意义?)

+

简并微扰波函数的一级修正:

+
$$ +c_{ml}^{(1)} = \frac{\int_{}^{}\phi_m^{(0)*}\hat H^\prime \psi_{nl}^{(0)}\mathrm d\tau}{E_n^{(0)} - E_m^{(0)}}\\ +\psi_{nl}^{(1)} =\sum\limits_{m\ne n}^{}c_{ml}^{(1)}\phi_m^{(0)} +$$
+ +

注意!其中 $\phi_m^{(0)}$ 是 $E_n^{(0)}$ 能级以外的态,这些态可以是简并的。

+

能量的二级修正:

+
$$ +E_{nl}^{(2)} =\sum\limits_{m\ne n}^{} \frac{\left | \int_{}^{}\phi_m^{(0)*}\hat H^\prime\psi_{nl}^{(0)}\mathrm d\tau \right|^2}{E_n^{(0)} - E_m^{(0)}} +$$
+ +

如果求解的本征值有重根?

+

此时零级波函数仍然不能求出来,但是可以求出能量一级修正;若考虑能量的二级修正,需要由二级方程确定零级波函数。

+

外磁场中的原子

Zeeman 效应:外磁场中原子的能级会分裂

+

简单 Zeeman 效应:外磁场作用很强, 可以略去自旋轨道耦合,这就是简单 Zeeman 效应

+
$$ +\vec M = \vec M_L + \vec M_s \approx -\frac{e}{2\mu}(\vec L + 2\vec S)\\ +U_m = -M_zB = \frac{eB}{2\mu} (\hat L_z + 2\hat S_z)\\ +H = H_0(氢原子) + \frac{eB}{2\mu} (\hat L_z + 2\hat S_z) +$$
+ +

结论:$\psi_{n,l,m_l,m_s}$ 组成了完全函数系,对应能级为

+
$$ +E_{n,l,m_l,m_s} = E_n + \frac{eB\hbar}{2\mu}(m_l + 2m_s) +$$
+ +

Zeeman 效应可以调节原子能级,操控原子的量子态,灵敏检测磁场。

+

如何用微扰论求解?

+

显然,在上面介绍的波函数正好使得 $H^\prime$ 成为一个对角矩阵:

+
$$ +\bra{\psi_{n,l,m_l^\prime,m_s\prime}} H^\prime \ket{\psi_{n,l,m_l,m_s}} = \frac{eB\hbar}{2\mu}(m_l + 2m_s)\delta_{m_l^\prime, m_l}\delta_{m_s^\prime, m_s}\\ +E_{n,l,m_l,m_s}^{(1)} = \frac{eB\hbar}{2\mu}(m_l + 2m_s) +$$
+ +

求自旋轨道耦合产生的精细结构?

+

(困难的拓展问题,在课程内不能完全解决)

+
$$ +H = H_0 + H^\prime\\ +H^\prime = \ksi(r)\vec L \cdot \vec s\\ +\ksi(r) = \left ( \frac{e^2}{8\pi\varepsilon_0} \right)\frac{1}{m_e^2c^2r^3} +$$
+ +

采用耦合表象基底 $L^2, L_z, S_z$ 共同本征态

+
$$ +\hat Y_{ljm} =\sum\limits_{m_lm_s}^{}c(l, j, m;l, m_l, m_s)Y_{lm_l}\chi_{m_s} = \ket{l, j, m} +$$
+ +
$$ +\vec J = \vec L + \vec s\\ +\vec L \cdot \vec s = \frac{1}{2}(\vec J^2 - \vec L^2 - \vec s^2) +$$
+ +

$H^\prime$ 又是一个对角阵:

+
$$ +\bra{l^\prime, j^\prime, m^\prime}\vec L \cdot \vec s\ket{l, j, m} = \frac{1}{2} \left [ j(j + 1) - l(l + 1) - \frac{3}{4} \right]\hbar^2\delta_{ll^\prime}\delta_{jj^\prime}\delta_{mm^\prime} +$$
+ + +

相对论得出的真实的精细结构跟 $l$ 并没有关系。

+

考虑真空电磁场微扰形成的能级微小移动——兰姆位移。

+

统计力学

第一章

平衡态下孤立系统各种微观态的几率相等。

+

最可几方法求玻色分布和费米分布

+

求 $W \lbrace n_i \rbrace$ 的极大值

+
$$ +\bar u = \frac{\Sigma u \lbrace n_i \rbrace W \lbrace n_i \rbrace}{W \lbrace n_i \rbrace} +$$
+ +

习题课

20231028

量子力学基本公理

公理1:希尔伯特空间

+

公理2:可观测量

+

公理3:位置与动量(正则量子化)

+

公理4:薛定谔方程

+

公理5:全同粒子(略:讲统计时会讲)

+

概率流密度的公式并不本质。根据薛定谔方程、概率密度公式、连续性方程可以推出。

+

全空间概率密度$w(t)$不是 $x$ 的函数。

+

要写盒外波函数为0.

+

对任意的束缚的能量本征态, 动量的平均值是 0.

+
$$ +[\hat {x}, \hat {H}] = [\hat {x}, \hat {p}^2/2\mu] = \frac{1}{2\mu}(\hat p[\hat {x}, \hat {p}] + [\hat {x}, \hat {p}]\hat p) = \frac{i\hbar}{\mu}\hat p +$$
+ +
$$ +\int_{-\infty}^{\infty}e^{-\alpha x^2 + \beta x}\mathrm dx = \sqrt{\frac{\pi}{\alpha}}e^{\beta^2/4\alpha} +$$
+ +

20231112

+
$$ +\mu = -\frac{e}{m}S\\ +U = - \mu \cdot B = -\dfrac{eB}{m}S \cdot n = +$$
+ +

+

透射率,反射率计算(用流密度)

+
\ No newline at end of file diff --git a/2023/09/21/Stochastic-Process/index.html b/2023/09/21/Stochastic-Process/index.html new file mode 100644 index 00000000..d7a1f8c9 --- /dev/null +++ b/2023/09/21/Stochastic-Process/index.html @@ -0,0 +1,1779 @@ +Stochastic-Process | Guo_Yun + + + + + + + + + + + + + + + + +

Stochastic-Process

随机过程随机过

信号与系统:研究确定信号随着时间、空间的变化

+

概率论:研究随机信号,但是不随时间、空间变化

+

随机过程:研究随机的信号随着时间、空间的变化

+
+

期末70分梭哈

+

考试题目不随机,就跟不上这门课的要求。

+
+

概率与随机变量回顾

样本空间$\Omega$

+

性质:

+
    +
  • 非负性:$P(A) \ge 0$
  • +
  • 规范性:$P(\Omega), P(\emptyset) = 0$
  • +
  • 可加性:$P(\bigcup\limits_{k = 1}^{\infty}A_k) = \sum\limits_{k=1}^{\infty}P(A_k)$
  • +
+

贝叶斯:

+
$$ +P(B_i|A) = \frac{P(A|B_i)P(B_i)}{\sum\limits_{j = 1}^{k}P(B_j)P(A|B_j)} +$$
+ +

随机变量:

+

分布函数,概率密度函数

+

期望,方差,协方差,相关系数

+

伯努利分布,高斯分布,泊松分布,瑞利分布

+

伯努利分布的概率密度函数:

+

当$k=1$时,$P(X=1) = p$
当$k=0$时,$P(X=0) = 1-p$

+

高斯分布的概率密度函数:
$P(x) = \frac{1}{\sqrt{2\pi\sigma^2}}\exp\left(-\frac{(x-\mu)^2}{2\sigma^2}\right)$

+

二维高斯分布的概率密度函数:

+

$P(x,y) = \frac{1}{2\pi\sigma_x\sigma_y\sqrt{1-\rho^2}}\exp\left(-\frac{1}{2(1-\rho^2)}\left[\frac{(x-\mu_x)^2}{\sigma_x^2}-2\rho\frac{(x-\mu_x)(y-\mu_y)}{\sigma_x\sigma_y}+\frac{(y-\mu_y)^2}{\sigma_y^2}\right]\right)$

+

其中,$\mu_x$和$\mu_y$是均值,$\sigma_x$和$\sigma_y$是标准差,$\rho$是相关系数。

+

泊松分布的概率密度函数:
$P(k;\lambda) = \frac{\lambda^k}{k!}\exp(-\lambda)$

+

瑞利分布的概率密度函数:
$P(x;\sigma) = \frac{x}{\sigma^2}\exp\left(-\frac{x^2}{2\sigma^2}\right)$

+

随机过程的基本概念

定义:

+

给定概率空间$(\Omega, \mathcal{F}, P)$,定义参数集$T \subset R$,$t \in T$

+
$$ +X = \lbrace X(t, \omega), t \in T, \omega \in \Omega \rbrace +$$
+ +

简记为$X(t)$: $X = \lbrace X(t), t \in T\rbrace$

+

解释:

+
    +
  • 二元单值函数
  • +
  • 对每个固定t,$X(t, \omega)$是一个随机变量
  • +
  • 每个$\omega_0 \in \Omega$, $X(t, \omega_0)$是定义在T上的函数,记为$x(t, \omega_0)$
  • +
+

单样本为随机变量:均值、方差、协方差、有限维联合分布等

+

随机过程的函数特性:时间的相关性,连续性和离散性,随机过程的导数、微分、积分、卷积、级数展开、微分方程、积分方程等

+

二重性的联合特征:

+

分类:

+

离散时间,离散分布:Bernouli过程

+

离散时间,连续分布:自回归过程

+

连续参数离散随机过程:Poission过程

+

连续参数连续型随机过程:Brown运动

+

数学特征:

+

相互独立和不相关是两个概念,无必然因果联系。

+

根据数字特征分类:

+
    +
  • 独立增量过程
  • +
  • 平稳过程及二阶矩过程
  • +
  • 马尔可夫过程
  • +
  • 更新过程
  • +
+

独立增量过程是一种随机过程,具有以下特性:

+
    +
  1. 零起点:独立增量过程在零时刻(通常表示为$t=0$)的取值为零,即$X(0) = 0$。

    +
  2. +
  3. 独立增量:对于任意时刻$t_1 < t_2 < \cdots < t_n$,随机变量$X(t_2)-X(t_1), X(t_3)-X(t_2), \cdots, X(t_n)-X(t_{n-1})$是相互独立的。

    +
  4. +
+

若对一切$0\le s \lt t$,增量$X(t) - X(s)$的分布仅依赖于$t - s$,则称之为平稳增量,具有平稳增量的独立增量过程称为独立平稳增量过程,例如泊松和布朗。

+

二阶矩过程:$D(X(t))$

+

宽平稳过程:

+

宽平稳过程可以用以下简单的数学表达式表示:

+
    +
  1. 均值平稳性:对于宽平稳过程 $X(t)$,其均值满足 $E[X(t)] = \mu$,其中 $\mu$ 是一个常数。

    +
  2. +
  3. 自相关平稳性:宽平稳过程的自相关函数在时间差 $\tau$ 下为常数,可以表示为 $R_X(\tau) = R_X(t,t+\tau) = \text{常数}$,其中 $R_X(\tau)$ 表示宽平稳过程的自相关函数。

    +
  4. +
+

严平稳过程(Strict-sense stationary process),也称为严格平稳过程或强平稳过程,是一种具有更强平稳性质的随机过程。它满足以下两个条件:

+
    +
  1. 时移不变性:严平稳过程的统计性质在时间上任意平移保持不变。具体而言,对于任意时间差 $\tau$ 和任意时间点 $t$,随机变量 $X(t)$ 和 $X(t+\tau)$ 的联合分布相同,即联合分布满足 $P(X(t) \in A, X(t+\tau) \in B) = P(X(0) \in A, X(\tau) \in B)$,其中 $A,B$ 是任意集合。

    +
  2. +
  3. 自相关平稳性:严平稳过程的自相关函数只与时间差有关,与参考时刻无关。具体而言,对于任意时间差 $\tau$ 和任意时间点 $t$,自相关函数满足 $R_X(t,t+\tau) = R_X(\tau)$,其中 $R_X(\tau)$ 表示严平稳过程的自相关函数。

    +
  4. +
+

马尔可夫过程是一种具有马尔可夫性质的随机过程。它可以用以下公式和概念来定义:

+
    +
  1. 状态空间:马尔可夫过程的状态空间是一个离散集合,表示可能的状态集合。通常用符号 $S$ 表示,$S = \lbraces_1, s_2, \ldots\rbrace$。

    +
  2. +
  3. 马尔可夫性质:马尔可夫过程具有马尔可夫性质,也称为无后效性。即,在给定当前时刻的状态 $X(t)$ 之下,未来的状态 $X(t+\Delta t)$ 只依赖于当前的状态 $X(t)$,与过去的状态 $X(t-1), X(t-2), \ldots$ 无关。

    +
  4. +
  5. 转移概率:转移概率描述了在给定当前状态 $s_i$ 的情况下,马尔可夫过程在下一个时刻转移到状态 $s_j$ 的概率。转移概率通常用符号 $P_{ij}$ 表示,即 $P_{ij} = P(X(t+\Delta t) = s_j \mid X(t) = s_i)$。

    +
  6. +
+

通过状态空间和转移概率,可以构建一个马尔可夫过程的状态转移矩阵(Transition Matrix),它描述了从一个状态到另一个状态的转移概率情况。

+

更新过程:

+

更新过程可以使用以下公式来描述:

+
    +
  1. 到达时间:假设到达时间的随机变量序列为 $T_1, T_2, T_3, \ldots$,其中 $T_i$ 表示事件 $i$ 的到达时间。

    +
  2. +
  3. 描述参数:更新过程的到达率(或强度)表示单位时间内平均发生事件的次数。通常用符号 $\lambda$ 表示,即 $\lambda = \lim_{t \to \infty} \frac{N(t)}{t}$,其中 $N(t)$ 表示时间 $t$ 之前(包括 $t$)发生的事件次数。

    +
  4. +
  5. 插值函数:更新过程的插值函数(或插值过程)表示给定时间 $t$ 时,最近的到达时间是多久之前。记为 $S(t)$,即 $S(t) = \sup{T_i \leq t}$,表示最近的到达时间小于等于 $t$ 的时间点。

    +
  6. +
+

可以定义复随机过程:

+

复随机过程是一组复数值随机变量的集合 ${X(t), t \in T}$,其中 $X(t)$ 是定义在概率空间 $(\Omega, \mathcal{F}, P)$ 上的复数值随机变量,表示在时间点 $t$ 上的取值。

+

具体而言,对于每个时间点 $t \in T$,$X(t)$ 是一个复数值随机变量,可以表示为 $X(t) = R(t) + iI(t)$,其中 $R(t)$ 和 $I(t)$ 分别表示实部和虚部。

+

复随机过程可以通过概率空间 $(\Omega, \mathcal{F}, P)$ 上的复数随机变量以及时间参数 $T$ 来描述,并且在不同时间点上表现出复数值随机变量的随机性质。

+

数学特征:

+

均值函数(一阶原点矩):$\mu_X(t) = E[X(t)]$

+

方差函数:$\text{Var}[X(t)] = E[(X(t) - \mu_X(t))(X(t) - \overline{\mu_X(t)} )]$

+

自相关函数:$R_X(t_1, t_2) = E[(X(t_1) - \mu_X(t_1))(X(t_2) - \overline{\mu_X(t_2)} )]$

+

自协方差函数:$\text{Cov}[X(t_1), X(t_2)] = E[(X(t_1) - \mu_X(t_1))(X(t_2) - \overline{\mu_X(t_2)} )]$

+

均方值函数:$E[|X(t)|^2] = \int_{-\infty}^{\infty} |x|^2 f_X(x,t)dx$

+

基本研究方法

    +
  • 相关方法
  • +
  • Markov 方法
  • +
+

相关

+

若随机过程在任意时刻的均值和方差都存在,则称之为二阶矩过程(second order process),即均方可积空间上的随机变量。

+

均方可积空间是内积空间。相关运算是均方可积的内积运算:

+
$$ +\langle X, Y \rangle = E(X\overline Y) +$$
+ + +

宽平稳(wide-sense stationary):

+
$$ +R_X(t, s) = R_X(t + D, s + D) = R(t - s) +$$
+ +

功率谱密度:

+
$$ +S_X(\omega) = \int_{-\infty}^{\infty}R_X(\tau)\exp(-j\omega\tau)\mathrm d\tau +$$
+ +

最优线性估计

+

Markov

+

有限维联合分布可以由各阶的条件分布表示出来:

+
$$ +\begin{align*} + &F_{X(t_1), \dots, X(t_n)}(x_1, \dots, x_n) \\ + =&F_{X(t_n)|X(t_{n - 1}), \dots, X(t_1)}(x_n|x_{n - 1}, \dots, x_1)F_{X(t_{n - 1}), \dots, X(t_1)}(x_1, \dots, x_{n - 1})\\ + =&F_{X(t_n)|X(t_{n - 1}), \dots, X(t_1)}(x_n|x_{n - 1}, \dots, x_1)\dots F_{X(t_2)|X(t_1)}(x_2|x_1)F_{X(t_1)}(x_1) +\end{align*} +$$
+ +

无后效性的 markov 过程:

+
$$ +F_{X(t_n)|X(t_{n - 1}), \dots, X(t_1)}(x_n|x_{n - 1}, \dots, x_1) = F_{X(t_n)|X(t_{n - 1})}(x_n|x_{n - 1}) +$$
+ +

从而所有高阶依赖关系都可以简化为二阶依赖:

+
$$ +F_{X(t_1), \dots, X(t_n)}(x_1, \dots, x_n)=F_{X(t_n)|X(t_{n - 1})}(x_n|x_{n - 1})\dots F_{X(t_2)|X(t_1)}(x_2|x_1)F_{X(t_1)}(x_1) +$$
+ +

相关理论与二阶矩过程——时域分析

自相关函数

由二阶矩过程的定义可知,均方可积空间的自相关函数、自协方差函数、互相关函数、互协方差函数均存在。

+

均值函数(一阶原点矩):$\mu_X(t) = E[X(t)]$

+

方差函数:$\text{Var}[X(t)] = E[(X(t) - \mu_X(t))^2]$

+

自相关函数:$R_X(t_1, t_2) = E[(X(t_1))(X^*(t_2))]$

+

自协方差函数:$C_X(t_1, t_2) = \text{Cov}[X(t_1), X(t_2)] = E[(X(t_1) - \mu_X(t_1))(X(t_2) - \mu_X(t_2))^*]$

+

均方值函数:$E[X^2(t)] = \int_{-\infty}^{\infty} x^2 f_X(x,t)dx$

+

互相关函数和互协方差函数:

+
    +
  • 如果$E[X(s)Y(t)]存在$,记为$R_{XY}(s, t)$
  • +
  • 如果$\text{cov}(X(s), Y(t))存在$,记为$C_{XY}(s, t)$
  • +
+
$$ +R_{XY}(t_1, t_2) = E[(X(t_1))(Y^*(t_2))] +$$
+ +
$$ +C_{XY}(t_1, t_2) = E[(X(t_1) - \mu_X(t_1))(Y(t_2) - \mu_Y(t_2))^*] +$$
+ +
$$ +C_{XY}(s, t) = R_{XY}(s,t) - \mu_X(s)\mu_Y(t) +$$
+ +

不相关:

+
$$ +C_{XY}(s, t) = 0 +$$
+ +
$$ +R_{XY}(s,t) = m_X(s)m_Y(t) +$$
+ + +

自相关函数具有共轭对称性:

+
$$ +R(t_1, t_2) = R^*(t_2, t_1) +$$
+ +

离散化的自相关矩阵同样是共轭对称的:

+
$$ +R = E[XX^H]\\ +R_{ij} = R^*_{ji} +$$
+ +

自相关矩阵是非负定的:

+
$$ +\lambda R \lambda^H = \lambda XX^H\lambda^H \ge 0 +$$
+ +

当 $P(\lambda X = 0) = 1$ 时等号成立。

+

非负定性是自相关函数的一种特征性质。如果一个二元函数满足非负定性质,则一定可以构造出一个随机过程,使得其自相关函数为给定的二元函数。

+

自相关矩阵非负定,分解的特征值均非负。其物理意义是信号的能量或者功率。

+

自相关函数对加法和乘法的封闭性:

+
$$ +R(t, s) = \alpha R_1(t, s) + \beta R_2(t, s) +$$
+ +

仍然是某一随机过程的自相关函数。

+

证明:取 $Z(t) = \alpha^{1/2} X(t) + \beta^{1/2} Y(t)$。这里 $X(t), Y(t)$是独立的。

+
$$ +R(t, s) = R_1(t, s)R_2(t, s) +$$
+ +

也是自相关函数。取 $Z(t) = X(t)Y(t)$。

+

宽平稳随机过程

宽平稳

+

对于随机过程 $X(t), t \in T$,若 $\forall t, s\in T$

+
$$ +E(X(t)) = E(X(s))\\ +R_X(t, s) = R_X(t + D, s + D) +$$
+ +

称随机过程 $X(t)$ 具有宽平稳性。

+

宽平稳过程的均值是常数,自相关函数与相对时间差有关。故宽平稳过程的自相关函数可以写成一元函数:$R_X(\tau), \tau = t - s$。

+

严平稳

+

对于随机过程 $X(t), t \in T$,若 $\forall n, \forall t_1, t_2, \dots, t_n \in T$,$\forall D \in T$,都有

+
$$ +F_{t_1, t_2, \dots, t_n}(x_1, x_2, \dots, x_n) = F_{t_1 + D, t_2+D, \dots, t_n + D}(x_1, x_2, \dots, x_n) +$$
+ +

则称随机过程 $X(t), t\in T$具有严平稳性。

+

在二阶矩存在的条件下,严平稳蕴含宽平稳,而反过来,宽平稳一般无法得到严平稳。

+

高斯过程的严平稳与宽平稳等价。

+

联合宽平稳

+
$$ +R_{X, Y}(t, s) = R_{XY}(t + D, s + D), \forall D \in T +$$
+ +

宽平稳过程的性质

+

设 $R_X(\tau)$ 为宽平稳过程的自相关函数, $m_X$ 为该过程的均值。

+
$$ +\begin{align} + R_X(\tau) = \overline{R_X(-\tau)}\\ + R_X(0)\ge |m_X|^2\\ + |R_X(\tau)| \le R_X(0)\\ + R_X(\tau) \text{是一元非负定函数。} +\end{align} +$$
+ +

正交增量过程

正交增量过程

+

对于二阶矩过程 $X(t), t \in \R$,若 $\forall t_1 \lt t_2 \le t_3 \lt t_4$,$t_1, t_2, t_3, t_4 \in \R$,满足

+
$$ +E(X(t_4) - X(t_3))(\overline{X(t_2) - X(t_1)}) = 0 +$$
+ +

则称 $X(t), t \in \R$ 为正交增量过程。

+

独立增量过程

+

对于二阶矩过程 $X(t), t \in \R$,若 $\forall t_1 \lt t_2 \le t_3 \lt t_4$,$t_1, t_2, t_3, t_4 \in \R$,$X(t_4) - X(t_3)$ 和 $X(t_2) - X(t_1)$ 统计独立,则称为独立增量过程。

+

均值为0的独立增量过程是正交增量过程。

+

平稳增量过程

+

对于随机过程 $X(t), t \in \R$,若 $X(t) - X(s)$ 的分布仅仅依赖于 $t - s$,则称为平稳增量过程。

+

定理:

+

随机过程 $X(t), t \in [0, \infty]$,满足 $X(0) = 0$,则其为正交增量过程的充要条件为

+
$$ +R_X(s, t) = F(\min(s, t)) +$$
+ +

其中,$F(\cdot)$是单调不减的函数。

+

随机过程的极限、连续、导数、积分

均方极限

+
$$ +E(|ka|^2) +$$
+ + + +

唯一性:若 $X_n \xrightarrow{m.s} X, X_n \xrightarrow{m.s}Y$,则 $E(|X - Y|^2) = 0$.

+

可加性:

+

数字特征相同:

+

如何判定 ${X_n}$ 是否收敛?

+

Cauchy 准则

+
$$ +X_n \xrightarrow{m.s}{X} \Leftrightarrow E(|X_m - X_n|^2) = 0, m, n \rightarrow \infty +$$
+ +

洛伊夫准则:

+
$$ +X_n \xrightarrow{m.s} X \lrArr E\lbrace X_n X_m^*\rbrace \rightarrow \text{constant} +$$
+ +

均方连续

+

二阶矩过程,$t \rightarrow t_0, X(t) \xrightarrow{m.s.} X(t_0)$,则称 $X(t)$ 在 $t_0$ 处连续

+

定理

+

以下命题等价:

+
    +
  1. $R(t, s)$ 在 $(t_0, t_0)$ 上连续,$\forall t_0 \in T$
  2. +
  3. $X(t)$ 在 $T$ 上均方连续
  4. +
  5. $R(t, s)$ 在 $T \times T$ 上连续
  6. +
+

推论

+

对于宽平稳过程 $X(t)$,$R(\tau)$ 为自相关函数,以下命题等价:

+
    +
  1. $R(\tau)$ 在 $\tau = 0$ 处连续;
  2. +
  3. $X(t)$ 在 $T$ 上均方连续;
  4. +
  5. $R(\tau)$ 在 T 上连续。
  6. +
+

均方导数

+

若 $\frac{X(t_0 + h) - X(t_0)}{h}\xrightarrow{m.s.}Y(t_0), \forall t_0 \in T, h \rightarrow 0$,则称$\lbrace X(t) \rbrace$ 在均方意义下的导数为 $Y(t)$。

+

如何判断 $X(t)$ 是否均方可导?

+

Cauchy 准则

+
$$ +E\left(|\frac{X(t_0 + h) - X(t_0)}{h} - \frac{X(t_0 + g) - X(t_0)}{g}|^2\right) \rightarrow 0, \forall h, g \rightarrow 0 +$$
+ +

洛伊夫准则

+
$$ +E\left(\left(\frac{X(t_0 + h) - X(t_0)}{h}\right)\left(\frac{X(t_0 + g) - X(t_0)}{g}\right)^*\right) \rightarrow 0, \forall h, g \rightarrow 0 +$$
+ +

均方导数判定定理

+
$$ +\frac{\partial^2 R(t, s)}{\partial t \partial s} 在 (t_0, t_0) 存在且连续,则 X(t) 在 t_0 处存在均方倒数 +$$
+ +

均方导数的性质:

+

$f(t)$ 为线性函数

+
    +
  • $E(X^\prime(t)) = \frac{\mathrm d }{\mathrm dt} E(X(t))$
  • +
  • $E(X^\prime(t)\overline{X(s)}) =\frac{\partial }{\partial t}R_x(t, s)$
  • +
  • $E(X(t)\overline{X^\prime(s)}) =\frac{\partial }{\partial s}R_x(t, s)$
  • +
  • $E(X^\prime(t)\overline{X^\prime(s)}) =\frac{\partial^2 }{\partial t\partial s}R_x(t, s)$
  • +
+

均方积分

+

若黎曼和 $\sum\limits_{k=1}^{n}X(v_k)h(v_k)(t_k - t_{k - 1})$ 在 $n \rightarrow \infty, \max\lbrace t_k - t_{k - 1}\rbrace \rightarrow 0$ 时均方收敛,其中 $h(t)$ 为确定的可积函数,则称$\lbrace X(t)\rbrace$ 为均方可积,记为 $\int_{a}^{b}X(t)h(t)\mathrm dt$。

+

判定定理

+
$$ +\lbrace X(t)h(t) \rbrace 均方可积 \Leftrightarrow \int_{a}^{b}\int_{a}^{b}R_X(t, s)h(t)h^*(s)\mathrm dt\mathrm ds 存在 +$$
+ +

均方积分的性质:

+
    +
  • $E\left( \int_{a}^{b}X(t)h(t)\mathrm dt\right) = \int_{a}^{b}E(X(t))h(t)\mathrm dt$
  • +
  • $E\left( \left(\int_{a}^{b}X(t)h(t)\mathrm dt\right)\left(\int_{a}^{b}X(s)h(s)\mathrm ds\right)^*\right) = \int_{a}^{b}E(X(t))h(t)\mathrm dt$
  • +
  • 三角不等式:$\sqrt{ E \left(|\int_{a}^{b}X(t)h(t)\mathrm dt|^2\right) } \le \int_{a}^{b}\sqrt{E\left(|X(t) - h(t)|^2\right)}\mathrm dt$
  • +
  • 均方积分与均方导数:$X(t)$ 在 $[a, b]$ 上均方连续,$Y(t) = \int_{a}^{t}X(s)\mathrm ds$,其中等号代表均方相等,则 $\lbrace Y(t)\rbrace$ 在 $[a, b]$ 可导,并称在均方意义下 $\lbrace Y(t) \rbrace$ 的导数为 $\lbrace X(t) \rbrace$
  • +
+

随机过程的遍历性

统计平均:对样本空间取平均

+
$$ +E\lbrace X(t_0) \rbrace = \int_{}^{}x\mathrm dF_X(x;t_0) +$$
+ +

时间平均:

+
$$ +\langle X(t) \rangle = \frac{1}{T} \int_{-T/2}^{T/2}X(t)\mathrm dt +$$
+ +

统计平均和时间平均的关系?

+

时间平均更容易获得。如果我们可以通过时间平均来获得统计平均?

+

遍历性

+

定义-宽平稳过程均值遍历:

+
$$ +\langle X(t) \rangle = \lim\limits_{T\rightarrow\infty} \frac{1}{2T} \int_{-T}^{T}X(t)\mathrm dt \mathop{=}\limits^{a.s.} E \lbrace X(t) \rbrace = \mu +$$
+ +

a.s. = with probability 1

+

左边是随机变量,右边是一个确定的数。这样的相等,意味着左边的随机变量的均值确定,方差为0.

+

定义:宽平稳过程自相关遍历

+
$$ +\langle X(t + \tau)X^*(t) \rangle = \lim\limits_{T\rightarrow\infty} \frac{1}{2T} \int_{-T}^{T}X(t + \tau)X^*(t)\mathrm dt \mathop{=}\limits^{a.s.} R_X(\tau) = E \lbrace X(t + \tau)X^*(t)\rbrace +$$
+ +

a.s. = with probability 1

+

定理:

+

宽平稳过程 $X(t)$ 满足均值遍历 $\lrArr$

+
$$ +D(\langle X(t) \rangle) = \lim\limits_{T \rightarrow\infty} \frac{1}{2T}\int_{-2T}^{2T}\left(1 - \frac{|\tau|}{2T}\right)(R_X(\tau) - |\mu|^2)\mathrm d\tau = 0 +$$
+ +

定理:

+

宽平稳过程具有均值遍历性的充要条件是:

+
$$ +\lim\limits_{T\rightarrow\infty} \frac{1}{2T}\int_{-T}^{T}C_X(\tau)\mathrm d\tau = 0 或者 \lim\limits_{T\rightarrow\infty} \frac{1}{T}\int_{0}^{T}C_X(\tau)\mathrm d\tau = 0 +$$
+ +

时间比较长的时候相关性消失了,也就是说过了一段时间同一轨道的样本就独立了,等价于多个轨道的样本,时间平均和统计平均就相等了。

+

2个推论:

+
    +
  • 若实数宽平稳过程的协方差函数满足 $\int_{0}^{+\infty}C_x(\tau)\mathrm d\tau\lt +\infty$,则该过程具有均值遍历性
  • +
  • 若实数宽平稳过程的协方差函数满足 $C_x(\tau) \rightarrow 0, \tau \rightarrow +\infty$,则该过程具有均值遍历性
  • +
+

随机过程的线性展开

卡胡曼-洛伊夫展开

+

在平方可积空间上

+

定义范数

+

定义内积,正交

+

在 $L^2[a, b]$ 中一定有一组标准正交基函数 $\phi_1(t), \phi_2(t), \phi_3(t)\dots$ 满足

+
$$ +\begin{cases} + \langle \phi_i, \phi_j \rangle = 0, i\ne j\\ + \langle \phi_i, \phi_i \rangle = 1 +\end{cases} +$$
+ +
    +
  • $f$ 可以用有限个基函数线性加和来逼近
  • +
  • $\langle f, \phi_n \rangle$ 表示 $f$ 在 $\phi_n$ 基上的坐标。
  • +
+

周期性宽平稳随机过程可以用傅里叶级数展开

+
$$ +E\left(\left |X(t) -\sum\limits_{n=-\infty}^{\infty}c_ne^{j\omega_0t} \right |^2\right) = 0 +$$
+ +

一般的用 KL 展开

+

随机向量的双正交展开:

+

零均值的 $n$ 元随机向量 $\mathbf X \in R^n$ 可以如下展开:

+
$$ +X = \sum\limits_{k=1}^{n} \xi_k \mathbf e_k +$$
+ +

基向量选择的是自相关矩阵 $\mathbf R$ 的特征向量。

+

如果我们用 $\mathbf K$ 个维度来逼近 $\mathbf X$,为了使得误差最小,选取最大的$\mathbf K$个特征值: $\mathbf X =\sum\limits_{k=1}^{K} \alpha_k\mathbf e_k$。这就是主成分分析(PCA)。

+

谱分析

周期函数的傅里叶级数

$$ +x(t) =\sum\limits_{n=-\infty}^{\infty}a_n e^{j\omega_0 t}, \omega_0 = \frac{2\pi}{T}\\ +a_n = \frac{1}{T}\int_{0}^{T}x(t)e^{-jn\omega_0t}\mathrm dt +$$
+ +

帕斯瓦尔定理

+
$$ +\frac{1}{T}\int_{0}^{T}|x(t)|^2\mathrm dt =\sum\limits_{n=-\infty}^{\infty}|a_n|^2 +$$
+ +

自相关函数

+
$$ +R(\tau) = \frac{1}{T}\int_{0}^{T}x(t + \tau)x^*(t)\mathrm dt +$$
+ +

功率谱密度

+
$$ +S(\omega) =\sum\limits_{n=-\infty}^{\infty}|a_n|^2\delta(\omega - n \omega_0) +$$
+ +

从而有

+
$$ +S(\omega) = \int_{-\infty}^{\infty}R(\tau)e^{-j\omega\tau}\mathrm d\tau +$$
+ +

非周期函数的傅里叶变换

知识

$$ +F(\omega) = \int_{-\infty}^{\infty}x(t)\exp(-j\omega t)\mathrm dt\\ +x(t) = \frac{1}{2\pi}\int_{-\infty}^{\infty}F(\omega)\exp(j\omega t)\mathrm d\omega = \int_{-\infty}^{\infty}F(f)\exp(j2\pi ft)\mathrm df +$$
+ +

帕斯瓦尔定理

+
$$ +\int_{-\infty}^{\infty}|x(t)|^2\mathrm dt = \int_{-\infty}^{\infty}|F(f)|^2\mathrm df +$$
+ +
$$ +时域采样 \lrarr 频域周期延拓\\ +时域周期延拓 \lrarr 频域采样\\ +$$
+ +

自相关函数

+
$$ +R(\tau) = \int_{-\infty}^{\infty}x(t + \tau)x^*(t)\mathrm dt +$$
+ +

能量谱密度

+
$$ +S(\omega) = |F(\omega)|^2 = \left |\int_{-\infty}^{\infty}x(t)e^{j\omega t}\mathrm dt \right|^2\\ +$$
+ +

波赫纳尔——辛钦定理

+
$$ +S(\omega) = \int_{-\infty}^{\infty}R(\tau)e^{-j\omega\tau}\mathrm d\tau\\ +R(\tau) = \frac{1}{2\pi}\int_{-\infty}^{\infty}S(\omega)e^{j\omega\tau}\mathrm d\omega, S(\omega)\ge 0 +$$
+ +

实过程的 $S(\omega)$ 为偶函数。

+

离散随机过程的功率谱:

+

只在整数点 k 采样

+
$$ +S(\omega) =\sum\limits_{k=-\infty}^{\infty}R(k)e^{-j\omega k}\\ +R(k) = \frac{1}{2\pi}\int_{-\pi}^{\pi}S(\omega)e^{j\omega k}\mathrm d\omega +$$
+ +

周期过程(自相关函数有周期性)的功率谱

+
$$ +S(\omega) =\sum\limits_{n=-\infty}^{\infty}b_n\delta(\omega - n \Delta \omega)\\ +R(\tau) = \frac{1}{2\pi}\sum\limits_{n=-\infty}^{\infty}b_ne^{jn\Delta\omega\tau} +$$
+ +

例子

白噪声 $E \lbrace X(t) \rbrace = 0$,

+
$$ +S(\omega) = N_0, -\infty \lt \omega \le \infty\\ +R(\tau) = N_0\delta(\tau) +$$
+ +
    +
  • 任意两个不同时刻 $X(t_1), X(t_2)$ 都不相关。
  • +
  • 在各个频率上都有分量,且强度一致。
  • +
+

高斯白噪声:各时刻服从高斯分布的白噪声

+

色噪声: $R(\tau)$ 不是冲击函数。

+
    +
  • 当某过程 $R(\tau)$ 比较胖的时候,功率谱比较瘦
      +
    • 相隔较长时间 $X(t)$ 与 $X(t + \tau)$ 还相关,说明信号变化慢,对应频域低频多
      分量多
    • +
    +
  • +
  • 当某过程 $R(\tau)$ 比较瘦时,功率谱比较胖
  • +
  • 相隔一点时间, $X(t)$ 与 $X(t + \tau)$ 不太相关,说明信号变化快,对应频域高频分量多。
  • +
+

互谱密度

+
$$ +S_{XY}(\omega) = \int_{-\infty}^{\infty}R_{XY}(\tau)e^{-j\omega \tau}\mathrm d\tau +$$
+ +

称为互谱密度,不具有功率的含义。

+
$$ +S_{YX}(\omega) = S_{XY}^*(\omega)\\ +R_{XY}(\tau) = 0, \forall \tau \lrArr S_{XY}(\omega) = 0, \forall \omega +$$
+ +
$$ +Z(t) = X(t) + Y(t)\\ +R_Z(\tau) = E \lbrace (X(t + \tau) + Y(t + \tau))\overline{(X(t) + Y(t))} \rbrace = R_X(\tau) + R_{XY}(\tau) + R_{XY} +$$
+ +

一个宽平稳过程分别通过两个 LTI 系统:

+
$$ +Y_1(t) = X(t) * h_1(t)\\ +Y_2(t) = X(t) * h_2(t)\\ +R_{Y_1Y_2}(\tau) = R_X(\tau) * h_1(\tau) * h_2^*(-\tau)\\ +S_{Y_1Y_2}(\omega) = S_X(\omega)H_1(\omega)H_2^*(\omega)\\ +$$
+ +

两个过程输入两个系统,输出过程的互谱(互相关函数的傅里叶变换)。怎么求?

+

(输入为联合宽平稳)

+
$$ +\hat X(t) = X(t) * f(t)\\ +\hat Y(t) = Y(t) * g(t)\\ +R_{\hat X\hat Y}(\tau) = R_{XY}(\tau) * f(\tau) * g^*(-\tau)\\ +S_{\hat X\hat Y}(\omega) = S_{XY}(\omega)F(\omega)G^*(\omega) +$$
+ + +

宽平稳过程通过线性系统

$$ +Y(t) = \int_{-\infty}^{\infty}h(t - \tau)X(\tau)\mathrm d\tau +$$
+ +

总结:

+
    +
  • 输出过程的均值:易求,因为宽平稳过程的均值为常数
  • +
  • 输出过程的自相关函数:有点麻烦
  • +
+

首先看输出与输入的自相关

+
$$ +R_{YX}(\tau) = \int_{-\infty}^{\infty}h(v)R_x(\tau - v)\mathrm dv\\ +R_Y(\tau) = \int_{-\infty}^{\infty}h^*(-u)R_{YX}(\tau - u)\mathrm du +$$
+ +
$$ +R_Y(\tau) = R_X(\tau) * h(\tau) * h^*(-\tau)\\ +S_Y(\omega) = |H(\omega)|^2S_X(\omega) +$$
+ +

因此,输出的自相关,也可以用功率谱求解。

+

离散时间宽平稳序列

$$ +R_{YX}(k) = h(k) * R_X(k)\\ +R_Y(k) = h^*(-k) * h(k) * R_X(k)\\ +S_Y(z) = H(z) H^*(\frac{1}{z^*})S_X(z)\\ +其中 H(z) =\sum\limits_{}^{}h(k)z^{-k}\\ +令 z = e^{j\omega}\\ +S_Y(\omega) = |H(\omega)|^2S_X(\omega) +$$
+ +

理想白噪声通过低通滤波器:

+
$$ +S_Y(f) = \begin{cases} + k_0, -f_c \le f \le f_c,\\ + 0, \text{otherwise.} +\end{cases}\\ +R_Y(0) = 2f_ck_0\\ +R(\tau) = R_Y(0)\frac{\sin(2\pi f_c\tau)}{2\pi f_c\tau} +$$
+ +

从自相关函数可看出,相隔 $\frac{n}{2f_c}$ 的两个时刻不相关。因此,以 $2f_c$ 为采样频率的噪声采样数据彼此不相关。

+

可以证明宽平稳过程功率谱非负:$S_X(f) \ge 0$:

+
$$ +E \lbrace |Y(t)|^2 \rbrace = R_Y(0) = \int_{-\infty}^{\infty}S_Y(f)\mathrm df = \int_{-\infty}^{\infty}S_X(f)|H(f)|^2\mathrm df \ge 0 +$$
+ +

如果 $S_X(f)$ 在某个地方小于0,可以设计对应的滤波器 $H(f)$将这个小于0的区域滤出来,从而 $\int_{-\infty}^{\infty}S_X(f)|H(f)|^2\mathrm df \le 0$,导致矛盾。

+

线性系统例子:

+

滑动平均

+
$$ +Y(t) = \frac{1}{T}\int_{t-T}^{t}X(s)\mathrm ds +$$
+ +

转化为滤波器:

+
$$ +R_Y(t) = R_X(t) * h(t) * h^*(-t)\\ +h(t) = \begin{cases} + \frac{1}{T}, 0 \le t \le T,\\ + 0, \text{otherwise.} +\end{cases} +$$
+ +

+
$$ +g(t) = h(t) * h^*(t) = \begin{cases} + \frac{1}{T}\left ( 1 - \frac{|t|}{T} \right), t \in [-T, T],\\ + 0,\text{otherwise.} +\end{cases} +$$
+ +

理想的矩形窗

+
$$ +R_Y(t) = \int_{-\infty}^{\infty}g(t - \tau)R_X(\tau)\mathrm d\tau = \int_{-T}^{T}\frac{1}{T}\left ( 1 - \frac{|t - \tau|}{T} \right)R_X(\tau)\mathrm d\tau +$$
+ +

从频域看

+
$$ +H(\omega) = \text{sinc} \left ( \frac{\omega T}{2} \right)e^{-j\omega \frac{T}{2}}\\ +S_Y(\omega) = S_X(\omega)\left |\text{sinc} \left ( \frac{\omega T}{2} \right) \right|^2 +$$
+ +

是一个低通滤波器。

+

例子2:MTI 滤波

+

静止目标反射信号相同,运动目标反射回波不同。因此设计滤波器消去静止目标。称为“对消”。

+
$$ +Y(t) = X(t) - X(t - T) +$$
+ +

在频域看:

+
$$ +H(\omega) = 1 - e^{j\omega T} +$$
+ +

静止目标,多普勒频率为0,因此频域响应为0;运动目标,多普勒频率不为0,频域响应不为0。因此这是一个高通滤波器。

+

还可以多次对消:

+
$$ +Y_1(t) = X(t) - X(t - T)\\ +Y_2(t) = Y_1(t) - Y_1(t - T)\\ +Y_3(t) = Y_2(t) - Y_2(t - T)\\ +\vdots\\ +Y_n(t) = Y_{n - 1}(t) - Y_{n - 1}(t - T) +$$
+ +

频率响应:

+
$$ +H(\omega) = (1 - e^{-j\omega T})^n +$$
+ +

采样定理

随机过程下的采样定理

+

$|f| \le f_0$, 当 $f_s \le 2f_0$ 时,均方意义下有

+
$$ +X(t) =\sum\limits_{k=-\infty}^{\infty}X(kT) \text{sinc} \left ( \frac{\pi}{T}(t - kT) \right) +$$
+ +

证明:

+
$$ +\begin{align*} + &要证明 N \rightarrow \infty 时,\\ + &\varepsilon_N = E \left \lbrace \left | X(t) -\sum\limits_{k=-N}^{N}X(kT)\text{sinc} \left ( \frac{\pi}{T}(t - kT) \right) \right|^2 \right \rbrace \rightarrow 0\\ + &利用E \lbrace X(a) X^*(b) \rbrace = R_X(a - b) = \frac{1}{2\pi}\int_{-\infty}^{\infty}e^{j\omega a}e^{-j\omega b}S_X(\omega)\mathrm d\omega,展开上式\\ + &\varepsilon_N = \frac{1}{2\pi}\int_{-\infty}^{\infty}\left | e^{j\omega t} -\sum\limits_{k=-N}^{N}e^{j\omega kT}\text{sinc} \left ( \frac{\pi}{T}(t - kT) \right) \right|^2 S_X(\omega)\mathrm d\omega\\ + &= \frac{1}{2\pi}\int_{-\omega_s/2}^{\omega_s/2}\left | e^{j\omega t} -\sum\limits_{k=-N}^{N}e^{j\omega kT}\text{sinc} \left ( \frac{\pi}{T}(t - kT) \right) \right|^2 S_X(\omega)\mathrm d\omega\\ + &对 e^{j\omega t}做周期延拓,周期为 \omega_s,可以做频域傅里叶级数展开\\ + &e^{j\omega t} = \sum\limits_{k=-\infty}^{\infty}\alpha_k e^{j\omega \frac{2\pi}{\omega_s}} = \sum\limits_{k=-\infty}^{\infty}\alpha_k e^{j\omega kT}\\ + &\alpha_k = \frac{1}{\omega_s}\int_{-\omega_s/2}^{\omega_s/2}e^{j\omega t}e^{-j\omega kT}\mathrm d\omega = \frac{\sin(\frac{\omega}{2}(t - kT))}{\frac{\omega}{2}(t - kT)}\\ + &从而\left | e^{j\omega t} -\sum\limits_{k=-N}^{N}e^{j\omega kT}\text{sinc} \left ( \frac{\pi}{T}(t - kT) \right) \right|^2 = \left | e^{j\omega t} -\sum\limits_{k=-N}^{N}\alpha_k e^{j\omega kT}\right|^2 \rightarrow 0, N \rightarrow \infty +\end{align*} +$$
+ +
    +
  • 采样定理两边是均方相等。
  • +
  • 当满足采样定理时,离散点包含全部信息,任意取值点可以恢复。
  • +
  • 频带边界点
      +
    • 当功率谱在 $\pm \omega_0$ 处有 $\delta$ 函数时,以 $f_s = 2f_0$ 无法恢复信号。
    • +
    • 例如:$X(t) = \cos(\omega_0 t + \phi)$,$\phi$ 为随机相位,在$[0, 2\pi]$内均匀分布。
    • +
    • $R(\tau) = \frac{1}{2}\cos(\omega_0\tau)$
    • +
    • $S(\omega) = \delta(\omega - \omega_0) + \delta(\omega + \omega_0)$
    • +
    • 采样点 $X(kT) = (-1)^kX(0)$,与 $X(0)$ 严重相关。
    • +
    +
  • +
+

欠采样

+
$$ +\begin{align*} + E \lbrace |\varepsilon(t)|^2 \rbrace =& \int_{\omega_s/2}^{-\omega_s/2}\sum\limits_{n=-\infty}^{\infty}|1 - e^{jn\omega t}|S(\omega + n\omega_s)\mathrm d\omega\\ + =&\sum\limits_{n=-\infty}^{\infty}4\sin^2(\omega_snt/2) \cdot \int_{\omega_s/2}^{-\omega_s/2}S(\omega + n\omega_s)\mathrm d\omega\\ +\end{align*}\\ + +

上面的级数为积分的加权求和。 n = 0 时权重为0,对应[-\omega_s/2, \omega_s/2] 内的功率谱。\
n\ne 0 时,权不为0,对应[-\omega_s/2, \omega_s/2]外的频谱,如果在这个区间外功率谱不是0,那 |\varepsilon|^2 将大于0。

+

$$

+

带通采样

$$ +X(\omega) = 0, |\omega - \omega_c| > \omega_0, |\omega + \omega_c| > \omega_0 +$$
+ +

一般研究实信号 $g(t)$,频谱具有共轭对称性,只需要考虑正半轴的频带就可以了:

+
$$ +G(-\omega) = G^*(\omega)\\ +A(\omega) = A(-\omega), \varphi(-\omega) = -\varphi(\omega) +$$
+ +

希尔伯特变换:

+
$$ +H(\omega) = \begin{cases} + -j, \omega \gt 0,\\ + 0, \omega = 0,\\ + j, \omega \lt 0. +\end{cases} +$$
+ +
$$ +\lbrace G(\omega)H(\omega) \rbrace^* = G(-\omega)H(-\omega) +$$
+ +

希尔伯特把正频率移相 $-90\degree$,负频率移相 $+90\degree$

+

时域表示:

+

滤波器的时域响应为

+
$$ +\hat h(t) = \frac{1}{\pi t} +$$
+ +

g(t) 做两次希尔伯特变换,相位转了 $180\degree$:

+
$$ +g(t)\xrightarrow{H(\omega)}\hat g(t) \xrightarrow{H(\omega)} -g(t) +$$
+ +

正交性:

+
$$ +\int_{-\infty}^{\infty}g(t)\hat g(t)\mathrm dt = 0 +$$
+ +

看成$\hat g(t)$ 与 $g(-t)$ 的卷积:

+
$$ +\int_{-\infty}^{\infty}g(t)\hat g(t)\mathrm dt = \int_{-\infty}^{\infty}g(- (u - t))\hat g(t)\mathrm dt|_{u = 0} = g(-t) * \hat g(t) |_{t = 0}\\ +g(-t) \rightarrow G^*(\omega) = G(-\omega), \hat g(t) \rightarrow G(\omega)H(\omega)\\ +g(-t) * \hat g(t)|_{t = 0} = \int_{-\infty}^{\infty}G^*(\omega)G(\omega)H(\omega)e^{j\omega t}\mathrm d\omega|_{t = 0} = 0 +$$
+ +

希尔伯特变换与原信号相加得到单边的频谱:

+
$$ +g(t) \rightarrow A^* + A\\ +j\hat g(t) \rightarrow \\ +g(t) + j\hat g(t) \rightarrow 2A\\ +$$
+ +

下变频:

+
$$ +\tilde{g}(t) = \lbrace g(t) + j\hat g(t) \rbrace e^{-j\omega_c t} = g_I(t) + jg_Q(t)\\ +g_I(t) = g(t) \cos \omega_c t + \hat g(t) \sin (\omega_c t)\\ +g_Q(t) = - g(t) \sin \omega_c t + \hat g(t) \cos (\omega_c t)\\ +$$
+ +

实际上是一个旋转矩阵,把单边频信号 $\tilde g(t)$ 顺时针旋转了 $\omega_ct$变成了基带复信号。

+

与原信号频谱的关系:

+
$$ +g_I(t) \rightarrow G(f - f_c) + G(f + f_c) \\ +g_Q(t) \rightarrow G(f - f_c)(+j) + G(f + f_c)(-j)\\ +(f \le |f_0|) +$$
+ +

调制和解调的流程

+
    +
  • 调制:不需要得到 $\hat g(t)$
  • +
  • 解调:通过低通滤波代替$\hat g(t)$
  • +
+

随机过程的希尔伯特变换

+

$X(t)$为实的带通随机过程

+
$$ +R_X(-\tau) = E\left \lbrace X(t - \tau)X^*(t) \right \rbrace = E\left \lbrace X(t)X^*(t + \tau) \right \rbrace = E\left \lbrace X(t + \tau)X(t) \right \rbrace = R_X(\tau)\\ +S_X(-\omega) = \int_{-\infty}^{\infty}R_X(\tau)e^{-j(-\omega) \tau}\mathrm d\tau = \int_{-\infty}^{\infty}R_X(-u)e^{-j\omega\tau}\mathrm du = \int_{-\infty}^{\infty}R_X(u)e^{-j\omega\tau}\mathrm du = S_X(\omega) +$$
+ +

通过希尔伯特滤波器后:

+
$$ +\hat X(t) = X(t) * h(t)\\ +R_{\hat X}(\tau) = R_X(\tau) * h(t) * h^*(-t) = R_X(\tau)\\ +S_{\hat X}(\omega) = S_X(\omega)|H(\omega)|^2 = S_X(\omega) +$$
+ +

互相关:

+
$$ +\hat R_X(\tau) = R_{\hat XX}(\tau) = E \left \lbrace \int_{-\infty}^{\infty}X(t + \tau - u)\frac{1}{\pi u}\mathrm duX(t) \right\rbrace = \int_{-\infty}^{\infty}R_X(\tau)\frac{1}{\pi u}\mathrm du +$$
+ +
$$ +R_{X\hat X}(\tau) = -\hat R_X(\tau) +$$
+ +

因此

+
$$ +Y = X + j\hat X\\ +R_Y(\tau) = R_X(\tau) + R_{\hat X}(\tau) + jR_{\hat XX}(\tau) - jR_{X\hat X}(\tau) = 2R_X(\tau) + 2j\hat R_X(\tau)\\ +S_Y(f) = \begin{cases} + 4S_X(f), &f \gt 0\\ + 0, &f\lt 0 +\end{cases} +$$
+ +

实的带通随机过程配合虚部的希尔伯特变换,同样也是只有正频率

+

反之,如果功率谱只有正频率有值,则实部和虚部互为希尔伯特变换,实部和虚部的信息是重复的。

+

随机信号的下变频:

+
$$ +\tilde{X}(t) = \lbrace X(t) + j\hat X(t) \rbrace e^{-j\omega_c t} = X_I(t) + jX_Q(t)\\ +X_I(t) = X(t) \cos \omega_c t + \hat X(t) \sin (\omega_c t)\\ +X_Q(t) = - X(t) \sin \omega_c t + \hat X(t) \cos (\omega_c t)\\ +$$
+ +

同样是顺时针旋转了 $2\pi f_c t$ 之后得到了基带信号

+

研究基带信号的实部、虚部的统计特性

+

$\tilde{X}(t)$ 还是一个平稳过程

+
$$ +E \lbrace \tilde{X}(t) \rbrace = E \lbrace X_I(t) \rbrace = E \lbrace X_Q(t) \rbrace = 0\\ +R_{X_I}(\tau) = R_X(\tau)\cos(2\pi f_c\tau) + \hat R_X(\tau)\sin(2\pi f_c\tau)\\ +R_{X_Q}(\tau) = R_X(\tau)\cos(2\pi f_c\tau) + \hat R_X(\tau)\sin(2\pi f_c\tau)\\ +R_{X_I}(\tau) = R_{X_Q}(\tau)\\ +R_{X_Q}(0) = R_{X_I}(0) = R_{X}(0)(三者方差一样)\\ +\hat R_X(0) = 0(奇函数,不具备自相关函数的性质)\\ +S_{X_I}(f) = S_{X_Q}(f) = \begin{cases} + S_X(f - f_c) + S_X(f + f_c), &|f| \le f_0,\\ + 0, &\text{otherwise.} +\end{cases} +$$
+ +

基带信号虚部和实部的互相关

+
$$ +R_{X_IX_Q}(\tau) = R_X(\tau)\sin(2\pi f_c\tau) - \hat R_X(\tau)\cos (2\pi f_c\tau),奇函数 +$$
+ +
$$ +R_{X_IX_Q}(0) = 0 +$$
+ +

因此同一时刻实部和虚部不相关。

+

互谱密度

+
$$ +S_{X_IX_Q}(f) = \begin{cases} + jS_X(f + f_c) - jS_X(f - f_c), &|f| \lt f_0,\\ + 0, &\text{otherwise.} +\end{cases} +$$
+ +

只有当正频谱和负频谱分别跟 $f = \pm f_c$ 对称时,互谱密度恒为0。此时,任意两个时间的虚部和实部信号都是不相关的。

+

高斯过程

定义

随机向量$X = (X(t_1), \dots, X(t_n))^T$ 服从 $n$ 元高斯分布,称为高斯过程。

+

均值 $\mu_k$ = $E \lbrace X_k \rbrace$

+

协方差阵

+
$$ +\Sigma = E \lbrace (X - \mu)(X - \mu)^T \rbrace = \begin{bmatrix} + b_{11}& \dots &b_{1n}\\ + \vdots& \ddots & \vdots\\ + b_{n1} & \dots & b_{nn} +\end{bmatrix}\\ +b_{ij} = E \lbrace (X_i - \mu_i)(X_j - \mu_j)^T \rbrace\\ +b_{ij} = b_{ji}^* = b_{ji} +$$
+ +

做特征分解

+
$$ +\Sigma v_i = \lambda_i v_i\\ +Q = (v_1, v_2, \dots, v_n)正交阵, Q^{-1} = Q^T\\ +\Sigma = Q\text{diag}(\lambda_1, \dots, \lambda_n)Q^T\\ +\Sigma^{-1} = Q^T\text{diag}(\lambda_1^{-1}, \dots, \lambda_n^{-1})Q +$$
+ +

多元高斯分布

$$ +f(x) = K \cdot \exp \left \lbrace -\frac{1}{2}(x - \mu)\Sigma^{-1}(x - \mu)^T \right \rbrace +$$
+ +

线性变换以消去下标$ij$项:

+
$$ +\Sigma^{-1} = A^TA\\ +y = A(x - \mu)\\ +(x - \mu)\Sigma^{-1}(x - \mu)^T = y^Ty +$$
+ +
$$ +1 = K \int \dots \int \exp \left \lbrace -\frac{1}{2}(x - \mu)\Sigma^{-1}(x - \mu)^T \right \rbrace \mathrm dx_1 \dots \mathrm dx_n\\ +K = \frac{1}{(\sqrt{2\pi})^n\cdot \sqrt{|\Sigma|}} +$$
+ +

多元高斯矢量的特征函数

+
$$ +\omega = (\omega_1, \omega_2,\dots, \omega_n)^T\\ +\Phi_X(\omega) = E \lbrace e^{j\omega^TX} \rbrace = E \lbrace e^{j(\omega_1 X_1 + \omega_2 X_2 + \dots + \omega_n X_n)} \rbrace = \exp \left \lbrace j\omega^T\mu - \frac{1}{2}\omega^T\Sigma\omega \right \rbrace +$$
+ +

特征函数不要求 $\Sigma$ 可逆。概率密度函数要求 $\Sigma$ 正定,特征值都大于0.

+

当 $X$ 为高斯矢量时

+
$$ +\Phi_X(\omega) = \int_{}^{}\int_{}^{}\dots\int_{}^{} K \cdot \exp \left \lbrace -\frac{1}{2}(x - \mu)^T\Sigma^{-1}(x - \mu) \right \rbrace\mathrm dx_1\mathrm dx_2\dots\mathrm dx_n = \int_{}^{}\int_{}^{}\dots\int_{}^{} K \cdot \exp \left \lbrace -\frac{y^Ty}{2} \right \rbrace \sqrt{|\Sigma|} +$$
+ +

高斯白噪声的协方差矩阵只有对角元,对角元为方差。

+

可以用逼近处理 $|\Sigma| = 0$:

+
$$ +\Sigma_K = \Sigma + \frac{1}{K}I\\ +\Phi_X(\omega) = \exp \left \lbrace j\omega^T\mu - \frac{1}{2}\omega^T \left (\Sigma + \frac{1}{K}I \right)\omega \right \rbrace\\ +f(x) = \frac{1}{\sqrt{2\pi}^n \sqrt{|\Sigma_K|}} \cdot \exp \left \lbrace -\frac{1}{2}(x - \mu)\Sigma^{-1}(x - \mu)^T \right \rbrace +$$
+ +

然后再讨论 $K \rightarrow \infty$ 的情况。

+

多元高斯矢量的边缘分布

+

任取子矢量 $\lbrace K_1, K_2, \dots, K_m \rbrace \subseteq {1, 2, \dots, n}$

+

观察 $\tilde{ X} = (X_{K_1}, X_{K_2}, \dots, X_{K_m})^T$ 的分布

+
$$ +\tilde{\Phi}(\tilde\omega) = E \lbrace e^{j(\omega_{K_1}\tilde X_{K_1} + \omega_{K_2}\tilde X_{K_2} + \dots + \omega_{K_m}\tilde X_{K_m})} \rbrace = \exp \left \lbrace j\tilde\omega^T\mu - \frac{1}{2}\tilde\omega^T\Sigma\tilde\omega \right \rbrace +$$
+ +

用置换矩阵 $P$ 将 $\Sigma$ 的第 $K_1, K_2, \dots, K_m$ 行、列移到 $\Sigma$ 的左上角,对应的 $\omega$ 也置换:

+
$$ +P\omega = \begin{pmatrix} + \tilde{\omega}\\ + 0 +\end{pmatrix}\\ +P^T\Sigma P^T = \begin{pmatrix} + \tilde{\Sigma} & B\\ + C & D +\end{pmatrix} +$$
+ +

置换到左上角后,容易看出子矢量的特征函数可以通过将原矢量其他的$\omega$置零得到,均值就是选择对应的均值,协方差矩阵就是把对应的行列元素抽出来:

+
$$ +\omega^T\Sigma\omega = (\tilde{\omega}, 0)^T\begin{pmatrix} + \tilde{\Sigma} & B\\ + C & D +\end{pmatrix}\begin{pmatrix} + \tilde{\omega}\\ + 0 +\end{pmatrix} = \tilde{\omega}^T\tilde{\Sigma}\tilde{\omega} +$$
+ +

利用特征函数求数字特征:

+
$$ +\frac{\partial^2\Phi}{\partial \omega_k\partial \omega_l}|_{\omega_k = \omega_l = 0} = -(\mu_l\mu_k + b_{kl})\\ +E \lbrace X_kX_l \rbrace = \mu_l\mu_k + b_{kl} +$$
+ +
$$ +E \lbrace X_1^{k_1}\dots X_n^{k_n} \rbrace = j^{\sum\limits_{i=1}^{n}k_i} \frac{\partial^{k_1 + k_2 + \dots k_n}}{\partial^{k_1}\omega_1\partial^{k_2}\omega_2\dots \partial^{k_n}\omega_n}\bigg|_{\omega_1 = \omega_2 = \dots = \omega_n = 0} +$$
+ +

高斯的矢量分布的高阶矩完全由一阶矩 $\mu$ 和二阶矩 $\Sigma$ 决定。例如可以用特征函数推出:

+
$$ +\begin{align*} + &E \left \lbrace X_1X_2X_3X_4 \right \rbrace \\ + =& j^4 \frac{\partial^4\Phi}{\partial \omega_1\partial \omega_2\partial \omega_3\partial \omega_4}\bigg|_{\omega_1 = \omega_2 = \omega_3 = \omega_4 = 0} \\ + =& E \left \lbrace X_1X_2 \right \rbrace E \left \lbrace X_3X_4 \right \rbrace + E \left \lbrace X_1X_3 \right \rbrace E \left \lbrace X_2X_4 \right \rbrace + E \left \lbrace X_1X_4 \right \rbrace E \left \lbrace X_2X_3 \right \rbrace +\end{align*} +$$
+ +

独立性

+

独立性说的是统计,不相关说的是线性(二阶矩)

+

一般来说

+
$$ +独立 \Rightarrow 不相关\\ +不相关 \not \Rightarrow 独立 +$$
+ +

但是,对于高斯分布而言:

+
$$ +独立 \lrArr 不相关 +$$
+ +

这是因为高斯分布完全由一阶和二阶矩决定。

+

定理:

+

$n$ 元向量 $X = \binom{X_1}{X_2}$ 服从 $N(\mu, \Sigma)$,则 $X_1, X_2$ 独立 $\lrArr$ $\Sigma_{12} = 0$

+
$$ +\Sigma = \begin{pmatrix} + \Sigma_{11}&\Sigma_{12}\\ + \Sigma_{21}&\Sigma_{22} +\end{pmatrix} +$$
+ +

充分性:

+
$$ +\Sigma_{12} = E \left \lbrace (X_1 - \mu_1)^T(X_2 - \mu_2) \right \rbrace = E \left \lbrace (X_1 - \mu_1)\right\rbrace E\left \lbrace(X_2 - \mu_2) \right \rbrace = 0 +$$
+ +

必要性:

+
$$ +f(x_1, x_2) = \frac{1}{(2\pi)^{n/2}\sqrt{|\Sigma|}}\exp \left \lbrace -\frac{1}{2}\begin{pmatrix} + x_1 - \mu_1\\ + x_2 - \mu_2 +\end{pmatrix}^T\begin{pmatrix} + \Sigma_{11}&0\\ + 0&\Sigma_{22} +\end{pmatrix} \begin{pmatrix} + x_1 - \mu_1\\ + x_2 - \mu_2 +\end{pmatrix} \right \rbrace = f(x_1)f(x_2) +$$
+ +

可见 $X_1, X_2$ 统计独立。

+

对于高斯过程:

+
$$ +严平稳 \lrArr 宽平稳 +$$
+ +

即 $X(t_1), X(t_2), \dots, X(t_n)$ 和 $X(t_1 + \tau), X(t_2 + \tau), \dots, X(t_n + \tau)$ 有相同的 $\mu, \Sigma$ 等价于具有相同的分布函数。

+

线性变换

+

定理: $X$ 服从高斯分布,矩阵 $C_{m\times n}$, $Y = CX$,则 $Y$ 服从高斯分布 $N \left(C\mu, C \Sigma C^T \right)$。

+

高斯过程经过微分,积分,滤波等线性操作,输出还是高斯过程。

+

有一种重要的线性变换:去相关。

+
$$ +\Sigma_X = \begin{pmatrix} + \Sigma_{11}&\Sigma_{12}\\ + \Sigma_{21}&\Sigma_{22} +\end{pmatrix}\\ +Y = \begin{pmatrix} + Y_1\\Y_2 +\end{pmatrix}= \begin{pmatrix} + I & A\\ + 0 & I +\end{pmatrix}\begin{pmatrix} + X_1\\X_2 +\end{pmatrix}\\ +E \left \lbrace (Y_1 - E(Y_1))(Y_2 - E(Y_2))^T \right \rbrace = \Sigma_{12} + A\Sigma_{22 } = 0 +$$
+ +

需要

+
$$ +-\Sigma_{12}\Sigma_{22}^{-1} = A\\ +$$
+ +

计算协方差

+
$$ +E \left \lbrace (Y - E(Y))(Y - E(Y))^T \right \rbrace = \begin{pmatrix} + \Sigma_{11} - \Sigma_{12}\Sigma_{22}^{-1}\Sigma_{21}&0\\ + 0&\Sigma_{22} +\end{pmatrix} +$$
+ +

去相关之后方差减小了。可以认为 $X_1 = Y_1 - AX_2$ 中,$- AX_2$是与 $Y$ “独立” 的“噪声项”,这个噪声导致了 $X_1$ 的方差大于去相关之后的 $Y$ 的方差。

+

去相关与是否是高斯矢量无关。但是对于高斯矢量,去相关之后,两个矢量就独立了,具有重要的意义。

+

对于一般的二阶矩过程,希望找到一个矩阵 $U$ ,使得 $Y = UX$ 的各个分量不相关:

+
$$ +E \left \lbrace (Y - \mu_Y)(Y - \mu_Y)^T \right \rbrace = \text{diag}\\ +E \left \lbrace U(X - \mu_X)(X - \mu_X)^TU^T \right \rbrace = \text{diag} = U\Sigma U^T +$$
+ +

所以,本质上就是分析了协方差矩阵 $\Sigma$ 的特征值。也就是二阶矩章节讲到的主成分分析:

+
$$ +\text{diag}(\lambda_1, \dots, \lambda_n) +$$
+ +

选取 $\lambda_i$ 大的特征矢量,张成主成分空间。

+

信号处理中有信号空间(特征值大的)和噪声空间(特征值小的,被噪声掩盖了)。

+

有时候 $Y$ 的各个分量不相关还不能完全消去元素之间的统计关系。只是线性不相关。不相关的约束实际上很弱。

+

如果要设计 $U$,使得 $Y = UX$ 的各个分量独立,运算很复杂。

+

但是,对于高斯矢量而言,不相关就是独立。所以对于高斯过程,主成分分析 $\lrArr$ 独立成分分析。

+

高斯变量的条件分布

仍是高斯:

+
$$ +f_{X_1|X_2}(x_1|x_2) = \frac{1}{\sqrt{\tilde{\Sigma}_{11}}(2\pi)^{\frac{n_1}{2}}}\exp \left \lbrace -\frac{1}{2}(x_1 - \tilde{\mu}_1)^T\tilde{\Sigma}_{11}^{-1}(x_1 - \tilde{\mu}_1) \right\rbrace\\ +E \lbrace X_1 | X_2 \rbrace = \mu_1 + \Sigma_{12}\Sigma_{22}^{-1}(X_2 - \mu_2)\\ +E \lbrace (X_1 - E(X_1 | X_2))(X_1 - E(X_1|X_2))^T|X_2 \rbrace = \Sigma_{11} - \Sigma_{12}\Sigma_{22}^{-1}\Sigma_{21} +$$
+ +

实高斯过程的若干性质

实高斯过程完全由均值函数和协方差函数确定。

+

严平稳等价于宽平稳。

+

若实高斯过程均方可导,则 $\lbrace X^\prime(t) \rbrace$ 也是高斯过程。

+

高斯过程通过一般线性系统仍然是高斯过程。

+
$$ +Y(t) = \int_{a}^{b}X(\tau)h(t, \tau)\mathrm d\tau\\ +更强的结论:\left \lbrace \binom{X(t)}{Y(t)} \right \rbrace 是高斯过程。 +$$
+ +

零均值带通高斯过程

$$ +Z(t) = X(t) + j \hat X(t)\\ +X_B(t) = X_I(t) + j X_Q(t)\\ +V(t) = \sqrt{X_I^2(t) + X_Q^2(t)}\\ +\Theta(t) = \arctan \frac{X_Q(t)}{X_I(t)}\\ +$$
+ +

此时有

+
$$ +X(t) = V(t)\cos(\omega_ct + \Theta(t))\\ +\binom{X_I(t)}{X_Q(t)} = \binom{\ \ \ \cos(\omega_ct)\quad \sin(\omega_c t)}{-\sin(\omega_ct)\quad \cos(\omega_ct)}\binom{X(t)}{\hat X(t)} +$$
+ +

幅度为瑞利分布,相位为均匀分布,相互统计独立:

+
$$ +f_V(v) = \frac{v}{\sigma^2}e^{-\frac{v^2}{2\sigma^2}}, v \ge 0\\ +f_\Theta(\theta) = \frac{1}{2\pi}, \theta \in [0, 2\pi] +$$
+ +

随机相位正弦波信号叠加零均值带通高斯

$$ +Y(t) = A\sin(\omega_ct + \Phi) + X(t) +$$
+ +

结果是幅度为莱斯分布,相位均匀分布,二者统计独立:

+
$$ +f_{V(t)}(v) = \frac{v}{\sigma^2}\exp(-\frac{v^2 + A^2}{2\sigma^2})I_0(\frac{Av}{\sigma^2})\\ +f_\Theta(\theta) = \frac{1}{2\pi} +$$
+ +

高斯过程经过非线性函数

限幅器

+
$$ +h(x) = \begin{cases} + 1, x\ge 0,\\ + 0, x \lt 0 +\end{cases} +$$
+ +

服从两点分布

+
$$ +P(Y(t) = 1) = P(Y(t) = 0) = \frac{1}{2}\\ +E_Y(t) = 0\\ +R_Y(t, s) = P \lbrace X(t)X(s) \ge 0 \rbrace - P \lbrace X(t)X(s) \lt 0 \rbrace +$$
+ +
$$ +P \lbrace X(t)X(s) \ge 0 \rbrace = \int_{0}^{\infty}\int_{0}^{\infty}\frac{1}{2\pi\sqrt{|\Sigma|^{-1}}}\exp((x_1\ x_2)\Sigma^{-1}\binom{x_1}{x_2})\mathrm dx_2\mathrm dx_1 = \frac{\pi/2 + \sin^{-1}(-\rho)}{2\pi} +$$
+ +

全线性检波(求绝对值)

+
$$ +E(Y) = \frac{2\sigma}{2\pi}\int_{0}^{\infty}\frac{y}{\sigma^2}\exp(-\frac{y^2}{2\sigma^2})\mathrm dy = \sqrt{\frac{2}{\pi}}\sigma\\ +R_Y(t, s) E \lbrace |X(t)||X(s)| \rbrace = \frac{2\sigma^2}{\pi} \lbrace \sqrt{1 - \rho^2} + \rho\sin^{-1}\rho \rbrace, \rho = \frac{R_X(t - s)}{\sigma^2}\\ +\int_{0}^{\infty}\int_{0}^{\infty}x_1x_2\frac{1}{2\pi\sigma^2\sqrt{1 - \rho^2}}\exp(-\frac{x_1^2 - 2\rho x_1x_2 + x_2^2}{2\sigma(1 - \rho^2)})\mathrm dx_1\mathrm dx_2 +$$
+ +

半波线性检波

+
$$ +h(x) = \begin{cases} + x, x\ge 0,\\ + 0, x\lt 0 +\end{cases} +$$
+ +
$$ +R_Y(t, s) = \frac{\sigma^2}{\pi} \lbrace \sqrt{1 - \rho^2} + \rho\sin^{-1}\rho \rbrace\\ +$$
+ +

平方率检波

+
$$ +h(x) = x^2 +$$
+ +
$$ +P(Y(t) \le y) = P(-\sqrt{y} \le Y(t) \le \sqrt{y}) = 2\Phi(\frac{\sqrt{y}}{\sigma}) - 1\\ +f_Y(y) = \frac{1}{\sqrt{2\pi}\sigma}\frac{1}{\sqrt{y}}\exp \lbrace -\frac{y}{2\sigma^2} \rbrace,\ (y \gt 0)\\ +E \lbrace Y(t) \rbrace = \sigma^2\\ +R_Y(t,s) = E \lbrace X^2(t_1)X^2(t_2) \rbrace = \sigma^2 + \sigma^2 + \rho\sigma^2 + \rho\sigma^2 = 2(\rho + 1)\sigma^2 +$$
+ +

基带信号的包络经过平方律检波

+
$$ +X_I^2 + X_Q^2 = V^2 服从复指数分布 +$$
+ +

高斯——马尔可夫性

马尔可夫特性:

+
$$ +f(x_n|x_1, \dots, x_{n - 1}) = f(x_n|x_{n - 1}) +$$
+ +

如果一个过程既是高斯的,又是马尔可夫的,会有很好的性质。

+

对于零均值高斯分布:

+
$$ +X(t) 是 \text{Markov} \lrArr R(t_1, t_3) = \frac{R(t_1, t_2)R(t_2, t_3)}{R(t_2, t_2)} +$$
+ +

正向很好证明,反向证明的关键是计算均值和方差。

+
$$ +X(t) 是 \text{Markov} \lrArr \forall t_1\le t_2\le...\le t_n, E \lbrace X_n|X_1, X_2, \dots, X_{n - 1} \rbrace = E \lbrace X_n|X_{n - 1} \rbrace +$$
+ +

从右到左:条件协方差 $E\lbrace (Y_1 - E \lbrace Y_1|Y_2 \rbrace)^2|Y_2\rbrace = \Sigma_{11} - \Sigma_{12}\Sigma_{22}^{-1}\Sigma_{21}$ 跟 $Y_2$ 无关(这并不是说条件协方差和协方差具有相同的意义,只是数值上正好相等)

+
$$ +E(X_n|X_{n - 1}) = \frac{E(X_nX_{n - 1})}{E(X_{n - 1}^2)}X_{n - 1}\\ +$$
+ +

残差与已有信息正交:

+
$$ +E \lbrace [X_n - E(X_n | X_{n - 1})] \cdot X_k \rbrace = 0, k = 1, 2, \dots, n - 1\\ +$$
+ +

类似于最小二乘估计:

+
$$ +X_n - \alpha_n X_{n - 1} 是一个高斯过程,与 X_1, X_2, \dots, X_n 独立 +$$
+ +

自回归方程:

+
$$ +X_n = \alpha_n X_{n - 1} + \beta_nY_n\\ +Y_n \sim N(0, 1) +$$
+ +

Brown 运动

从一维随机游走开始:

+
$$ +P \lbrace X_i = a \rbrace = P \lbrace X_i = -a \rbrace = \frac{1}{2}\\ +Y =\sum\limits_{i=1}^{\infty}X_i +$$
+ +

令 $t = nT$,固定 $t$,令 $n \rightarrow \infty$,由 CLT 可知成为一个高斯分布:

+
$$ +E(Y) = 0\\ +D(Y) = \frac{t}{T}a^2\\ +\frac{a^2}{T} = \beta\\ +f_Y(y) = \frac{1}{\sqrt{2\pi}\sqrt{\beta t}}\exp (-\frac{y^2}{2\beta t}) +$$
+ +

随着时间增加,不确定性越来越大。

+

标准布朗运动:

+

(1)$B(t)$ 满足独立增量,平稳增量
(2)$B(t)$ 的每个样本轨道都是连续的
(3)$\forall t, B(t)$ 遵循高斯分布,均值0,方差 $t$

+
$$ +f_t(x) = \frac{1}{\sqrt{2\pi t}}\exp (-\frac{x^2}{2t}) +$$
+ +

布朗运动是高斯白噪声的积分:

+
$$ +Y(t) = \int_{0}^{t}X(u)\mathrm du +$$
+ +

可见布朗运动的不规则。

+

Markov 过程

Markov 链

一种状态离散、时间离散的随机过程。

+

Markov 特性

马尔可夫特性的一种表示:

+

在已知现在的条件下,过去与将来独立。

+
$$ +P(C,A | B) = P(C | B, A) \cdot P(A|B) = P(C|B)P(A|B) +$$
+ +

其他表示:过去用集合事件表示

+
$$ +P \lbrace X_{n+1}=j|(X_{n-1}, \dots, X_1)\in A, X_n=i \rbrace = P \lbrace X_{n+1}=j|X_n=i \rbrace +$$
+ +

进一步,过去是一个集合,未来也是一个集合:

+
$$ +P \lbrace X_{n+1}\in B|(X_{n-1}, \dots, X_1)\in A, X_n=i \rbrace = P \lbrace X_{n+1}\in B|X_n=i \rbrace +$$
+ +

但是,变量“现在”必须取值为一个确定的值,不能是一个集合。对现在的状态一定要精确掌握,不能放宽约束。

+

口号:从小事做起(泊松),从现在做起(马尔可夫)

+

转移概率

+
$$ +P_{ij}(m, n) = P \lbrace X_n = a_j | X_m = a_i \rbrace +$$
+ +
$$ +P_{ij}(m, n) \ge 0\\ +\sum\limits_{j}^{}P_{ij}(m, n) = 1 +$$
+ +

一步转移概率:

+
$$ +P_{ij}(m, m + 1) 或 P_{ij}(m) +$$
+ +

状态转移矩阵

+

观察变量族的联合分布

+

齐次马尔科夫链的迭代表示

$$ +X_0 \xrightarrow{Z_1} X_1 \xrightarrow{Z_2} X_2 \dots \xrightarrow{Z_n} X_{n} +$$
+ +
$$ +X_{n+1} = f(X_n,Z_{n+1}) = P \lbrace X_{n+1} = j | X_n = i \rbrace +$$
+ +

也称为新息过程

+

一维随机游走

吸收壁

+

反射壁 - 完全反射壁

+

成功逃跑

+

等待服务人数

+
$$ +X_{n + 1} = \begin{cases} + X_n - 1 + Y_{n + 1}, X_n \ne 0\\ + Y_{n + 1}, X_0 +\end{cases}\\ +P = \begin{bmatrix} + a_0 & a_1 & a_2 & \dots\\ + a_0 & a_1 & a_2 & \dots\\ + & a_0 & a_1 & \dots\\ + & & a_0 & \dotsb +\end{bmatrix} +$$
+ +

柯尔莫格洛夫方程

多步转移矩阵概率

+
$$ +P_{ij}(m, n) = \sum_k P(X_n = j | X_r = k) \cdot P(X_r = k | X_m = i) +$$
+ +

或者表示为

+
$$ +P_{ij}^{(p + q)} = \sum_{k \in \Omega} P_{ik}^{(p)} P_{kj}^{(q)} +$$
+ +

由于上面转移阵步数 $p, q$ 的任意性,多步跳变矩阵可以转变为矩阵相乘:

+
$$ +P^{(L)} = P^{(L - 1)}P^{(1)} = ... = P^L +$$
+ +

求多步转移矩阵:适用于齐次马尔可夫

+

齐次马尔可夫链的 $P$ 与时间起点无关

+

先求 $P^{(n)} = P^n$,再看 $[P^n]_{ij}$ 就是要求的转移概率。

+

如何求 $P^n$ ?

+

首先做特征分解 $PU = U\Lambda$

+
$$ +P^n = U \Lambda^nU^{-1} +$$
+ +

二元通信信道

+
$$ +P = \begin{pmatrix} + 1 - \alpha & \alpha\\ + \beta & 1 - \beta +\end{pmatrix}\\ +U = \begin{pmatrix} + 1 & -\alpha\\ + 1 & \beta +\end{pmatrix} +$$
+ + +
$$ +P^n = \frac{(1 - \alpha - \beta)^n}{\alpha + \beta}\begin{pmatrix} + \alpha & -\alpha\\ + -\beta & \beta +\end{pmatrix} + \frac{1}{\alpha + \beta} \begin{pmatrix} + \beta & \alpha\\ + \beta & \alpha +\end{pmatrix} +$$
+ +

在 $|1 - \alpha - \beta| < 1$ 的条件下,无穷步跳变后:

+
$$ +P^n = \frac{1}{\alpha + \beta} \begin{pmatrix} + \beta & \alpha\\ + \beta & \alpha +\end{pmatrix} +$$
+ +

各列相等,说明这个马尔可夫链与初始状态无关,历史被淡忘——马尔可夫性。

+

$1 - \alpha - \beta = -1$ 时,极限不存在

+
$$ +P = \begin{pmatrix} + 0 & 1\\ + 1 & 0\\ +\end{pmatrix} +$$
+ +

状态分类

可达性:$\exists m, s.t. P_{ij}^{(m)} > 0$

+

互通性:$\exist m, n, s.t. P_{ij}^{(m)} > 0, P_{ji}^{(n)} > 0$,是等价关系。

+

不可约(irreducible),不可分

+

马尔可夫链中每两个状态都是互通的,也叫互通链。

+

闭集:$\forall i \in C, j\not \in C, i \not \rightarrow j$

+

不可约的另一定义:除了把整个链作为闭集,不存在取其中一些状态构成其他闭集了。

+

激励状态

+

稳定状态(闭集)

+

一般情况,Markov 链的转移矩阵行列重排后可化为:

+
$$ +P = \begin{pmatrix} + u_1\\ + &u_2\\ + &&\ddots\\ + &&&u_k\\ + v_1&v_2&\dots&v_k&v_{k+1} +\end{pmatrix} +$$
+ +

对闭集而言,可以在闭集内使用柯尔莫格洛夫方程:

+
$$ +P_{ij}^{(n + m)} =\sum\limits_{r\in \Omega_1}^{}P_{ir}^{(n)}P_{rj}^{(m)} +$$
+ +

首次达到时间:$T_{ij}(\omega) = \min \lbrace n: X_0(\omega) = i, X_n(\omega) = j, n \ge 1 \rbrace$

+
$$ +T_{ij} \in [1, 2, ..., \infty) +$$
+ +

首次到达概率

+
$$ +f_{ij}^{(n)} = P \lbrace T_{ij} = n| X_0 = i \rbrace +$$
+ +

此时有

+
$$ +f_{ij}^{(1)} = P_{ij} +$$
+ +

定义

+
$$ +f_{ij} =\sum\limits_{k=1}^{\infty^-} f_{ij}^{(k)} +$$
+ +

为迟早到达的概率。

+
$$ +f_{ij}^{(\infty)} = 1 - f_{ij} +$$
+ +

表示永远无法到达的概率。

+

定理:

+
$$ +P_{ij}^{(n)} =\sum\limits_{r=1}^{n} f_{ij}^{(r)}P_{jj}^{(n - r)} +$$
+ +

考虑 $P_{ij}^{(0)} = \delta_{ij}$,上述可以写成卷积形式:

+
$$ +F_{ij}(z) = \sum\limits_{r=0}^{\infty} f_{ij}^{(r)}z^r\\ +G_{ij}(z) = \sum\limits_{r=0}^{\infty} f_{ij}^{(r)}z^{r}\\ +G_{ij}(z) = \delta_{ij} + F_{ij}(z)G_{jj}(z) +$$
+ +
$$ +i \rightarrow j \lrArr f_{ij} \gt 0 +$$
+ +

常返性

常返与非常返

若 $f_{ij} = 1$,称状态 i 为常返态

+

令 $z = 1$:

+
$$ +G_{ij}(1) = \delta_{ij} + F_{ij}(1)G_{jj}(1)\\ +i = j \rArr G_{ii}(1) = \frac{1}{1 - F_{ii}(1)} \rArr \sum_{n = 0}^{\infty}P_{ii}^{(n)} = \frac{1}{1 - f_{ii}} +$$
+ +

常返性判别:

+
$$ +常返态 \lrArr f_{ii} = 1 \lrArr \sum\limits_{n=0}^{\infty}P_{ii}^{(n)} = +\infty\\ +非常返态 \lrArr f_{ii} \lt 1 \lrArr \sum\limits_{n=0}^{\infty}P_{ii}^{(n)} = \frac{1}{1 - f_{ii}} < +\infty\\ +$$
+ +

后面会证明,这种返回的次数都是无穷大。

+

常返的理解:

+
$$ +\forall n, A_n = \begin{cases} + A_n = 1, X_n = i,\\ + A_n = 0, X_n \ne i. +\end{cases} +$$
+ +
$$ +E \lbrace \sum\limits_{k=0}^{\infty}A_k | X_0 = i \rbrace = \sum\limits_{k=0}^{\infty}P_{ii}^{(0)}\\ +$$
+ +

从判别定理可以看出,在期望意义上,常返态被无限次访问。

+

推论1:既然常返态被无穷次返回,非常返态被有限次访问,则在有限状态的 Markov 链中一定存在常返态。

+

反证法:如果全是有限返回次数,那所有态的访问次数加起来还是有限的,但是马尔可夫可以访问无限次,矛盾。所以一定有常返态。

+

推论1.1:如果非常返态的个数有限,则足够长的时间后,状态一定会到达常返态。

+

推论1.2:若 j 非常返,则$\forall i$

+
$$ +\sum\limits_{n=0}^{\infty}P_{ij}^{(n)} < \infty (i 到达 j的次数为有限值)\\ +\lim_{n \rightarrow \infty} P_{ij}^{(n)} = 0 +$$
+ +

推论2:若 $i$ 常返,$i \lrarr j$,则 $j$ 也是常返的。

+

推论3:若 $i$ 为常返,$i \rarr j$,则 $j \rarr i$

+

正常返与零常返

$f_{ii}^n$ 可以视为首次返回时间 $T_{ii}$ 的概率分布。对于非常返态不能这么看,因为 $f_{ii} < 1$。

+

对于常返态的 $T_{ii}$,可以计算期望

+
$$ +\mu_i = E \lbrace T_{ii} \rbrace = \sum\limits_{n = 1}^{\infty} n f_{ii}^{(n)} +$$
+ +

若均值为无穷大,则称为零常返。

+

零常返与非常返是有区别的。零常返是可以常返,只是大概率步数很多。

+

定义返回的速率,可推导

+
$$ +\lim _{n \rightarrow \infty} \frac{1}{n} \sum\limits_ {k=0}^{n - 1} P_{jj}^{(k)} = \frac{1}{\mu_j} +$$
+ +

正常返意味着速率为常数,零常返意味着速率为 0。

+

判定定理:

+
$$ +j 状态零常返 \lrArr \sum\limits_{n=0}^{\infty}P_{jj}^{(n)} = \infty, 且 n \rightarrow \infty 时,P_{jj}^{(n)} = 0 +$$
+ +

条件一就是常返的判定定理。条件二比较特殊:

+
$$ +\lim_{n \rightarrow \infty}P_{jj}^{(n)} = \frac{1}{\mu_j} +$$
+ +

如果是零常返,这个极限就是0。在条件二上,零常返和非常返是一样的。

+

定理:常返态 $i$,$i \rarr j$,则 $i, j$ 同为正常返或者零常返

+

补充性质

$$ +q_{jj}(M) = P \lbrace \sum\limits_{k=0}^{\infty}A_k \ge M | X_0 = j \rbrace\\ +\lim_{M \rarr \infty}q_{jj}(M) = \begin{cases} + 1, f_{jj} = 1\\ + 0, f_{jj} < 1\\ +\end{cases} +$$
+ +

下面研究常返态 $j$,不可约链

+

“从常返态触发,返回次数为无穷大”这件事的概率为 1.

+
$$ +\lim_{M \rarr \infty} q_{rj}(M) = 1, \forall +$$
+ +

“任意状态访问常返态的次数为无穷大”的概率为1.

+
$$ +q_{ij}(M) = f_{ij}q_{jj}(M) +$$
+ +

两边取极限可得 $f_{ij} = 1$

+

结论3: 从不可约链任何状态出发,迟早访问状态 $j$

+
$$ +\lim_{n \rarr \infty} P_{ij}^{(n)} = \frac{1}{\mu_j} +$$
+ +

结论4:极限概率与初始状态无关。

+

分类方式

+

对于每个常返态 i,存在一个 i 可达状态构成的状态集 C 。则这些状态彼此相通,构成一个不可约闭集,都常返

+

马尔可夫链可以唯一划分为 $C_1, C_2, …, T$,其中 $C_i$ 互为不相交的不可约闭集。T 为非常返态。每个闭集中,常返类型一致,不同闭集不互通。

+

定理:马尔科夫链若有一个零常返,有无穷多个零常返。

+

推论:有限状态马尔可夫链的常返态必然为正常返。

+

马尔可夫链的平稳分布和极限概率

对于不可约链:

+
$$ +\lim_{n \rarr \infty}P_{ij}^{(n)} = 0,j非常返\\ +P_{ij}^{(n)} = \frac{1}{\mu_j} = 0,j零常返\\ +P_{ij}^{(n)} = \frac{1}{\mu_j},j正常返 +$$
+ +

极限概率用 $\pi_j$表示

+

对于非常返和零常返,极限概率都是0。零常返的链一定有无穷个状态。

+

对于正常返,$\pi_j \gt 0, \sum\limits_{j\in S}^{}\pi_j = 1$

+

从柯式方程得出:

+
$$ +\pi_j = \sum\limits_{i}^{}\pi_iP_{ij} +$$
+ +

矩阵形式:

+
$$ +\lim_{n \rarr \infty} P^n = \Pi = \begin{bmatrix} + \pi_1 & \pi_2 & \cdots & \pi_n & \cdots\\ + \pi_1 & \pi_2 & \cdots & \pi_n & \cdots\\ + \cdots & \cdots & \cdots & \cdots & \cdots\\ +\end{bmatrix} +$$
+ + +

泊松过程

定义

计数过程

在 $[0, t]$ 内发生某类事件的次数记为 $\lbrace N(t), t\ge 0 \rbrace$,则称 $\lbrace N(t) \rbrace$ 为计数过程。

+

泊松过程

若满足以下条件:

+
    +
  1. $N(0) = 0$
  2. +
  3. 非负性:$N(t)$ 的取值非负整数;
  4. +
  5. 非降性:$N(t)$ 是随时间单调不减的;
  6. +
  7. 独立增量性:对于 $0 \le t_1 < t_2 < \ldots < t_n$,$N(t_2) - N(t_1), N(t_3) - N(t_2), \ldots, N(t_n) - N(t_{n-1})$ 是相互独立的随机变量;
  8. +
  9. 平稳增量性:对于 $0 \le s < t$,$N(t) - N(s)$ 的分布只与时间间隔 $t-s$ 有关,而与具体的时刻 $s$ 无关。
  10. +
  11. $P(N(t + \Delta t) - N(t) = 1) = \lambda\Delta t + o(\Delta t), P(N(t + \Delta t) - N(t) \ge 2) = o(\Delta t)$
    则称 $\lbrace N(t), t\ge 0 \rbrace$ 为泊松过程。
  12. +
+

性质

泊松的表达式

+
$$ +P_n(t) = P(N(t) = n) = \frac{(\lambda t)^n}{n!}e^{-\lambda t} +$$
+ +

泊松分布的特征函数

+
$$ +\phi_{N(t)}(\omega) = \exp \left \lbrace \lambda t (e^{j\omega} - 1) \right \rbrace +$$
+ +

泊松过程的数字特征

+
$$ +E(N(t)) = \lambda t\\ +R(t_1, t_2) = \lambda t_1 + \lambda^2 (t_1t_2) (t_1 \le t_2)\\ +C(t_1, t_2) = \min \lbrace t_1, t_2 \rbrace +$$
+ +

泊松与二项分布

泊松分布是二项分布的极限。

+

泊松脉冲串:

+
$$ +X(t) = \frac{\mathrm dN(t)}{\mathrm dt} = \sum\limits_{i}^{}\delta(t - t_i)\\ +E(X(t)) = \lambda +$$
+ +

泊松相关问题

事件间隔时间的分布

$S_n$ 表示第 n 件事到达的时刻

+

$T_n$ 表示相邻两件事发生的间隔

+
$$ +P\lbrace S_n \gt t \rbrace = P \lbrace N(t) \le n - 1 \rbrace +$$
+ +
$$ +f_{T_n}(t) = \lambda e^{-\lambda t}\\ +E(T_n) = 1 / \lambda +$$
+ +

$T_n$ 和 $T_m$ 是独立的。

+

等待时间的分布

概率密度函数与特征函数互为傅里叶变换

+
$$ +\Phi_{T_i}(\omega) = \frac{\lambda}{\lambda - j\omega}\\ +\Phi_{S_n}(\omega) = \left (\frac{\lambda}{\lambda - j\omega} \right)^n\\ +$$
+ +

要求 $S_n$ 的概率密度函数,可以看作 $T_n$ 的卷积:

+
$$ +f_{S_n}(t) = \frac{(\lambda t)^{n - 1}}{(n - 1)!}\lambda e^{-\lambda t}\\ +$$
+ +

称为 $\Gamma$ 分布,参数 $\lambda, n$。

+

相邻两次事件之间的计数

两次公交车到来(速度 $\mu$)之间,等车人数(速度 $\lambda$)的计数:

+
$$ +P(L = k) = (\frac{\mu}{\mu + \lambda})(\frac{\lambda}{\mu + \lambda})^k +$$
+ +

n个事件到达时间的的联合分布

$$ +f_{S_1...S_n|N(t) = n}(u_1, u_2, ..., u_n) = \frac{n!}{t^n} +$$
+ +

如果是有编号的(不是按顺序到达):

+
$$ +f_{V_1...V_n|N(t) = n}(t_1, t_2, ..., t_n) = \frac{1}{t^n} +$$
+ +

以下分布的极限,就是泊松过程:

+
$$ +P \lbrace N(s) = k | N(t) = n \rbrace = \binom{n}{k}(\frac{\lambda s}{n})^k(1 - \frac{\lambda s}{n})^{n - k} +$$
+ +

总结泊松过程的几种定义

    +
  1. N(0) = 0,独立增量,平稳增量,$\Delta t$ 内发生一个事件的概率 $\lambda \Delta t$,发生两件事以上的概率小
  2. +
  3. 事件时间间隔独立同分布,服从复指数分布,则计数为泊松
  4. +
  5. N 个客体随机地分布在 $[0, t]$ 区间上,每个客体的出现时间均匀分布,且相互时间独立,当 $n \rightarrow \infty, t \rightarrow \infty$,极限分布为泊松分布
  6. +
  7. 二项分布的极限
  8. +
+

顺序统计量

统计量是样本的某个函数 $g(X_1, …, X_n)$。例如:最大值、中值、平均值、样本协方差阵

+

顺序统计量:根据到达时刻排序。例如 $S_1, S_2, …, S_n$ 就是 $V_1, V_2, …, V_n$ 的顺序统计量

+
$$ +f_{Y_k}(x) = \binom{n}{k - 1}F(x)\binom{n - k + 1}{1}f(x)(1 - F(x))^{n - k} +$$
+ +

有序的顺序统计量的分布:

+
$$ +f_{Y_1...Y_n}(y_1, y_2, ..., y_n) = n!f(y_1)f(y_2)...f(y_n) +$$
+ +

非齐次泊松过程

四个条件:

+

$N(0) = 0$

+

$N(t)$ 独立增量

+

$P(N(t + \Delta t) - N(t) = 1) = \lambda(t)\Delta t + o(\Delta t)$

+

$P(N(t + \Delta t) - N(t) \ge 2) = o(\Delta t)$

+

定理:

+
$$ +P(N(t_0 + t) - N(t_0) = n) = \frac{[m(t_0 + t) - m(t_0)]^n}{n!}e^{-[m(t_0 + t) - m(t_0)]} +$$
+ +

其中,

+
$$ +m(t) = \int_{0}^{t}\mathrm \lambda(u) du +$$
+ +

其意义可以理解为事件的个数。

+

令 $m(t + t_0) - m(t_0) = \alpha$

+
$$ +P(N(t_0 + t) - N(t_0) = n) = \frac{\alpha^n}{n!}e^{-\alpha} +$$
+ +

则期望和方差

+
$$ +E(N(t_0 + t) - N(t_0)) = \alpha\\ +V(N(t_0 + t) - N(t_0)) = \alpha +$$
+ +

复合泊松

$Y_n$ 随机变量族,$N(t)$ 泊松过程,称$X(t) = \sum_{n = 1}^{N(t)}Y_n$ 为复合泊松。

+
$$ +E \lbrace X(t) \rbrace = \lambda t \cdot E \lbrace Y_i \rbrace\\ +D \lbrace X(t) \rbrace = \lambda t \cdot E \lbrace Y_i^2 \rbrace\\ +G_X(z) = \exp(\lambda t G_Y(z) - 1)\\ +\phi_X(\omega) = \exp(\lambda t \phi_Y(\omega) - 1) +$$
+ +

随机参数泊松

参数 $\lambda$ 是随机变量,PDF为 $f(\lambda)$

+
    +
  • 是平稳增量
  • +
  • 不是独立增量
  • +
+
$$ +P(Y(t) = n) = \int^{+\infty}_{0}\frac{(\lambda t)^n}{n!}e^{-\lambda t}f(\lambda)\mathrm d\lambda +$$
+ +

母函数:

+
$$ +G_{Y(t)}(z) = \int_{0}^{\infty}\exp (\lambda t(z - 1))f(\lambda)\mathrm d\lambda +$$
+ +
$$ +E(Y(t)) = \int_{0}^{\infty}\lambda t f(\lambda)\mathrm d\lambda\\ +V(Y(t)) = \int_{0}^{\infty}\lambda t f(\lambda)\mathrm d\lambda\\ +$$
+ +

数据统计的后验分布

+
$$ +P(\Lambda \le x | Y(t) = n) = \frac{\int_{0}^{x}\frac{(\lambda t)^n}{n!}e^{-\lambda t}f(\lambda)\mathrm d\lambda}{\int_{0}^{\infty}\frac{(\lambda t)^n}{n!}e^{-\lambda t}f(\lambda)\mathrm d\lambda}\\ +f_\Lambda(x|Y(t) = n) = \frac{\frac{(x t)^n}{n!}e^{-x t}f(x)}{\int_{0}^{\infty}\frac{(\lambda t)^n}{n!}e^{-\lambda t}f(\lambda)\mathrm d\lambda} +$$
+ +

过滤的泊松过程

统计一段时间影响的总和

+
$$ +Y(t) = \sum\limits_{i=1}^{N(t)}h(t, S_i, A_i) +$$
+ +

特征函数:

+
$$ +\Phi_{Y(t)}(\omega) = \exp \left ( \lambda t \left ( \int_{0}^{t}\frac{1}{t}\exp(j\omega h(t, v))\mathrm dv - 1\right) \right) +$$
+ +

均值:

+
$$ +E(Y(t)) = \frac{1}{j}\frac{\partial \Phi_{Y(t)}}{\partial \omega} = \underbrace{\lambda t}_{平均到达个数} \underbrace{\int_{0}^{t}\frac{1}{t}\exp(j\omega h(t, v))\mathrm dv}_{每个事件在 t 时刻的影响} +$$
+ +

生灭过程

该过程状态可以用整数序列 $n = 0, 1, 2, 3, …$ 来表示

+

状态转移只能发生在临近状态之间

+

在$[t, t + \Delta t)$ 区间内,n状态转移到 $n + 1$ 状态的概率为 $\lambda \Delta t$, 转移到 $n - 1$ 状态的概率为 $\mu \Delta t$。

+

M/M/1

系统平均顾客人数 $L = \frac{\lambda / \mu}{1 - \lambda / \mu}$

+

排队平均人数

+
$$ +L_Q = \sum\limits_{n=1}^{\infty}(n - 1)p_n = \frac{\lambda^2}{(\mu - \lambda)\mu}\\ +L_Q \ne L - 1 +$$
+ +

前面有一个人,等待时间:负指数分布的无记忆性

+
$$ +f_T(t|T > t_0) = \mu e^{-\mu (t - t_0)} +$$
+ +

从而不管你什么时候来,平均等待时间为 $1/\mu$,和一个人被服务的时间是一样的。

+

习题课

alt

+
\ No newline at end of file diff --git a/2023/10/09/Python-OJ/index.html b/2023/10/09/Python-OJ/index.html new file mode 100644 index 00000000..fbca2cf2 --- /dev/null +++ b/2023/10/09/Python-OJ/index.html @@ -0,0 +1,78 @@ +Python-OJ | Guo_Yun + + + + + + + + + + + + + + + +

Python-OJ

idea

python语言以其时间性能和空间性能低下著称,在各类 OJ 竞赛中尤为劣势。因此,优化 python 语言的空间和时间成为了一种可以研究的技巧()

+
    +
  • 使用 python 练习 Codeforce 最新赛题
  • +
  • 比较 test case 的通过时间,从而得出优化结论
  • +
+

解释器的选择

Codeforce 官网称,采用 PyPy 运行 python 代码的速度远快于原生 python 解释器。

+

《much faster》

+

alt

+

建议一个不快就换另一个

+

python 时间优化技巧

list.pop()很占用时间

+

赛题为 Codeforces Round 902 (Div. 1, based on COMPFEST 15 - Final Round)

+

优化前的代码:

+
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
def single(n, p, a, b):
all_len = n
person_list = list(range(all_len))
person_list.sort(key=lambda x:b[x])
cost = p
informed_len = 1
while informed_len < all_len:
index = person_list.pop(0)
item_a = a[index]
item_b = b[index]
if item_b < p:
if item_a < all_len - informed_len:
# continue
informed_len += item_a
cost += item_a * item_b
else:
# end
rest_len = all_len - informed_len
cost += rest_len * item_b
break
else:
rest_len = all_len - informed_len
cost += rest_len * p
break

return cost
+ +

结局:Test: #8, time: 1000 ms., memory: 12104 KB, exit code: -1, checker exit code: 0, verdict: TIME_LIMIT_EXCEEDED

+

优化后的代码:

+
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
def single(n, p, a, b):
all_len = n
person_list = list(range(all_len))
person_list.sort(key=lambda x:b[x])
cost = p
informed_len = 1
front = 0
while informed_len < all_len:
index = person_list[front]
item_a = a[index]
item_b = b[index]
if item_b < p:
if item_a < all_len - informed_len:
# continue
informed_len += item_a
cost += item_a * item_b
else:
# end
rest_len = all_len - informed_len
cost += rest_len * item_b
break
else:
# end
rest_len = all_len - informed_len
cost += rest_len * p
break
front += 1

return cost
+ +

结局:Accepted。在 test #8上:Test: #8, time: 171 ms., memory: 12140 KB, exit code: 0, checker exit code: 0, verdict: OK

+

pop会删除列表的元素,因此需要多余的时间。故采用下标记录列表的顶层元素更节约时间。

+
\ No newline at end of file diff --git a/2024/02/26/AI/index.html b/2024/02/26/AI/index.html new file mode 100644 index 00000000..9db8f7c5 --- /dev/null +++ b/2024/02/26/AI/index.html @@ -0,0 +1,325 @@ +Introduction to Artificial Intelligence | Guo_Yun + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Introduction to Artificial Intelligence

Learning

Linear Classification

Logistic Regression

Useful for classification problems.

+

Cross-Entropy Loss

+
$$ +\ell(h(\boldsymbol{x}_{i}),y_{i})=\begin{cases}-\log[\sigma(\boldsymbol{w}^{T}\boldsymbol{x}_{i})]&\quad y_{i}=1\\-\log[1-\sigma(\boldsymbol{w}^{T}\boldsymbol{x}_{i})]&\quad y_{i}=0\end{cases} +$$
+ +

With regularization:

+
$$ +\hat{\epsilon}(w)=-\sum_{i=1}^n\lbracey_i\log\sigma(h_w(x))+(1-y_i)\log[1-\sigma(h_w(x))]+\lambda\sum_{j=1}^dw_j^2 +$$
+ +

How to deal with multiclass problems?

+

Softmax Regression

Normalizes multiple outputs in a probability vector.

+
$$ +p(y=i|x)=\frac{\exp(w_i^Tx)}{\sum_{r=1}^C\exp(w_r^Tx)} +$$
+ +

Cross-Entropy Loss

+
$$ +\ell(h(x_i),y_i)=\begin{cases}-\log\left[\frac{\exp(\boldsymbol{w}_1^T\boldsymbol{x})}{\sum_{r=1}^C\exp(\boldsymbol{w}_r^T\boldsymbol{x})}\right]&y_i=1\\-\log\left[\frac{\exp(\boldsymbol{w}_2^T\boldsymbol{x})}{\sum_{r=1}^C\exp(\boldsymbol{w}_r^T\boldsymbol{x})}\right]&y_i=2\\\vdots\\-\log\left[\frac{\exp(\boldsymbol{w}_c^T\boldsymbol{x})}{\sum_{r=1}^C\exp(\boldsymbol{w}_r^T\boldsymbol{x})}\right]&y_i=C\end{cases} +$$
+ +

This loss is convex. But there are many solutions that result in same outputs, so the regularizaton is indispensible to prevent divergence.

+

1713166706648

+

Support Vector Machine (SVM)

Soft-SVM (Hinge Loss)

$$ +\min_{w,b,\xi}\frac{1}{2}\|w\|_{2}^{2}+\frac{C}{n}\sum_{i=1}^{n}\xi_{i}\\\mathrm{s.t.~}y_i(\boldsymbol{w}\cdot\boldsymbol{x}_i+b)\geq1-\xi_i\\\xi_i\geq0,1\leq i\leq n +$$
+ +

Define Hinge Loss

+
$$ +\ell(f(x),y)=\max\{0,1-yf(x)\rbrace +$$
+ +

For the linear hypothesis:

+
$$ +\ell(f(x),y)=\max\{0,1-y(w\cdot x+b)\} +$$
+ +

Theorem: Soft-SVM is equivalent to a Regularized Rise Minimization:

+
$$ +\min_{w,b}\frac12\|w\|_2^2+\frac Cn\sum_{i=1}^n\max\{0,1-y_i(w\cdot x_i+b)\} +$$
+ +

这意味着SVM的“最大化”边界距离项本质上是一个正则化项。

+

Kernel Soft-SVM

Basis function $\Phi(x)$ can often replaced by kernal function $k(x_1, x_2)$.

+

Polynomial Kernel: efficient computation: $O(d)$

+

1713169419702

+

Construct new kernel function from exist kernel functions:

+
$$ +k^{\prime}(x_{1},x_{2})=k_{1}\otimes k_{2}(x_{1},x_{2})=k_{1} +(x_{1},x_{2})k_{2}(x_{1},x_{2}) +$$
+ +

For any function $g: \mathcal X \rightarrow \R$

+
$$ +k^\prime(x_1,x_2)=g(x_1)k_1(x_1,x_2)g(x_2) +$$
+ +

Apply Representer theorem:

+
$$ +\min_\alpha\frac12\alpha^TK\alpha+\frac Cn\sum_{i=1}^n\max\left\{0,1-y_i\sum_{j=1}^n\alpha_jk(x_i,x_j)\right\} +$$
+ +
    +
  • $\alpha_j$ is the weight of each reference point $\color{red}{x_j}$ to the prediction of $\color{red}{x_i}$.
  • +
  • lt is actually a Primal Form with kernel functions.
  • +
+

Decision Tree

Criterion:

+
    +
  • More balance
  • +
  • More pure
  • +
+

Misclassification error (not used very frequently):

+
$$ +\mathrm{Err}(\mathcal{D})=1-\max_{1\leq k\leq K}\left(\frac{|\mathcal{C}_k|}{|\mathcal{D}|}\right) +$$
+ +

Use Entropy to measure purity:

+
$$ +H(\mathcal{D})=-\sum_{k=1}^K\frac{|\mathcal{C}_k|}{|\mathcal{D}|}\mathrm{log}\frac{|\mathcal{C}_k|}{|\mathcal{D}|} +$$
+ +

Gini Index:

+
$$ +\mathrm{Gini}(\mathcal{D})=1-\sum_{k=1}^K\left(\frac{|\mathcal{C}_k|}{|\mathcal{D}|}\right)^2 +$$
+ +

ID3 Algorithm

1713171808270

+

Multiplayer Perceptrons (MLP)

MLP for XOR

1713771652191

+

Activation

1713772489046

+

Loss Functions

Entropy

+
$$ +H(q)=-\sum_{j=1}^kq_j\log q_j +$$
+ +

Relative-entropy

+
$$ +\mathrm{KL}(q||p)=-\sum_{j=1}^kq_j\log p_j-H(q) +$$
+ +

Cross-entropy

+
$$ +H(q,p)=-\sum_{j=1}^kq_j\log p_j +$$
+ +

Relationship:

+
$$ +\boxed{H(q,p)=\mathrm{KL}(q||p)+H(q)} +$$
+ +

Softmax in the output layer

+
$$ +\widehat{\boldsymbol{y}}=\boldsymbol{a}^{(n_l)}=f_\theta\big(\boldsymbol{x}^{(i)}\big)=\begin{bmatrix}p\big(\boldsymbol{y}^{(i)}=1\big|\boldsymbol{x}^{(i)};\boldsymbol{\theta}\big)\\p\big(\boldsymbol{y}^{(i)}=2\big|\boldsymbol{x}^{(i)};\boldsymbol{\theta}\big)\\\vdots\\p\big(\boldsymbol{y}^{(i)}=k\big|\boldsymbol{x}^{(i)};\boldsymbol{\theta}\big)\end{bmatrix}=\frac{1}{\sum_{j=1}^{k}\exp(z_{j}^{(n_{l})})}\begin{bmatrix}\exp(z_{1}^{(n_{l})})\\\exp(z_{2}^{(n_{l})})\\\vdots\\\exp(z_{k}^{(n_{l})})\end{bmatrix} +$$
+ +

Cross-entropy loss:

+
$$ +J(y,\widehat{y})=-\sum_{j=1}^ky_j\log\widehat{y}_j +$$
+ +

Cost function:

+
$$ +\min J(\theta)=-\frac1m\sum_{i=1}^m\left[\sum_{j=1}^k\mathbf{1}\{y^{(i)}=j\}\mathrm{log}\frac{\exp(\mathbf{z}_j^{(n_\iota)})}{\sum_{j^{\prime}=1}^k\exp(\mathbf{z}_{j^{\prime}}^{(n_\iota)})}\right] +$$
+ +

Gradient-Based Training

$$ +\arg\min_\theta O(\mathcal{D};\theta)=\sum_{i=1}^mL\left(y_i,f(x_i);\theta\right)+\Omega(\theta) +$$
+ +

Forward Propagation: to compute activations & objective $J(\theta)$

+

Backward Propagation: Update paramters in all layers

+
Learning Rate decay

Exponential decay strategy:

+
$$ +\eta = \eta_0e^{kt} +$$
+ +

1/t decay strategy:

+
$$ +\eta = \eta_0/(1+kt) +$$
+ +
Weight Decay

L2 regularization:

+
$$ +\Omega(\theta)=\frac\lambda2\sum_{l=1}^{n_l-1}\sum_{i=1}^{s_l}\sum_{j=1}^{s_{l+1}}(\theta_{ji}^{(l)})^2\\\frac\partial{\partial\theta^{(l)}}\Omega(\theta)=\lambda\theta^{(l)} +$$
+ +

L1:

+
$$ +\Omega(\theta)=\lambda\sum_{l=1}^{n_{l}-1}\sum_{i=1}^{s_{l}}\sum_{j=1}^{s_{l+1}}|\theta_{ji}^{(l)}|\\\frac{\partial}{\partial\theta^{(l)}}\Omega(\theta)_{ji}=\lambda(1_{\theta_{ji}^{(l)}>0}-1_{\theta_{ji}^{(l)}<0}) +$$
+ +

一般不调。

+
Weight Initialization

Xavier initialization

+

(Linear activations)

+
$$ +\mathrm{Var}(w)=1/n_{\mathrm{in}} +$$
+ +

避免梯度爆炸或者消失;

+

He initialization

+

(ReLU activations)

+
$$ +\mathrm{Var}(w)=2/n_{\mathrm{in}} +$$
+ +

因为 ReLU 删除了一半的信息。

+

1713775669844

+

Convolutional Neural Network (CNN)

1713776156049

+

1713776168789

+

1714379943169

+

Convoluion Kernel

1714380111476

+

Stride

+

1714380132725

+

Padding

+

1714380159356

+

1714380233071

+

Pooling

1714380343254

+

Batch Normalization

+

1714379335929

+

在 N 张图像的对应通道做归一化。

+

可以增强训练的稳定性,使得学习率可以设大一点而仍然保证收敛。

+
    +
  • 数据集成
  • +
  • 参数集成
  • +
  • 模型集成
  • +
+

ResNet

1714380578105

+

1714380763838

+

最后一层 Global Average Pooling:7*7*2048 -> 1* 1 * 2048

+

Recurrent Neural Network (RNN)

Idea for Sequence Modeling

Local Dependency

+

1714982108981

+

Parameter Sharing

+

1714982133935

+

RNN

1714982188331

+

Go deeper

+

1714982215920

+

Standard Architectures

1714982075164

+
    +
  • RNNs can represent unbounded temporal dependencies
  • +
  • RNNs encode histories of words into a fixed size hidden vector
  • +
  • Parameter size does not grow with the length of dependencies
  • +
  • RNNs are hard to learn long range dependencies present in data
  • +
+

LSTM

Multihead, shared bottom.

+

1714982405665

+

Gradient flow highway: remember history very well.

+

NIPS 2015 Highway Network.

+

Training Strategies

Shift in Training & Inference

+

1714983390325

+

Use Scheduled Sampling to solve this

+

1714983452419

+

Problem: Gradient Explosion during continuously multiplication.

+

Solution: Gradient Clipping

+

1714983641507

+

Variational Dropout

+

1714983788461

+

Layer Normalization

+

1714983988587

+

BN: Easy to compare between channels

+

LN: Easy to compare between samples

+

在图像任务上,我们一般认为 channel 之间的地位应该是相同的,因此常常采用 BN。

+

Transformer

use attention to replace state space.

+

1714984460020

+

Attention

1714984778231

+
$$ +\text{Attention}(Q,K,V)=\text{Softmax}\left(\frac{QK^T}{\sqrt{d_k}}\right)V +$$
+ +

Multi-Head Attention

+

1714985419724

+

Sparse?

+

$W^o$ to maintain shape and jointly attend to information from different representation subspaces.

+

FFN

Position-wise FFN (Similar to multi convolution kernels in CNN, shared parameters in every word.)

+

1714985971187

+

Positional Encoding

1714986050538

+
\ No newline at end of file diff --git a/2024/02/26/StaSP/index.html b/2024/02/26/StaSP/index.html new file mode 100644 index 00000000..97969278 --- /dev/null +++ b/2024/02/26/StaSP/index.html @@ -0,0 +1,1044 @@ +Statistical Signal Processing | Guo_Yun + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Statistical Signal Processing

参数估计

分类:

+
    +
  • 经典估计
  • +
  • 贝叶斯估计
  • +
+

准则:

+
    +
  • MSE,均方误差
  • +
+
$$ +\hat \theta = f(\bm{x}) +$$
+ +

MSE

$$ +\text{mse}(\hat \theta) = E \lbrace(\theta - \hat \theta)^2\rbrace = \text{var}(\hat \theta) + b^2(\hat \theta)\\ +b^2(\hat \theta) = E(\hat \theta) - \theta +$$
+ +

现实中无法直接计算 MSE,因为涉及到真值 $\theta$,但是 $\theta$ 是我们要求的参数。

+

MVU

最小方差无偏估计

+

MVU, Minimum Variance Unbiased

+

无偏:

+
$$ +E(\hat \theta) = \theta, a \lt \theta \lt b +$$
+ +

无偏的含义:$\hat \theta$ 的求法需要对取值范围内任意的 $\theta$ 进行估计。

+

无偏估计是否一定存在?不一定。

+

最小方差:

+
$$ +\min \text{var}\lbrace\hat\theta\rbrace +$$
+ +

MVU的内涵:估计值的发散程度最小(最小方差),平均意义上靠近真值(MVU)。是对 MSE 的迂回实现。

+

克拉美罗界定理(CRLB)

假设 $p(\bm{x};\theta)$ 满足正则条件:

+
$$ +E \left [ \frac{\partial\ln p(\bm{x};\theta)}{\partial\theta} \right] = 0 +$$
+ +

+
$$ +\text{var}(\hat\theta) \ge \frac{1}{E \left [\left( \frac{\partial\ln p(\bm{x};\theta)}{\partial\theta}\right)^2 \right]} = - \frac{1}{E \left [ \frac{\partial^2\ln p(\bm{x};\theta)}{\partial\theta^2} \right]} +$$
+ +

等号成立的充要条件:找到函数 $I, g$

+
$$ +\frac{\partial \ln p(\bm{x};\theta)}{\partial \theta}= I(\theta)(g(\bm{x}) - \theta)\\ +\hat \theta = g(\bm{x}) +$$
+ +

此时有 $\text{var}(\hat\theta) =1 / I(\theta)$。

+

求解MVU

$$ +\frac{\partial \ln p(\bm{x};A)}{\partial A} = \frac{1}{\sigma^2}\sum\limits_{n=0}^{N - 1}(x[n] - A) = \frac{N}{\sigma^2}\left (\frac{1}{N}\sum\limits_{n=0}^{N - 1}(x[n] - A) \right) +$$
+ +
$$ +g(\bm{x}) = \frac{1}{N}\sum\limits_{n=0}^{N - 1}x[n]\\ +I(\theta) = \frac{N}{\sigma^2} +$$
+ +

有效估计量:能达到克拉美罗下界的估计量,是MVU的子集。

+

参数变换的克拉美罗界

+
$$ +\alpha = g(\theta) +$$
+ +

+
$$ +CRLB(\hat \alpha) = \left(\frac{\partial g(\theta)}{\partial \theta}\right)^2CRLB(\hat \theta) +$$
+ +

对于高斯分布有

+
$$ +E(x^2) = \mu^2 + \sigma^2\\ +E(x^4) = \mu^4 + 6\mu^2\sigma^2 + 3\sigma^4 +$$
+ +

当数据量很大时

+

有效估计量靠近真值:$N \rightarrow \infty, \hat\theta \rightarrow \theta$

+

非线性变换渐进有效,可以看成线性函数:$g(\hat \theta) \approx g(\theta) + \frac{\partial g(\theta)}{\partial\theta}(\hat \theta - \theta)$

+

矢量参数的克拉美罗界

$$ +E \left [ \frac{\partial \ln p(\bm{x};\bm{\theta})}{\partial \bm{\theta}} \right] = 0 +$$
+ +
$$ +\alpha = g(\theta) +$$
+ +

+

注意:$\bm T(\bm x)$ 的维度要和 $\bm \theta$ 的维度相同

+

线性模型方法

$$ +x = H\theta + w, w \sim N(0, \sigma^2I) +$$
+ +
$$ +p(x;\theta) = \frac{1}{(2\pi\sigma)^{N/2}}\exp \lbrace -\frac{1}{2\sigma^2}(x - H\theta)^T(x - H\theta) \rbrace +$$
+ +
$$ +\frac{\partial \ln p(x;\theta)}{\partial \theta} = \frac{H^TH}{\sigma^2}\lbrace (H^TH)^{-1}H^Tx - \theta \rbrace +$$
+ +

从而

+
$$ +\hat \theta = (H^TH)^{-1}H^Tx\\ +C_{\hat\theta} = \sigma^2(H^TH)^{-1} +$$
+ +

这个 MVU 估计量满足

+
$$ +\hat \theta \sim N(\theta, \sigma^2(H^TH)^{-1}) +$$
+ +
    +
  • 要求观测数据与待估计参数间呈线性关系
  • +
  • 要求噪声是高斯白噪声
  • +
  • 要求观测矩阵是满秩的
  • +
  • 所得估计量是有效估计量
  • +
+

一般信号模型

+
$$ +x = H\theta + s + w, s已知,w \sim N(0, C) +$$
+ +

结论

+
$$ +\hat \theta = (H^TC^{-1}H)^{-1}H^TC^{-1}(x - s)\\ +C_{\hat\theta} = (H^TC^{-1}H)^{-1} +$$
+ +

充分统计量方法

$$ +p(x|T(x);\theta) = p(x|T(x)) +$$
+ +

则称 $T(x)$ 为充分统计量

+

充分统计量的性质:

+
    +
  • 一旦充分统计量确定,似然函数就与待估计参数无关
  • +
  • 充分统计量依赖于待估计参数。待估计参数变化,其相应的充分计量一般也会变化
  • +
  • 所谓“充分”,是相对于原始观测数据而言的原始观测量总是充分统计量,但通常不是最小集
  • +
  • 充分统计量并不唯一
  • +
+

+
$$ +\int_{-\infty}^{\infty}v(T)p(T;\theta)\mathrm dT = 0 +$$
+ +

对所有的 $\theta$ 并非都满足,只对零函数 $v(T) = 0$ 成立,则称充分统计量是完备的。

+
    +
  • 一般地,当待估计参数发生变化时,充分统计量也会发生变化
  • +
  • 一旦充分统计量确定以后,似然函数就与待估计参数无关
  • +
+

Neyman-Fisher因子分解定理

如果概率密度函数(或概率质量函数,对于离散随机变量)$p(x; \theta)$ 可以被分解为

+
$$ +p(x; \theta) = g(T(x); \theta) \cdot h(x) +$$
+ +

其中:

+
    +
  • $g(T(x); \theta)$ 是一个只通过统计量 $T(x)$ 并依赖于参数 $\theta$ 的函数。
  • +
  • $h(x)$ 是只与观测数据 $x$ 相关的函数,与参数 $\theta$ 无关。
  • +
+

那么,统计量 $T(x)$ 是参数 $\theta$ 的充分统计量。反之,如果 $T(x)$ 是参数 $\theta$ 的充分统计量,那么概率密度函数 $p(x; \theta)$ 必然可以分解为上述形式。

+

Rao-Black-Lehmann-Scheffe(RBLS)定理

若 $\breve\theta$ 是$\theta$的无偏估计,$T(x)$是$\theta$的充分统计量,那么$\hat \theta=E(\breve{\theta}|T(x))$

+
    +
  1. 是$\theta$ 的一个适用的估计量(与$\theta$无关)
  2. +
  3. 无偏的
  4. +
  5. 对所有的 $\theta$,它的方差小于等于$\breve\theta$ 的方差
  6. +
  7. 若$T(x)$是完备的,那么$\theta$是MVU估计量
  8. +
+

矢量参数的 RBLS

+

+

BLUE

定义

直接求出数据->参数的映射 $\bm A_{p \times N}$:

+
$$ +\bm x = \bm H \theta\\ +\hat {\theta}_{p \times 1} = \bm A\bm x +$$
+ +

无偏性:

+
$$ +\theta = E(\hat\theta) = \bm AE(\bm x) = \bm AH\theta\\ +\Rightarrow AH = I_{p \times p} +$$
+ +

最佳(最小方差)

+
$$ +\min \lbrace a_i^TCa_i \rbrace, A = [a_1, a_2, \dots, a_n]^T +$$
+ +

其中

+
$$ +C = E \lbrace (x - E(x))(x - E(x))^T \rbrace +$$
+ +

高斯-马尔可夫定理

如果数据具有一般线性模型的形式

+
$$ +\bm x = \bm H \theta + w +$$
+ +

其中 $\bm H$ 为已知 $N \times p$ 矩阵,$\theta$ 为待估计参数,$w$ 是均值为零、协方差为 $\bm C$ 的噪声矢量(不一定为高斯),则 BLUE 估计量为

+
$$ +\hat \theta = (H^TC^{-1}H)^{-1}H^TC^{-1}x\\ +C_{\hat\theta} = (H^TC^{-1}H)^{-1} +$$
+ +
    +
  • 若为高斯噪声,则BLUE为MVU,且为有效估计量
  • +
+

MLE

定义

$$ +\hat \theta = \arg\max\limits_\theta p(\bm{x};\theta) +$$
+ +

如果 PDF 可导

+
$$ +\frac{\partial p(\bm x; \theta)}{\partial \theta}\bigg|_{\hat\theta} = 0\\ +\Rightarrow\frac{\partial \ln p(\bm x; \theta)}{\partial \theta}\bigg|_{\hat\theta} = 0 +$$
+ +

若有效估计量存在,$\frac{\partial \ln p(\bm x; \theta)}{\partial \theta}\bigg|_{\hat\theta} = I(\theta)(g(x) - \theta)$,则可以使用最大似然估计方法求得结果。

+

MLE 的性质

如果数据 $\bm x$ 的 PDF $p(\bm x;\theta)$ 满足“正则”条件,那么
对于足够多的数据记录,未知参数 $\theta$ 的 MLE 渐近服从

+
$$ +\hat\theta \stackrel{a}{\sim} N(\theta, I^{-1}\theta) +$$
+ +

其中 $\theta$ 是在未知参数真值处计算的 Fisher 信息。

+

MLE是渐近无偏的

+

MLE渐近达到CRLB

+

MLE是渐近有效的

+

MLE是渐近最佳的

+
    +
  • MLE的方差(协方差)可大于、等于、小于CRLB!(不同于MVU估计)
  • +
  • 但数据量足够多时,将与CRLB接近
  • +
  • 因此,可利用CRLB评估MLE的性能
  • +
+

“足够多”数据:大量能带来新信息的数据

+

MLE的不变性

+

若参数 $\alpha = g(\theta)$,则

+
$$ +\hat\alpha = g(\hat\theta) +$$
+ +

若 $g$ 非一对一函数,那么 $\hat\alpha$ 是使修正后的似然函数 $p_T(\bm x;\alpha)$ 最大者

+
$$ +\hat\alpha = \arg\max_\alpha p_T(\bm x; \alpha)\\ +p_T(\bm x; \alpha) = \max_{\theta: \alpha=g(\theta)}p(\bm x; \theta) +$$
+ +

该性质对函数 $g$ 无线性变换要求,对任意函数均成立。

+

对比MVU

+
    +
  • 无偏性、有效性仅对线性变换成立
  • +
  • 对非线性变换不能保持(但渐近无偏、渐近有效)
  • +
+

对一般线性模型,MLE是MVU,达到了CRLB,是有效的、最佳的!

+

1711254850893

+

最小二乘估计(LS)

线性最小二乘估计

1711339154789

+

加权最小二乘估计

1711339192281

+

约束最小二乘估计

1711339216759

+

比较

1711339249863

+

经典估计方法比较

噪声电平估计问题

$$ +x[n] = A + w[n] +$$
+ +

其中 $w[n] \sim N(0, \sigma^2)$,待估计参数 $\theta = [A, \sigma^2]^T$

+

MVU估计

$$ +p(x;\theta) = \frac{1}{(2\pi\sigma^2)^{N/2}}\exp \lbrace -\frac{1}{2\sigma^2} \sum\limits_{n=0}^{N - 1}(x[n] - A)^2\rbrace +$$
+ +
$$ +\frac{\partial \ln p (x;\theta)}{\partial A} = \frac{1}{\sigma^2}\sum\limits_{n=0}^{N - 1}(x[n] - A) +$$
+ +
$$ +\frac{\partial \ln p(x;\theta)}{\partial \sigma^2} = \frac{N}{2\sigma^2} + \frac{1}{2\sigma^4}\sum\limits_{n=0}^{N - 1}(x[n] - A) +$$
+ +

1711339773571

+

1711339786814

+

线性模型

$$ +\hat\theta = (\bm H^T\bm H)^{-1}\bm H^T x +$$
+ +

1711339831807

+

BLUE

$$ +\hat\theta = (\bm H^T\bm C^{-1}\bm H)^{-1}\bm H^T\bm C^{-1} x +$$
+ +

1711339865703

+

充分统计量

1711340151724

+

1711340163113

+

1711340177961

+

MLE

1711340277148

+

LSE

1711340293644

+

贝叶斯估计

贝叶斯MSE:
Bmse$\left(\hat{\theta}\right)=E\left(\left(\theta-\hat{\theta}\right)^2\right)$

+

$=\int\int\left(\theta-\hat{\theta}\right)^{2}p\big(\mathbf{x},\theta\big)d\mathbf{x}d\theta$ $=\iint\left(\theta-\hat{\theta}\right)^2p\big(\boldsymbol{x}|\theta\big)p\big(\theta\big)d\boldsymbol{x}d\theta$
$=\iint\left(\theta-\hat{\theta}\right)^2p(x|\theta)dxp(\theta)d\theta$

+

$\hat{\theta}=E\big(\theta|x\big)$

+

多余参数:未知,但不感兴趣的参数
解决思路:通过积分消除多余参数的影响
(1) 后验概率中存多余参数时:

+
$$ +p(\boldsymbol{\theta},\boldsymbol{\alpha}\mid\boldsymbol{x}) \Rightarrow p (\boldsymbol{\theta}\mid\boldsymbol{x})=\int p(\boldsymbol{\theta},\boldsymbol{\alpha}\mid\boldsymbol{x})\:d\boldsymbol{\alpha} +$$
+ +

(2) 条件概率中存在多余参数时:

+
$$ +p(\boldsymbol{\theta}\mid\boldsymbol{x})=\frac{p(\boldsymbol{x}\mid\boldsymbol{\theta})p(\boldsymbol{\theta})}{\int p(\boldsymbol{x}\mid\boldsymbol{\theta})p(\boldsymbol{\theta})d\boldsymbol{\theta}} +$$
+ +
$$ +\text{若现只有 }p(x|\theta,\alpha)\text{,而无 }p(x|\theta) +$$
+ 此时可通过积分方式解决 + +
$$ +p(x\mid\theta)=\int p(x\mid\theta,\alpha)p(\alpha\mid\theta)d\alpha +$$
+ +

进一步地,若待估计参数与多余参数相互独立,

+
$$ +p(x\mid\theta)=\int p(x\mid\theta,\alpha)p(\alpha)d\alpha +$$
+ +

矢量参数下贝叶斯估计
若 θ 是 $p{\times}1$ 的矢量参数,那么为了估计其中某个参数 $\theta_i$, 可以将剩余参数当作多余参数,因此对$\theta_i$ 的MMSE为

+
$$ +\hat{\theta}_i=E\left(\theta_i\mid x\right)=\int\theta_ip(\theta_i\mid x)d\theta_i +$$
+ 其中 + +
$$ +p(\theta_i\mid x)=\int\cdots\int p(\theta\mid x)d\theta_1\cdots d\theta_{i-1}d\theta_{i+1}\cdots d\theta_p +$$
+ +
$$ +\hat{\theta}_i=\int\theta_i\left(\int\cdots\int p(\boldsymbol{\theta}\mid\boldsymbol{x})\underline{d\theta_1\cdots d\theta_{i-1}d\theta_{i+1}\cdots d\theta_p}\right)d\theta_i=\int\theta_ip(\boldsymbol{\theta}\mid\boldsymbol{x})d\boldsymbol{\theta} +$$
+ +
$$ +\Longrightarrow\hat{\theta}=\begin{bmatrix}\theta_1p(\theta|x)d\theta\\\int\theta_2p(\theta|x)d\theta\\\vdots\\\int\theta_pp(\theta|x)d\theta\end{bmatrix}=\int\theta_P(\theta|x)d\theta=E(\theta|x) +$$
+ +

Woodbury 恒等式:

+
$$ +\left(\mathbf{B}+\boldsymbol{u}\boldsymbol{u}^T\right)^{-1}=\mathbf{B}^{-1}-\frac{\mathbf{B}^{-1}\boldsymbol{u}\boldsymbol{u}^T\mathbf{B}^{-1}}{1+\boldsymbol{u}^T\mathbf{B}^{-1}\boldsymbol{u}} +$$
+ +

贝叶斯风险

$$ +\Re=\iint C(\varepsilon)p(x,\theta)dxd\theta +$$
+ +

二次型误差

$$ +C(\varepsilon) = \begin{pmatrix}\theta-\hat{\theta}\end{pmatrix}^2 +$$
+ +

这就是 MMSE

+

绝对误差

$$ +C(\varepsilon)=\begin{vmatrix}\theta-\hat{\theta}\end{vmatrix} +$$
+ +
+

Leibnitz 准则
$\frac{\partial}{\partial u}\int\limits_{\phi_1(u)}^{\phi_2(u)}h\big(u,v\big)dv=\int\limits_{\phi_1(u)}^{\phi_2(u)}\frac{\partial h\big(u,v\big)}{\partial u}dv+\frac{\partial\phi_2\big(u\big)}{\partial u}h\big(u,\phi_2\big(u\big)\big)-\frac{\partial\phi_1\big(u\big)}{\partial u}h\big(u,\phi_1\big(u\big))$

+
+

此时

+
$$ +\int_{-\infty}^{\hat{\theta}}p\big(\theta|x\big)d\theta=\int_{\hat{\theta}}^{+\infty}p\big(\theta|x\big)d\theta +$$
+ +

成功失败型误差

$$ +C(\varepsilon)=\begin{cases}0,\left|\theta-\hat{\theta}\right|<\delta\\1,\left|\theta-\hat{\theta}\right|\geq\delta\end{cases} +$$
+ +

此时

+
$$ +\hat{\theta}=\arg\max_{\theta}p(\theta|x) +$$
+ +

即 $\hat{\theta}$ 是后验PDF的最大值 (众数)

+

MAP maximum a posteriori

+

根据贝叶斯公式

+
$$ +\hat{\theta}=\arg\max_{\theta}\left\lbracep(x|\theta)p(\theta)\right\rbrace\\ +\hat{\theta}=\arg\max_{\theta}\left\{\ln p\big(x|\theta\big)+\ln p\big(\theta\big)\right\} +$$
+ +

三值比较

一般而言,“三值”并不相等,因此三种估计量往往不同

+

特例:高斯时“三值”相等,三种估计方法等价

+

大数据量时先验信息不起作用,最大后验概率估计(MAP)将转变为(贝叶斯)最大似然估计(MLE)

+

线性贝叶斯估计

线性贝叶斯估计(LMMSE), 也称线性最小意味着:

+
$$ +\hat{\theta}=\sum_{n=0}^{N-1}a_nx[n]+a_N +$$
+ +

即限定估计量与观察数据间呈线性关系,然最小化

+
$$ +\mathrm{Bmse}\Big(\hat{\theta}\Big)=E\Big[\Big(\theta-\hat{\theta}\Big)^{2}\Big] +$$
+ +

即,LMMSE:

+
$$ +\min\left\{E\left[\left(\theta-\hat{\theta}\right)^2\right]\right\}\\s.t.\quad\hat{\theta}=\sum_{n=0}^{N-1}a_nx[n]+a_N +$$
+ +

解得估计量:

+
$$ +\hat{\theta}=E\left(\theta\right)+\mathbf{C}_{\theta x}\mathbf{C}_{xx}^{-1}\left(x-E\left(x\right)\right)\\\mathrm{Bmse}\left(\hat{\theta}\right)=\mathbf{C}_{\theta\theta}-\mathbf{C}_{\theta x}\mathbf{C}_{xx}^{-1}\mathbf{C}_{x\theta} +$$
+ +

对比 MMSE:

+

附加了线性约束

+
    +
  • 可得显示解——好求
  • +
  • 仅需一阶矩和二阶矩
  • +
+

无附加约束

+
    +
  • 可能难以求得显示解
  • +
  • 需PDF
  • +
  • 全局最优
  • +
  • 仅在“线性”中最优
  • +
+

矢量参数情况

待估计参数$\boldsymbol{\theta}=\begin{bmatrix}\theta_1,\theta_2,…,\theta_p\end{bmatrix}^T$,其每个参数的 LMMSE 定义为

+
$$ +\begin{aligned}&\min E\bigg[\bigg(\theta_{i}-\hat{\theta}_{i}\bigg)^{2}\bigg]\\&s.t.\hat{\theta}_{i}=\sum_{n=0}^{N-1}a_{in}x[n]+a_{iN}\end{aligned} +$$
+ +
$$ +\hat{\boldsymbol{\theta}}=\begin{bmatrix}E(\theta_1)\\E(\theta_2)\\\vdots\\E(\theta_p)\end{bmatrix}+\begin{bmatrix}\mathbf{C}_{\theta_1x}\mathbf{C}_{xx}^{-1}\left(\boldsymbol{x}-E(\boldsymbol{x})\right)\\\mathbf{C}_{\theta_2x}\mathbf{C}_{xx}^{-1}\left(\boldsymbol{x}-E(\boldsymbol{x})\right)\\\vdots\\\mathbf{C}_{\theta_px}\mathbf{C}_{xx}^{-1}\left(\boldsymbol{x}-E(\boldsymbol{x})\right)\end{bmatrix}\\ +=E\left(\boldsymbol{\theta}\right)+\mathbf{C}_{\theta x}\mathbf{C}_{xx}^{-1}\left(\boldsymbol{x} - E(\boldsymbol{x})\right) +$$
+ +

序贯LMMSE

白噪声电平估计

+
$$ +x[n]=A+w[n],n=0,1,...,N +$$
+ +
$$ +A\sim N\big(0,\sigma_{A}^{2}\big)\\ +w[n]\sim N\left(0,\sigma^{2}\right) +$$
+ +

解得

+
$$ +\begin{aligned} +&E(\theta)=0 \\ +&\mathbf{C}_{\theta x}=E\left(\left(\theta-E\left(\theta\right)\right)\left(x-E\left(x\right)\right)^{T}\right) \\ +&=E\left(\left(A-0\right)\left(x-0\right)^{T}\right) \\ +&=E\Big(A\big(A\mathbf{1}+\mathbf{w}\big)^{T}\Big) \\ +&=\sigma_{A}^{2}\mathbf{1}^{T} +\end{aligned}\\ +\begin{aligned} +\mathbf{C}_{xx}& =E\left(\left(x-E\left(x\right)\right)\left(x-E\left(x\right)\right)^T\right) \\ +&=E\left(\left(A\mathbf{1}+\boldsymbol{w}\right)\left(A\mathbf{1}+\boldsymbol{w}\right)^T\right) \\ +&=E\left\{A\mathbf{1}\mathbf{1}^TA+A\mathbf{1}\boldsymbol{w}^T+\boldsymbol{w}\mathbf{1}^TA+\boldsymbol{w}\boldsymbol{w}^T\right\} \\ +&=\sigma_A^2\mathbf{1}\mathbf{1}^T+\sigma^2\mathbf{I} +\end{aligned}\\ +\begin{aligned}\mathbf{C}_{\theta\theta}&=\sigma_A^2\\\mathbf{C}_{x\theta}&=\mathbf{C}_{\theta x}^T\\&=\sigma_A^2\mathbf{1}\end{aligned} +$$
+ +
$$ +\begin{aligned}\hat{A}&=\frac{\sigma_{A}^{2}}{\sigma_{A}^{2}+\frac{\sigma^{2}}{N}}\\\mathrm{Bmse}&\left(\hat{A}\right)=\frac{1}{N}\end{aligned} +$$
+ +

+
$$ +\hat{A}[N-1]=\frac{\sigma_A^2}{\sigma_A^2+\frac{\sigma^2}{N}}\frac{1}{N}\sum_{n=0}^{N-1}x[n] +$$
+ +

+
$$ +\hat{A}[N]=\hat{A}[N-1]+\underbrace{\frac{\sigma_A^2}{\left(N+1\right)\sigma_A^2+\sigma^2}}_{K[N],增益因子}\Big(x[N]-\hat{A}[N-1]\Big) +$$
+ +
$$ +\frac{\frac1{\sigma^2}}{\frac1{\mathrm{Bmse}\left(\hat{A}\left[N-1\right]\right)}+\frac1{\sigma^2}}=\frac{\mathrm{Bmse}\left(\hat{A}\left[N-1\right]\right)}{\mathrm{Bmse}\left(\hat{A}\left[N-1\right]\right)+\sigma^2}\\=\frac{\frac{\sigma_A^2\sigma^2}{N\sigma_A^2+\sigma^2}}{\frac{\sigma_A^2\sigma^2}{N\sigma_A^2+\sigma^2}+\sigma^2}=\frac{\sigma_A^2}{\left(N\sigma_A^2+\sigma^2\right)+\sigma_A^2}=K\begin{bmatrix}N\end{bmatrix} +$$
+ +

一般方法

+

序贯计算方法估计量更新:

+
$$ +\hat{A}[N]=\hat{A}[N-1]+K[N]\Big(x[N]-\hat{A}[N-1]\Big) +$$
+ +

增益因子:

+
$$ +K\left[N\right]=\frac{\mathrm{Bmse}\left(\hat{A}\left[N-1\right]\right)}{\mathrm{Bmse}\left(\hat{A}\left[N-1\right]\right)+\sigma^2} +$$
+ +

最小贝叶斯MSE更新:

+
$$ +\mathrm{Bmse}\Big(\hat{A}[N]\Big)\boldsymbol{=}\Big(1\boldsymbol{-}K[N]\Big)\mathrm{Bmse}\Big(\hat{A}[N\boldsymbol{-}1]\Big) +$$
+ +

初始化:

+
$$ +\hat{A}[-1]=E(A)\\ +\text{Bmse}\left ( \hat{A} [ - 1] \right ) = \text{var}\left ( A\right ) +$$
+ +

维纳滤波

滤波

假定观测数据是零均值、宽平稳的,信号也是零均值、宽平稳的,信号与噪声不相关

+
$$ +x[n] = s[n] + w[n], n = 0, 1, \dots, N - 1 +$$
+ +
$$ +\theta=s[n]\text{ 用 }x[0],x[1],x[2],...,x[n]\text{来估计}$$
+ +

1713150769252

+

利用 LMMSE 可得

+
$$ +\hat{s}[n]=r_{ss}^{'T}\left(\mathbf{R}_{ss}+\mathbf{R}_{ww}\right)^{-1}\boldsymbol{x} +$$
+ +

从而得到维纳-霍夫滤波方程

+
$$ +\begin{bmatrix}r_{xx}\begin{bmatrix}0\end{bmatrix}&r_{xx}\begin{bmatrix}1\end{bmatrix}&\cdots&r_{xx}\begin{bmatrix}n\end{bmatrix}\\r_{xx}\begin{bmatrix}1\end{bmatrix}&r_{xx}\begin{bmatrix}0\end{bmatrix}&\cdots&r_{xx}\begin{bmatrix}n-1\end{bmatrix}\\\vdots&\vdots&\ddots&\vdots\\r_{xx}\begin{bmatrix}n\end{bmatrix}&r_{xx}\begin{bmatrix}n-1\end{bmatrix}&\cdots&r_{xx}\begin{bmatrix}0\end{bmatrix}\end{bmatrix}\begin{bmatrix}h^{(n)}\begin{bmatrix}0\end{bmatrix}\\h^{(n)}\begin{bmatrix}1\end{bmatrix}\\\vdots\\h^{(n)}\begin{bmatrix}n\end{bmatrix}\end{bmatrix}=\begin{bmatrix}r_{ss}\begin{bmatrix}0\end{bmatrix}\\r_{ss}\begin{bmatrix}1\end{bmatrix}\\\vdots\\r_{ss}\begin{bmatrix}n\end{bmatrix}\end{bmatrix} +$$
+ +

平滑

$$ +\theta=s[n]\text{用 }...,x[-1],x[0],x[1],x[2],...,\text{来估计} +$$
+ +

1713152016025

+

LMMSE:

+
$$ +\hat{s}[n]=\sum_{k=-\infty}^\infty a_kx[k] +$$
+ +

令 $h[k] = a_{N-k}$

+
+

正交原理:误差与每一个观测数据正交

+
$$ +E\left(\left(\theta-\hat{\theta}\right)x[m]\right)=0 +$$
+正交原理不依赖于任务是平滑、滤波还是预测,是普遍适用的,证明如下: +![1713152987612](../images/StaSP/1713152987612.png) +![1713152970273](../images/StaSP/1713152970273.png) +在 LMMSE +
+
$$ +\hat{s}[n]=\sum_{k=-\infty}^\infty a_kx[k] +$$
+ +

中令 $h[k]=a_{n-k}$

+

则有

+
$$ +\hat s[n] = \sum\limits_{k=-\infty}^{\infty}h[k]x[n-k] +$$
+ +

可得

+
$$ +r_{ss}\begin{bmatrix}n\end{bmatrix}=h\begin{bmatrix}n\end{bmatrix}*r_{xx}\begin{bmatrix}n\end{bmatrix} +$$
+ +

无限维纳平滑器的频率响应

+
$$ +H\left(f\right)=\frac{P_{ss}\left(f\right)}{P_{xx}\left(f\right)}\quad=\frac{P_{ss}\left(f\right)}{P_{ss}\left(f\right)+P_{ww}\left(f\right)}\quad=\frac{\eta\left(f\right)}{\eta\left(f\right)+1}\quad\text{,其中 }\eta\left(f\right)=\frac{P_{ss}\left(f\right)}{P_{ww}\left(f\right)} +$$
+ +

预测

可以用来进行预测

+
$$ +\theta=x[N-1+l]\text{ 用 }x[0],x[1],x[2],...,x[N-1]\text{ 来估计} +$$
+ +

1713150674892

+

依然用 LMMSE 可以得到线性预测维纳-霍夫滤波方程

+
$$ +\begin{bmatrix}r_{xx}\begin{bmatrix}0\end{bmatrix}&r_{xx}\begin{bmatrix}1\end{bmatrix}&\cdots&r_{xx}\begin{bmatrix}N-1\end{bmatrix}\\r_{xx}\begin{bmatrix}1\end{bmatrix}&r_{xx}\begin{bmatrix}0\end{bmatrix}&\cdots&r_{xx}\begin{bmatrix}N-2\end{bmatrix}\\\vdots&\vdots&\ddots&\vdots\\r_{xx}\begin{bmatrix}N-1\end{bmatrix}&r_{xx}\begin{bmatrix}N-2\end{bmatrix}&\cdots&r_{xx}\begin{bmatrix}0\end{bmatrix}\end{bmatrix}\begin{bmatrix}h\begin{bmatrix}1\end{bmatrix}\\h\begin{bmatrix}2\end{bmatrix}\\\vdots\\h\begin{bmatrix}N\end{bmatrix}\end{bmatrix}=\begin{bmatrix}r_{xx}\begin{bmatrix}l\end{bmatrix}\\r_{xx}\begin{bmatrix}l+1\end{bmatrix}\\\vdots\\r_{xx}\begin{bmatrix}N-1+l\end{bmatrix}\end{bmatrix} +$$
+ +

应用

信道均衡问题

+

1713151589324

+

卡尔曼滤波

如何估计电压?

+

模型 1:当成确定参数

$$ +x[n] = A + w[n], w[n] \sim N(0, \sigma^{2}) +$$
+ +
$$ +\hat A = \sum\limits_{n=0}^{N - 1}x[n] = \bar x +$$
+ +

模型2:当成某个随机变量

$$ +x[n] = A + w[n], w[n] \sim N(0, \sigma^{2}), A \sim N(\mu_A, \sigma_A^{2}) +$$
+ +

贝叶斯一般线性模型:

+
$$ +\boldsymbol{x}=\mathbf{H}\boldsymbol{\theta}+\boldsymbol{w}\quad\text{其中 }\boldsymbol{\theta}{\sim}N\begin{pmatrix}\boldsymbol{\mu}_\theta,\mathbf{C}_\theta\end{pmatrix}\text{,}\boldsymbol{w}{\sim}N\begin{pmatrix}\boldsymbol{0},\mathbf{C}_w\end{pmatrix}\\ +E\left(\boldsymbol{\theta}\mid\boldsymbol{x}\right)=E\left(\boldsymbol{\theta}\right)+\mathbf{C}_{\theta x}\mathbf{C}_{xx}^{-1}\left(\boldsymbol{x}-E\left(\boldsymbol{x}\right)\right)=\boldsymbol{\mu}_\theta+\mathbf{C}_{\theta|x}\mathbf{H}^T\mathbf{C}_w^{-1}\left(\boldsymbol{x}-\mathbf{H}\boldsymbol{\mu}_\theta\right)\\ +\text{其中,}\mathbf{C}_{\theta|x}=\left(\mathbf{C}_\theta^{-1}+\mathbf{H}^T\mathbf{C}_w^{-1}\mathbf{H}\right)^{-1} +$$
+ +
$$ +\hat{A}=\mu_A+\frac{\frac1{\sigma^2/N}}{\frac1{\sigma_A^2}+\frac1{\sigma^2/N}}(\overline{x}-\mu_A) +$$
+ +

模型3:当成未知且随时间变化的量

$$ +x[n]=A[n]+w[n],n=0,1,...,N-1 +$$
+ +
$$ +\mathrm{MVU}\text{估计量:}\hat{\boldsymbol{\theta}}=\left(\mathbf{H}^T\mathbf{H}\right)^{-1}\mathbf{H}^T\boldsymbol{x}\\ +\begin{aligned}&\boldsymbol{\theta}=&\begin{bmatrix}A[0],A[1],...,A[N-1]\end{bmatrix}^T\\&\mathbf{H}=\mathbf{I}\end{aligned}\\ +\hat{A}[n]=x[n] +$$
+ +

动态信号模型

一阶高斯-马尔可夫信号模型:

+
$$ +s[n]=as[n-1]+u[n],n\geq0 +$$
+ +

其中,$u[n]$是均值为零方差为 $\sigma_u^2$ 的高斯白噪声,称为驱动噪声或激励噪声。信号初值s$[-1]\sim N(\mu_s,\sigma_s^2)$与激励噪声$u[n]$相互独立。

+

均值:

+
$$ +s[n]=a^{n+1}s[-1]+\sum_{k=0}^na^ku[n-k]\\ +E\left(s[n]\right)=a^{n+1}E\left(s[-1]\right)+\sum_{k=0}^na^kE\left(u[n-k]\right)=a^{n+1}\mu_s\\ +c_s[m,n] = a^{m+n+2}\sigma_s^2+\sum_{k=0}^m\sum_{l=0}^na^{k+l}E\left(u[m-k]u[n-l]\right)\\ +E\left(u[m-k]u[n-l]\right)=\begin{cases}\sigma_u^2,&l=n-m+k\\0,&\mathrm{others}\end{cases} +$$
+ +

协方差:

+
$$ +m \ge n, c_s\left[m,n\right]=a^{m+n+2}\sigma_s^2+\sum_{k=m-n}^ma^{2k+n-m}\sigma_u^2=a^{m+n+2}\sigma_s^2+\sigma_u^2a^{m-n}\sum_{k=0}^na^{2k}\\ +m \lt n, c_s\begin{bmatrix}m,n\end{bmatrix}=a^{m+n+2}\sigma_s^2+\sum_{k=0}^ma^{2k+n-m}\sigma_u^2=a^{m+n+2}\sigma_s^2+\sigma_u^2a^{n-m}\sum_{k=0}^ma^{2k}=c_s\begin{bmatrix}n,m\end{bmatrix} +$$
+ +

方差和二阶矩:

+
$$ +\begin{aligned} +\operatorname{var}(s[n])& =E\left(\left(s[n]-E\left(s[n]\right)\right)\left(s[n]-E\left(s[n]\right)\right)\right) \\ +&=c_s[n,n] \\ +&=a^{2n+2}\sigma_s^2+\sigma_u^2\sum_{k=0}^na^{2k} +\end{aligned}\\ +\text{当 }m\geq n\text{ 时}\\r_{ss}\left[m,n\right]=a^{m+n+2}\left(\mu_{s}^{2}+\sigma_{s}^{2}\right)+\sigma_{u}^{2}a^{m-n}\sum_{k=0}^{n}a^{2k}\\\text{当 }m + +

平稳性

$$ +\begin{aligned}&E\left(s\left[n\right]\right)=a^{n+1}\mu_s\\&r_{ss}\left[m,n\right]=a^{m+n+2}\left(\mu_s^2+\sigma_s^2\right)+\sigma_u^2a^{m-n}\sum_{k=0}^na^{2k}\end{aligned} +$$
+ +

不是宽平稳的。

+

通常要求 $|a| \lt 1$,当取 $n \rarr \infty$ 时

+
$$ +\begin{aligned}&E\left(s\left[n\right]\right)=0\\&r_{ss}\left[m,n\right]=a^{m+n+2}\left(\mu_s^2+\sigma_s^2\right)+\sigma_u^2a^{m-n}\frac{1-a^{2n+2}}{1-a^2}=\frac{\sigma_u^2a^{m-n}}{1-a^2}=r_{ss}\left[k\right]\end{aligned} +$$
+ +

此时是宽平稳(WSS)的。

+

递推特性

$$ +E\left(s[n]\right)=aE\left(s[n-1]\right)+E\left(u[n]\right)=aE\left(s[n-1]\right) +$$
+ +
$$ +\operatorname{var}\left(s[n]\right)=E\left(\left(s[n]-E(s[n])\right)\left(s[n]-E(s[n])\right)\right) = a^2\operatorname{var}\left(s[n-1]\right)+\sigma_u^2 +$$
+ +
$$ +m \ge n, c_s\left[m,n\right]=a^{m-n}\operatorname{var}\left(s[n]\right) = a^{m-n}\left(a^{2n+2}\sigma_s^2+\sigma_u^2\sum_{k=0}^na^{2k}\right)\\ +m \le n, c_s\left[m,n\right]=c_s\left[n,m\right]=a^{n-m}\operatorname{var}\left(s\left[m\right]\right) +$$
+ +

卡尔曼滤波

状态方程:$s[n]=as\left[n-1\right]+u\left[n\right]$

+

观测方程:$x[n]=s\left[n\right]+w[n]$

+

驱动噪声 $u[n]$ 相互独立且 $u[n] \sim N(0, \sigma^2)$,观测噪声 $w[n]$ 相互独立且 $w[n] \sim N(0, \sigma^2)$,起始条件 $s[-1] \sim N(0, \sigma_s^2)$。假定 $s[-1], u[n], w[n]$ 之间相互独立。

+
    +
  • 提高估计性能:利用待估计参数的内在联系提高性能
  • +
  • 减小运算量:通过“老”估计量更新得到“新”估计量
  • +
+

性质:

+

对联合高斯独立数据矢量可加性:

+

若$\theta,x_1,x_2$是联合高斯的,数据矢量$x_1,x_2$ 相互独立,则MMSE估计量为:

+
$$ +\hat{\theta}=E\left(\boldsymbol{\theta}\right)+\mathbf{C}_{\theta x_1}\mathbf{C}_{x_1x_1}^{-1}\left(\boldsymbol{x}_1-E\left(\boldsymbol{x}_1\right)\right)+\mathbf{C}_{\theta x_2}\mathbf{C}_{x_2x_2}^{-1}\left(\boldsymbol{x}_2-E\left(\boldsymbol{x}_2\right)\right) +$$
+ +

对待估计参数的可加性:

+

若 $\boldsymbol{\theta}=\boldsymbol{\theta}_1+\boldsymbol{\theta}_2$, 则相应的MMSE估计量是可加的,即

+
$$ +\hat{\theta}=E\left(\boldsymbol{\theta}\mid\boldsymbol{x}\right)=E\left(\boldsymbol{\theta}_1+\boldsymbol{\theta}_2\mid\boldsymbol{x}\right)=E\left(\boldsymbol{\theta}_1\mid\boldsymbol{x}\right)+E\left(\boldsymbol{\theta}_2\mid\boldsymbol{x}\right) +$$
+ +

线性变换的不变性:

+

若$\alpha=\mathbf{A\theta}+\boldsymbol{b},\quad\theta$ 的MMSE估计量是 $\theta$, 则 $\alpha$ 的MMSE估计量为:

+
$$ +\hat{\alpha}=\mathbf{A}\hat{\theta}+b +$$
+ +

定义:

+
$$ +\hat{s}[n-1]=E\left(s[n-1]|x[0],x[1],...,x[n-1]\right)\triangleq\hat{s}[n-1\mid n-1]\\ +M\begin{bmatrix}n-1\end{bmatrix}=E\left(\left(s\begin{bmatrix}n-1\end{bmatrix}-\hat{s}\begin{bmatrix}n-1\end{bmatrix}\right)^2\right)\\ +\hat s[n] \triangleq\hat{s}[n\mid n] +$$
+ +

其中,前面的 n 表示被估计的信号下表,后面的 n 表示估计量用到的数据中最新的那个数据的下标。

+

如果能够提取出第 n 个数据点带来的新的信息,并加入之前已有的估计量,就可更新估计量:

+
$$ +\begin{aligned} +\hat{s}\Big[n|n\Big]& =E\left(s[n]|x[0],x[1],...,x[n-1],x[n]\right) \\ +&=E\left(s[n]|x[0],x[1],...,x[n-1],\tilde{x}[n]\right) \\ +&=\underbrace{E\left(s[n]|x[0],x[1],...,x[n-1]\right)}_{先前数据估计}+\underbrace{E\left(s[n]|\tilde{x}[n]\right)}_{新息估计} +\end{aligned} +$$
+ +

新息与已有的数据正交。

+
$$ +\tilde{x}[n]=x[n]-\hat{x}[n|n-1] +$$
+ +

“先前数据估计”怎么求解?

+
$$ +\begin{aligned} +\hat{s}[n\mid n-1]& =E\left(as[n-1]+u[n]|x[0],x[1],...,x[n-1]\right) \\ +&=E\left(as[n-1]|x[0],x[1],...,x[n-1]\right)+E\left(u[n]|x[0],x[1],...,x[n-1]\right) \\ +&=aE\left(s\begin{bmatrix}n-1\end{bmatrix}|x\begin{bmatrix}0\end{bmatrix},x\begin{bmatrix}1\end{bmatrix},...,x\begin{bmatrix}n-1\end{bmatrix}\right)\\ +&=a\hat{s}\begin{bmatrix}n-1|n-1\end{bmatrix} \\ +\end{aligned} +$$
+ +

预测

求解新息

+
$$ +E\left(s[n]|\tilde{x}[n]\right)=E\left(s[n]\right)+\mathbf{C}_{s\tilde{x}}\mathbf{C}_{\tilde{x}\tilde{x}}^{-1}\left(\tilde{x}[n]-E\left(\tilde{x}[n]\right)\right) +$$
+ +
$$ +s[n]=a^{n+1}s[-1]+\sum_{k=0}^na^ku[n-k]\rArr E(s[n]) = 0\\ +$$
+ +
$$ +\begin{gathered} +E\left(\tilde{x}[n]\right)=E\left(x[n]-\hat{x}[n\mid n-1]\right) \\ +E\left(x[n]\right)=E\left(s[n]+w[n]\right)=0 \\ +E\left(\hat{x}[n\mid n-1]\right)=E\left(\sum_{k=0}^{n-1}a[k]x[k]\right) +\end{gathered}\\ +\rArr E\left(\hat{x}[n\mid n-1]\right)=0\\ +\rArr E(\tilde x[n]) = 0 +$$
+ +

因此,

+
$$ +E\left(s[n]|\tilde{x}[n]\right)=\mathbf{C}_{s\tilde{x}}\mathbf{C}_{\tilde{x}\tilde{x}}^{-1}\tilde{x}[n]=\underbrace{\mathbf{C}_{s\tilde{x}}\mathbf{C}_{\tilde{x}\tilde{x}}^{-1}}_{卡尔曼增益}\left(x[n]-\hat{x}[n\mid n-1]\right) +$$
+ +

最小预测 MSE

$\mathbf{C}_{s\tilde{x}}\text{的求解}$

+
$$ +\begin{aligned} +C_{s\tilde{x}}& =E\left(s[n]\tilde{x}[n]\right) \\ +&=E\Big(s[n]\Big(x[n]-\hat{x}\Big[n|n-1\Big]\Big)\Big) +\end{aligned} +$$
+ +

其中

+
$$ +\begin{aligned}\hat{x}\left[n|n-1\right]&=E\left(x[n]|x[0],x[1],...x[n-1]\right)=E\left(s[n]+w[n]|x[0],x[1],...x[n-1]\right)\\&=E\left(s[n]|x[0],x[1],...x[n-1]\right)=\hat{s}\left[n|n-1\right]\end{aligned} +$$
+ +

因此

+
$$ +\begin{aligned} +C_{s\tilde{x}}& =E\left(s[n]\left(s[n]+w[n]-\hat{s}[n|n-1]\right)\right) \\ +&=E\left(s[n]w[n]+s[n]\left(s[n]-\hat{s}[n|n-1]\right)\right) \\ +&=E\Big(s[n]\Big(s[n]-\hat{s}\Big[n|n-1\Big]\Big)\Big)\\ +&=E\left(s[n]\left(s[n]-\hat{s}[n|n-1]\right)\right)-E\left(\hat{s}[n|n-1]\left(s[n]-\hat{s}[n|n-1]\right)\right)\\ +&=E\left(\left(s[n]-\hat{s}[n|n-1]\right)\left(s[n]-\hat{s}[n|n-1]\right)\right)\\ +&\triangleq M\begin{bmatrix}n\mid n-1\end{bmatrix} +\end{aligned} +$$
+ +

求解 $M\begin{bmatrix}n\mid n-1\end{bmatrix}$

+
$$ +\begin{aligned} +&M\begin{bmatrix}n\mid n-1\end{bmatrix}\\ +&=E\left(\left(as\begin{bmatrix}n-1\end{bmatrix}+u\begin{bmatrix}n\end{bmatrix}-\hat{s}\begin{bmatrix}n|n-1\end{bmatrix}\right)^2\right)\\ +&=E\left(\left(a\left(s[n-1]-\hat{s}[n-1\mid n-1]\right)+u[n]\right)^2\right) \\ +&=E\left(a^2\left(s\left[n-1\right]-\hat{s}\left[n-1\mid n-1\right]\right)^2+u^2\left[n\right]+2a\left(s\left[n-1\right]-\hat{s}\left[n-1\mid n-1\right]\right)u\left[n\right]\right) \\ +&=a^2M\left[n-1\mid n-1\right]+\sigma_u^2 +\end{aligned} +$$
+ +

卡尔曼增益

$\mathbf{C}_{\tilde{x}\tilde{x}}\text{的求解}$

+
$$ +\\ +\begin{aligned} +\mathbf{C}_{\tilde{x}\tilde{x}}&=E\left(\left(\tilde{x}[n]-E(\tilde{x}[n])\right)^2\right) = E\left(\tilde{x}^2[n]\right) = E\left(\left(x[n]-\hat{s}[n\mid n-1]\right)^2\right)\\ +&=E\left(\left(s[n]+w[n]-\hat{s}[n\mid n-1]\right)^2\right) \\ +&=E\left(\left(s[n]-\hat{s}[n\mid n-1]\right)^2+w^2\left[n\right]+2\left(s[n]-\hat{s}[n\mid n-1]\right)w[n]\right) \\ +&=M\begin{bmatrix}n\mid n-1\end{bmatrix}+\sigma_n^2 +\end{aligned} +$$
+ +

结合

+
$$ +\begin{aligned}\mathbf{C}_{\tilde{x}\tilde{x}}&=M\begin{bmatrix}n\mid n-1\end{bmatrix}+\sigma_n^2\\\mathbf{C}_{s\tilde{x}}&=M\begin{bmatrix}n\mid n-1\end{bmatrix}\end{aligned} +$$
+ +

我们得到了卡尔曼增益

+
$$ +E\left(s[n]|\tilde{x}[n]\right)=\underbrace{\frac{M\left[n\mid n-1\right]}{M\left[n\mid n-1\right]+\sigma_n^2}}_{卡尔曼增益 K[n]}\tilde{x}[n] +$$
+ +

修正

$$ +\hat{s}\left[n\mid n\right]=\underbrace{\hat{s}\left[n\mid n-1\right]}_{预测}+\underbrace{K\left[n\right]\left(x\left[n\right]-\hat{s}\left[n\mid n-1\right]\right)}_{新息修正} +$$
+ +

最小 MSE

MSE 修正:

+
$$ +M[n|n] = (1 - K[n])M[n|n - 1] +$$
+ +

非零均值信号模型

1714360809348

+

初始化:$\hat{s} [ - 1|- 1] = E\begin{pmatrix} s[ - 1] \end{pmatrix} = \mu _s$ $M[ - 1|- 1] = E\left ( \begin{pmatrix} s[ - 1] - \hat{s} [ - 1|- 1] \end{pmatrix} ^2\right ) = \sigma _s^2$

+

估计量预测:$\hat{s}[n|n-1]=a\hat{s}[n-1|n-1]$

+

MSE预测:$M\left[n\mid n-1\right]=a^2M\left[n-1\mid n-1\right]+\sigma_u^2$

+

卡尔曼增益:$K[n]=\frac{M\left[n|n-1\right]}{M\left[n|n-1\right]+\sigma_n^2}$

+

估计量修正:$\hat{s}[n|n]=\hat{s}[n|n-1]+K[n]\left(x[n]-\hat{s}[n|n-1]\right)$

+

MSE修正: $M\left [ n\mid n\right ] = \left ( 1- K\left [ n\right ] \right ) M\left [ n\mid n- 1\right ]$

+

矢量状态-标量观测信号模型

1714360717248

+

矢量状态-矢量观测信号模型

1714360742651

+

非线性信号模型

1714360782259

+

1714361011137

+

1714361027958

+

总结

    +
  • 不同时刻的待估计参数并不完全一样,但是存在某些内在联系
  • +
  • 卡尔曼滤波利用这种联系进行 LMMSE 估计,并减少了运算量
  • +
  • 如果信号与噪声是高斯的,则卡尔曼滤波在 MMSE 准则下最佳,否则,在 LMMSE 准则下是最佳的。
  • +
+

信号检测基本准则与方法

之前一直在研究连续型的问题(回归/估计),这里研究离散型的问题(分类/检测)。

+

Neyman-Pearson 准则

适用于没有先验信息、代价不好量化的场景。

+

两种假设:

+
$$ +\begin{aligned}&H_0:x[n]=w[n],n=0,1,...,N-1\\&H_1:x[n]=s[n]+w[n],n=0,1,...,N-1\end{aligned} +$$
+ +
$$ +\begin{aligned} +&P\left(H_1;H_0\right):\text{ 虚警概率}\left(P_{FA},\text{有时简记为}P_F\right)\\ +&P\left(H_0;H_1\right):\text{ 漏检概率 }\left(P_M\right)\\ +&P\left(H_1;H_1\right):\text{ 检测概率 }\left(P_D\right)\end{aligned} +$$
+ +

要求:在虚警概率一定情况下,使检测概率最大化

+

检测概率和虚警概率之间追求折中,不可能两者都改善。

+

对给定的虚警概率 $P_{FA}=\alpha$ ,使检测概率 $P_D$ 最大的判决为

+
$$ +L(x)=\frac{p(x;H_1)}{p(x;H_0)}>\gamma +$$
+ +

其中门限由 $P_{FA}=\int_{\lbrace\mathbf{x}:L(\mathbf{x})>\gamma\rbrace}p(\boldsymbol{x};H_0)d\boldsymbol{x}=\alpha$ 决定

+

对于信号检测问题:

+
$$ +H_0:\boldsymbol{x}\sim N\left(\boldsymbol{0},\sigma^2\mathbf{I}\right)\\H_1:\boldsymbol{x}\sim N\left(A\mathbf{1},\sigma^2\mathbf{I}\right) +$$
+ + +

NP 检测器:

+
$$ +\frac{p\left(\boldsymbol{x};H_1\right)}{p\left(\boldsymbol{x};H_0\right)}=\frac{\frac1{\left(2\pi\sigma^2\right)^{N/2}}\exp\left\{-\frac1{2\sigma^2}\sum_{n=0}^{N-1}\left(x[n]-A\right)^2\right\}}{\frac1{\left(2\pi\sigma^2\right)^{N/2}}\exp\left\{-\frac1{2\sigma^2}\sum_{n=0}^{N-1}x^2[n]\right\}}>\gamma\\\quad\exp\left\{-\frac1{2\sigma^2}\sum_{n=0}^{N-1}\left(x[n]-A\right)^2+\frac1{2\sigma^2}\sum_{n=0}^{N-1}x^2[n]\right\}>\gamma +$$
+ +
$$ +-\frac1{2\sigma^2}\Bigg(-2A\sum_{n=0}^{N-1}x[n]+NA^2\Bigg)>\ln\gamma\\\frac1N\sum_{n=0}^{N-1}x[n]>\frac{\sigma^2}{NA}\ln\gamma+\frac A2 +$$
+ +

称为检测统计量。若均值大于门限,则判为有信号,否则为无信号。

+

使用方法:

+
$$ +\begin{aligned} +&\text{检测统计量:}T(x)=\frac1N\sum_{n=0}^{N-1}x[n]\sim\begin{cases}N\Big(0,\sigma^2\Big/_N\Big),&H_0\\[2ex]N\Big(A,\sigma^2\Big/_N\Big),&H_1\end{cases} \\ +&\text{虚警概率:}P_{FA}=Pr\left(T\left(\boldsymbol{x}\right)>\gamma^{'};H_0\right)=Q\left(\frac{\gamma^{'}}{\sqrt{\sigma^2/N}}\right) \\ +&\text{门限设置:}\gamma^{\prime}=\sqrt{\frac{\sigma^2}N}Q^{-1}\left(P_{FA}\right) \\ +& \begin{aligned}&\text{相应的检测概率:}\\&P_{D}=Pr\Big(T\big(\boldsymbol{x}\big)>\gamma^{'};H_{1}\Big)=Q\Bigg(\frac{\gamma^{'}-A}{\sqrt{\sigma^{2}/N}}\Bigg)=Q\Bigg(\frac{\sqrt{\frac{\sigma^{2}}{N}}Q^{-1}\big(P_{FA}\big)-A}{\sqrt{\sigma^{2}/N}}\Bigg)\end{aligned} \\ +&=Q\Bigg(Q^{-1}\big(P_{F_A}\big)-\sqrt{\frac{NA^2}{\sigma^2}}\Bigg) +\end{aligned} +$$
+ +

检测性能分析

接收机工作特性曲线(ROC, receiver operating characteristics)

+

1714966200160

+

直观理解:

+

1714966230536

+

多次观测的好处

+
    +
  • 从数学角度:不同假设下的pdf分隔更开,更易区分不同假设
  • +
  • 从信号处理角度:增加信号预检测积分时间,获得更多的能量用于检测
  • +
  • 从信息论角度:多的观测数据带来了新的信息
  • +
+

最小错误概率准则

$$ +\begin{aligned} +P_{e}& =\Pr\left\{\text{判}H_0,H_1\text{为真}\right\}+\Pr\left\{\text{判}H_1,H_0\text{为真}\right\} \\ +&=P\big(H_0,H_1\big)+P\big(H_1,H_0\big) \\ +&=P\big(H_1\big)P\big(H_0|H_1\big)+P\big(H_0\big)P\big(H_1|H_0\big) \\ +&=P\big(H_1\big)\int_{R_0}p\big(\boldsymbol{x}|H_1\big)d\boldsymbol{x}+P\big(H_0\big)\int_{R_1}p\big(\boldsymbol{x}|H_0\big)d\boldsymbol{x} \\ +&=P\big(H_1\big)\Bigg(1-\int_{R_1}p\big(\boldsymbol{x}\mid H_1\big)d\boldsymbol{x}\Bigg)+P\big(H_0\big)\int_{R_1}p\big(\boldsymbol{x}\mid H_0\big)d\boldsymbol{x} \\ +&=P\left(H_1\right)+\int_{R_1}\left\{P\left(H_0\right)p\left(\boldsymbol{x}\mid H_0\right)-P\left(H_1\right)p\left(\boldsymbol{x}\mid H_1\right)\right\}d\boldsymbol{x} +\end{aligned} +$$
+ +

为了使错误最小,需要在积分式小于零的区域积分,即

+
$$ +\frac{p\left(\boldsymbol{x}\mid H_1\right)}{p\left(\boldsymbol{x}\mid H_0\right)}>\frac{P\left(H_0\right)}{P\left(H_1\right)}\text{ 时,判 }H_1 +$$
+ +

最小错误概率准则可推导出最大后验概率检测器:

+
$$ +\frac{p\left(\boldsymbol{x}\mid H_1\right)}{p\left(\boldsymbol{x}\mid H_0\right)}>\frac{P\left(H_0\right)}{P\left(H_1\right)}\text{ 时,判 }H_1 +$$
+ +

等价于

+
$$ +\frac{p\left(\boldsymbol{x}\mid H_1\right)P\left(H_1\right)}{p\left(\boldsymbol{x}\right)}>\frac{p\left(\boldsymbol{x}\mid H_0\right)P\left(H_0\right)}{p\left(\boldsymbol{x}\right)}\\p\left(H_1\mid\boldsymbol{x}\right)>p\left(H_0\mid\boldsymbol{x}\right) +$$
+ +

若先验概率相同,则为最大似然检测器:

+
$$ +p\left(x\mid H_1\right)>p\left(x\mid H_0\right) +$$
+ +

二元贝叶斯风险准则

引入判错代价

+
$$ +R=C_{01}P\left(H_1\right)P\left(H_0\mid H_1\right)+C_{10}P\left(H_0\right)P\left(H_1\mid H_0\right) +$$
+ +

进一步泛化:

+
$$ +R=C_{00}P\big(H_0\big)P\big(H_0|H_0\big)+C_{10}P\big(H_0\big)P\big(H_1|H_0\big)\\+C_{01}P\big(H_1\big)P\big(H_0|H_1\big)+C_{11}P\big(H_1\big)P\big(H_1|H_1\big) +$$
+ +
$$ +\begin{aligned}\text{R}&=C_{00}P\left(H_0\right)+C_{01}P\left(H_1\right)\\&+\int_{R_1}\left\{\left(C_{10}-C_{00}\right)P\left(H_0\right)p\left(\boldsymbol{x}\mid H_0\right)-\left(C_{01}-C_{11}\right)P\left(H_1\right)p\left(\boldsymbol{x}\mid H_1\right)\right\}d\boldsymbol{x}\end{aligned} +$$
+ +

因此,有了最小贝叶斯风险判决准则:

+
$$ +\frac{p\left(\boldsymbol{x}\mid H_1\right)}{p\left(\boldsymbol{x}\mid H_0\right)}>\frac{\left(C_{10}-C_{00}\right)P\left(H_0\right)}{\left(C_{01}-C_{11}\right)P\left(H_1\right)}\text{ 时,判 }H_1 +$$
+ +

风险一致条件下($C_{00}=C_{11}=0,C_{10}=C_{01}=1$),回到最小错误概率准则。

+

多元贝叶斯风险准则

贝叶斯风险:

+
$$ +\begin{aligned} +\text{R}& =\sum_{i=0}^{M-1}\sum_{j=0}^{M-1}C_{ij}P\Big(H_i,H_j\Big) \\ +&=\sum_{i=0}^{M-1}\sum_{j=0}^{M-1}C_{ij}\int_{R_i}P\Big(x,H_j\Big)dx \\ +&=\sum_{i=0}^{M-1}\int_{R_i}\sum_{j=0}^{M-1}C_{ij}P\Big(x,H_j\Big)dx \\ +&=\sum_{i=0}^{M-1}\int_{R_i}\sum_{j=0}^{M-1}C_{ij}P\Big(H_j\mid x\Big)p(x)dx +\end{aligned} +$$
+ + +

应选择使平均风险$C_i\left(\boldsymbol{x}\right)=\sum_{j=0}^{M-1}C_{ij}P\left(H_j\mid\boldsymbol{x}\right)$最小的假设

+

在风险一致条件下

+
$$ +C_{ij}=\begin{cases}0,&i=j\\1,&i\neq j\end{cases} +$$
+ +
$$ +\begin{aligned}C_{i}\left(\boldsymbol{x}\right)&=\sum_{j=0\atop j\neq i}^{M-1}P\Big(H_j\mid\boldsymbol{x}\Big)\\&=\sum_{j=0}^{M-1}P\Big(H_j\mid\boldsymbol{x}\Big)-\underline{P\Big(H_i\mid\boldsymbol{x}\Big)}_{最大化这个}\end{aligned} +$$
+ +

因此等价于最大后验准则:

+
$$ +\max_iP(H_i\mid\boldsymbol{x}) +$$
+ +

若此时先验概率相同,则为最大似然准则。

+
\ No newline at end of file diff --git a/2024/02/28/Speech-SP/index.html b/2024/02/28/Speech-SP/index.html new file mode 100644 index 00000000..cc9aa62c --- /dev/null +++ b/2024/02/28/Speech-SP/index.html @@ -0,0 +1,485 @@ +Speech-SP | Guo_Yun + + + + + + + + + + + + + + + + + + + + + +

Speech-SP

语音信号的线性预测编码技术

线性预测编码技术(维纳滤波)。可以参考隔壁统计信号处理的笔记hh。

+

维纳滤波的正交原理:

+
$$ +E \langle x(n-k), e(n) \rangle = 0 +$$
+ +

正交原理可以用来估计任何时候的任何值,不管是现在(滤波),过去(平滑)还是未来(预测),也不管估计的对象是 $x,y$,上述公式的含义是:估计误差始终与已知信号垂直,与估计的是哪个时间的信号无关。

+

利用前面的 $P$ 个信号预测下一个信号:

+
$$ +\hat{s}(n)=-\sum_{i=1}^{P^{\prime}}\hat{\alpha}_i\cdot s(n-i) +$$
+ +

误差定义为

+
$$ +\begin{aligned} +\varepsilon(n)& =s(n)-\overset{\wedge}{\operatorname*{s}}(n)=s(n)+\sum_{i=1}\widehat{\alpha}_i\cdot s(n-i) \\ +&=\sum_{i=0}^{P^{\prime}}\widehat{\alpha}_i\cdot s(n-i) +\end{aligned} +$$
+ +

从 z 域看,这是一个全极点模型产生了目标信号:

+
$$ +S(z) = -S(z)\sum\limits_{i=1}^{P}\alpha_iz^{-i} + E(z) +$$
+ +

接下来的所有步骤,目的都是推导 $\alpha$ 的取值。

+

自相关法

本文中假设信号具有遍历性,即时间平均等于统计平均,时间上的自相关等于统计意义上的自相关。

+

利用 LMMSE 准则可以推出

+
$$ +\begin{bmatrix}R(0)&R(1)&R(2)&\cdots&R(P-1)\\R(1)&R(0)&R(1)&\cdots&R(P-2)\\R(2)&R(1)&R(0)&\cdots&R(P-3)\\\vdots&\vdots&&&\vdots\\R(P-1)&R(P-2)&\cdots&\cdots&R(0)\end{bmatrix}\cdot\begin{bmatrix}\hat\alpha_1\\\hat\alpha_2\\\vdots\\\vdots\\\hat\alpha_P\end{bmatrix}=-\begin{bmatrix}R(1)\\R(2)\\\vdots\\\vdots\\R(P)\end{bmatrix} +$$
+ +

一个例子:Durbin 递推算法

+

协方差法

不能保证声码器稳定

+

Durbin 递推算法

滤波器的内积

定义$s_w(n)$关于$F(z)$和$G(z)$的内积如下:

+
$$ +\langle F(z),G(z)\rangle=\sum_{-\infty}^{+\infty}u(n)\cdot v(n) +$$
+ +

特别地若这里的$F(z),\quad G(z)$都用我们的逆滤波器$A(z)=\sum_{i=0}^P\alpha_iZ^{-i}$替换,那么语音信号$s_w(n)$经过$A(z)$后的输出$e(n)$就是预测误差。

+

$\alpha_i\cdot s_W(n-i)$ 因此$A(z)$范数$|A(z)|$的平方就是预测误差。即

+
$$ +\|A(z)\|^2=\langle A(z),A(z)\rangle=\sum_{-\infty}^{+\infty}e(n)\cdot e(n)=\sum_{-\infty}^{+\infty}e^2(n) +$$
+ +

内积有正定性,线性,三角不等式

+

特殊性质:

+
$$ +\langle z^{-i}, z^{-j} \rangle = R(|i - j|)\\ +\langle F(z), G(z) \rangle = \sum\limits_{i=0}^{M}\sum\limits_{j=0}^{M}f_ig_jR(|i - j|)\\ +\langle F(z),G(z)\rangle=\left\langle z^kF(z),z^kG(z)\right\rangle\\ +\langle F(z),G(z)\rangle=\langle F(1/z),G(1/z)\rangle +$$
+ +

逆滤波器

定义FIR滤波器$\hat{A}(z)$:

+
$$ +\hat{A}(z)=\sum_{i=0}^P\hat{\alpha}_iz^{-i}\quad,\quad\alpha_0=1 +$$
+ +

若$\hat{\alpha}_{i}$是满足LPC正则方程的解,则称$\hat{A}(z)$称为逆滤波器。$\hat{E}(z)=\hat{A}(z)\cdot S(z)$是预测误差$\varepsilon(n)$的z 变换。显然有:

+

(1) 若s(n)是由全极点模型$1/A(z)$产生的,这时$A(z)=\sum_{i=0}^P\alpha_iz^{-i}$, 即:

+

$s(n)=-\sum_{i=1}^P\alpha_is(n-i)+Ge(n)$

+
$$ +S(z) \cdot A(z) = G \cdot E(z) +$$
+ +

前向和后向预测

前向线性预测器(P阶)

+
$$ +\hat{s}(n)=-\sum_{i=1}^P\alpha_i^{(P)}\cdot s(n-i) +$$
+ +

前向预测误差(P阶)

+
$$ +\varepsilon_\alpha^{(P)}(n)=s(n)-\hat{s}(n)=\sum_{i=0}^P\alpha_i^{(P)}\cdot s(n-i)\:,\alpha_0^{(P)}=1 +$$
+ +

前向逆滤波器(P阶)

+
$$ +A^{(P)}(z)=\sum_{i=0}^P\alpha_i^{(P)}z^{-i} +$$
+ +

显然有

+
$$ +E^{(P)}_\alpha(z) = S(z) \cdot A^{(P)}(z) +$$
+ +

后向线性预测器(P阶)

+
$$ +\hat{s}(n-P-1)=-\sum_{i=1}^P\beta_i^{(P)}\cdot s(n-i) +$$
+ +

n时刻对$s(n-P-1)$的后向预测误差(P阶)

+
$$ +\begin{aligned}&\varepsilon_{\beta}^{(P)}(n)=s(n-P-1)-\hat{s}(n-P-1)\\&=\sum_{i=1}^{P+1}\beta_i^{(P)}\cdot s(n-i)\quad,\quad\beta_{P+1}^{(P)}=1\end{aligned} +$$
+ +

后向逆滤波器 (P阶)

+
$$ +B^{(P)}(z)=\sum_{i=1}^{P+1}\beta_i^{(P)}z^{-i} +$$
+ +

显然有

+
$$ +E_\beta^{(P)}(z) = S(z) \cdot B^{(P)}(z) +$$
+ +

正交性原理

判定最佳预测器的充要条件是

+
$$ +\langle A^{(m)}(z), z^{-l} \rangle = 0\\ +\langle B^{(m)}(z), z^{-l} \rangle = 0\\ +l = 1, 2, \dots, m +$$
+ +

一个不严谨的理解:

+
$$ +u(n) = s(n) * Z^{-1}[A(z)] = \varepsilon(n)\\ +v(n) = s(n) * Z^{-1}[z^{-l}] = s(n - l)\\ +\begin{align*} + &\langle A^{(m)}(z), z^{-l} \rangle\\ + =&\sum\limits_{n=-\infty}^{\infty}u(n)v(n)\\ + =&\sum\limits_{n=-\infty}^{\infty}\varepsilon(n)s(n - l)\\ +\end{align*} +$$
+ +

由于时间平均等于统计平均,

+
$$ +\frac1{2N} \sum\limits_{n=-N}^{N - 1}\varepsilon(n)s(n-l) = E \langle \varepsilon(n), s(n-l) \rangle +$$
+ +

根据开头提到的维纳滤波正交原理可知上式等于0。

+

递推公式

根据定义,当$m=0$时,显然有

+
$$ +A^{(0)}(z)=1\\B^{(0)}(z)=z^{-1} +$$
+ +

$m>0$时有如下递推公式(施密特正交化)

+
$$ +A^{(m)}(z)=A^{(m-1)}(z)+K^{(m)}B^{(m-1)}(z) +$$
+ +
$$ +B^{(m)}(z)=z^{-1}\Big[B^{(m-1)}(z)+K^{(m)}A^{(m-1)}(z)\Big] +$$
+ +
$$ +K^{(m)} = -\frac{\langle A^{(m-1)}(z), B^{(m-1)}(z)\rangle}{||B^{(m-1)}(z)||^2} +$$
+ +

根据正交性原理,需要证明由递推公式得到的$A^{(m)}(z)$和$B^{(m)}(z)$满足正交性条件公式。

+

在公式(76) 中,根据多项式对应项系数相等的原则,可以得到

+
$$ +\begin{aligned}&\alpha_{i}^{(m)}=\alpha_{i}^{(m-1)}+K^{(m)}\cdot\beta_{i}^{(m-1)}\quad,\quad i=1,\cdots,m-1\\&\alpha_{i}^{(m)}=K^{(m)}\quad,\quad i=m\end{aligned} +$$
+ +

由公式(73)可知

+
$$ +\beta_j^{(m)}=\alpha_{m+1-j}^{(m)},\:j=1,\cdots,m+1 +$$
+ +
+

从这里可以推出

+
$$ +B^{(m)}(z) = z^{-(m+1)}A^{(m)}(1/z) +$$
+
+

因此可以得到预测器系数的递推公式

+
$$ +\begin{cases}\alpha_\mathrm{m}^{(\mathrm{m})}=\mathrm{K}^{(\mathrm{m})}\\\alpha_\mathrm{i}^{(\mathrm{m})}=\alpha_\mathrm{i}^{(\mathrm{m}-1)}+\mathrm{K}^{(\mathrm{m})}\cdot\alpha_\mathrm{m-i}^{(\mathrm{m}-1)}\quad,\:\mathrm{i}=1,\cdots,\mathrm{m}-1\end{cases} +$$
+ +

这是线性预测系数的Durbin递推算法公式。$m$阶部分相关系数$K^{(m)}$可以用以下方法计算:

+
$$ +K^{(m)} = -\frac{\sum\limits_{j=1}^{m}\alpha_{m-j}^{(m-1)}R(j)}{||B^{(m-1)}(z)||^2} +$$
+ +

$||B^{(m)}(z)||^2$ 可以用这个递推式计算:

+
$$ +\begin{Vmatrix}B^{(m)}(z)\end{Vmatrix}^2=(1-[K^{(m)}]^2)\begin{Vmatrix}B^{(m-1)}(z)\end{Vmatrix}^2 +$$
+ +

初值

+
$$ +||B^{(0)}(z)|| = R(0)\\ +\alpha^{(0)}_0 = 1 +$$
+ +

Durbin 算法系统的稳定性

充分性:

+
$$ +\frac{1}{A^{(m)}(z)} 稳定 \Rarr |k^{(m)}| < 1 +$$
+ +

必要性:

+
$$ +|k^{(m)}| < 1 \Rarr \frac{1}{A^{(m)}(z)} 稳定 +$$
+ +

Highlight:

+

Durbin 逆序递推公式

+
$$ +A^{(m-1)}(z)=\frac{A^{(m)}(z)-k^{(m)}zB^{(m)}(z)}{1-(k^{(m)})^2} +$$
+ +

证明过程中引入的一个辅助函数

+
$$ +F^{(m)}(z)=\frac{A^{(m)}(z)}{zB^{(m)}(z)}=\frac{z^mA^{(m)}(z)}{A^{(m)}(1/z)} +$$
+ +

满足 $F^{(m)}(z) < 1 \lrArr |z| < 1$

+

稳定性的应用

充分性:说明使用 Durbin 算法可以保证 $1/A(z)$ 稳定

+

必要性:

+

判定高阶多项式 $A(z)$ 构成的系统 $1/A(z)$ 是否稳定。

+

只要计算出 $k_m$,判断 $|k_m|$ 是否小于1即可。

+

LPC 模型参数讨论

阶数

误差能量是单调减的,一般 $P = 8 \sim 14$

+

激励增益 G

采用缓变窗(哈明窗),$N >> P$

+
$$ +\varepsilon_\alpha^{(p)}(n)\approx Ge_w(n)=Ge(n)w(n) +$$
+ +
$$ +G^2\approx\frac{\sum_{n=-\infty}^\infty\left(\varepsilon_\alpha^{(p)}(n)\right)^2}{\sum_{n=-\infty}^\infty e^2(n)w^2(n)} +$$
+ +

短时分析对于LPC参数估计的影响

    +
  1. 𝑒(𝑛)为白噪声时,$E[\hat \alpha_i] = \alpha_i$,无偏估计
  2. +
  3. 𝑒(𝑛)为浊音时,采用基音同步算法可以达到无偏估计。否则如果是任意截取一段语音作分析估计是有偏的。
  4. +
+

LPC分析的频域解释

用LPC分析可以用来跟踪声道模型谱(或称语音的平滑谱)。若用LPC算法解出的全极点模型来逼近实际声道,则它的单位冲激响应ℎ(𝑛)为:

+
$$ +\begin{cases} + h(n) = 0, n \lt 0\\ + h(n) = - \sum\limits_{i=1}^{p}\alpha_i^{(p)}h(n - 1) + \delta(n), n \ge 0 +\end{cases} +$$
+ +

若 $R_h(l) = R_h(-l) = \sum\limits_{n=0}^{\infty}h(n - l)h(n), l \ge 0$

+
$$ +\sum\limits_{i=1}^{p}\alpha_i^{(P)}R_h(|k - i|) = -R_h(k), l \ge 0\\ +R_h(l)/R_h(0) = R(l) / R(0) +$$
+ +

当激励为均方值为1,均值为0的白噪声序列时,输出的自关函数𝑅𝑤(𝑙)也有此关系。
P阶LPC预测模型也称为P阶自关匹配模型。

+

各种LPC参数计算其它们之间的关系

    +
  1. $R(l) \Rightarrow \alpha$
  2. +
  3. $K \Rightarrow \alpha$
  4. +
+
$$ +\begin{cases}\alpha_m^m=K^{(m)}\\\alpha_i^{(m)}=\alpha_i^{(m-1)}+K^{(m)}\alpha_{m-i}^{(m-1)}\end{cases} +$$
+ +
    +
  1. LPC 系数 => 倒谱(因为是最小相位序列)
  2. +
  3. PARCOR 系数($K^{(m)}$)
      +
    1. 由 Durbin 解得
    2. +
    3. 由格形算法解得
    4. +
    5. 由 Schur 算法解得
    6. +
    +
  4. +
  5. 由 $A(z)$ 根确定振峰
      +
    1. 每一对根与一个共振峰对应
    2. +
    +
  6. +
  7. 声道面积比系数和对数面积比系数
  8. +
+
$$ +\frac{A_m}{A_{m-1}}=\frac{1-K^{(m)}}{1+K^{(m)}}\:,\:m=1,2,\cdots P\\ +g_m = \ln\Bigg[\frac{A_m}{A_{m-1}}\Bigg] +$$
+ +
    +
  1. 线谱对(LSP)或者线谱频率参数(LSF)
  2. +
+
$$ +P(z) = A^{(p)}(z) + z^{-(p+1)}A^{(p)}(z^{-1})\\ +Q(z) = A^{(p)}(z) - z^{-(p+1)}A^{(p)}(z^{-1}) +$$
+ +

性质:

+
    +
  1. $P(z)$ 和 $Q(z)$ 的根均在单位圆上
  2. +
  3. $P(z)$ 和 $Q(z)$ 的根在单位元上交错
  4. +
  5. $\alpha$ 参数和 $LSP$ 参数互推
  6. +
+

某个特定的𝐿𝑆𝑃 [𝑓1, 𝑓2, ⋯ 𝑓𝑝]中只移动其中任意一个频率𝑓𝑖的位置,那么对应的平滑谱只
有𝑓𝑖附近与原平滑谱有异,而在其它频域则变化很小

+

语音信号编码

语音信号的标量量化

标量量化器

均匀量化器

非均匀量化器

非线性压扩量化器

自适应量化(Adaptive Delta Modulation,ADM)

前向自适应量化(AQF)

后向自适应量化(AQB)

差分编码 DPCM

1713960093567

+

DPCM是指采用固定预测器与固定量化器的差值脉冲调制。

+

CVSD 编码器

1713958735363

+

Delta-Sigma 量化器

1713958768829

+

考虑 $D/A$ 变换器的增益为 1 的情况,此时 $V_a(z)\approx V(z)$,

+
$$ +\begin{gathered} +V(z)=[U(z)-V(z)]\cdot H(z)+Q(z) \\ +[1+H(z)]\cdot V(z)=U(z)\cdot H(z)+Q(z) \\ +V(z)=\frac{H(z)}{1+H(z)}U(z)\cdot+\frac{1}{1+H(z)}Q(z) +\end{gathered} +$$
+ +

定义信号传输函数

+
$$ +STF(z)=\frac{V(z)}{U(z)}\Bigg|_{Q(z)=0}=\frac{H(z)}{1+H(z)} +$$
+ +

定义超取样量化噪声传输函数

+
$$ +NTF(z)=\frac{V(z)}{Q(z)}\Bigg|_{U(z)=0}=\frac{1}{1+H(z)} +$$
+ +

让 $H(z)$ 为低通,则 $STF(z)$ 是低通,$NTF(z)$ 是高通

+
$$ +V(z)=STF(z)\cdot U(z)+NTF(z)\cdot Q(z) +$$
+ +

噪声整形(Noise-Shaping)技术:$NTF(z)$ 去掉了噪声能量的低频部分。接下来,只要经过低通滤波器 $H_d(z)$,就可以滤除高频部分的噪声能量,剩下的只有所需要的信号 $U(z)$,$H_d(z)$ 的输出 $V_d(z)$ 的量化噪声可以小于直接用 A/D 量化器量化的噪声。

+

采用速度(超采样)换精度(高量化比特数),量化器的精度可以非常低,甚至可以用 1 bit 量化器。1 bit 量化器,就不存在 A/D 非线性问题。

+

超采样的好处:扩展了频带宽度,我们认为噪声的功率一定,当频带变宽,噪声功率谱的高度就降低了。

+

1713960064882

+

子带编码

含有多个频点信号分量的复合宽带信号

+

首先用一组滤波器将信号分解成若干子带信号

+
$$ +\langle f_1(t),f_2(t)\rangle=\frac1{2\pi}\cdot\langle F_1(\omega),F_2(\omega)\rangle +$$
+ +

若 $\langle F_1(\omega),F_2(\omega)\rangle\approx0$,则采用子带滤波后,两个信号的相关性 $\langle f_1(t),f_2(t)\rangle$ 降低,对于这些不相关的子带信号独立编码可能提高编码效率。

+

比特数分配

$$ +\sum_{k=1}^MR_k=R\\ +\sigma_{r_k}^2=\varepsilon_{*k}^2\cdot2^{-2R_k}\cdot\sigma_{x_k}^2\\ + +

\min_{R_k} \sigma_{r,SBC}^2=\sum_{k=1}^M\varepsilon_{*k}^2\cdot2^{-2R_k}\cdot\sigma_{xk}^2\
$$

+

解得

+
$$ +R_{k,opt}=R/M+\frac12\log_2\frac{\sigma_{x_k}^2}{\left[\prod_{i=1}^M\sigma_{x_i}^2\right]^{1/M}}\\ +\sigma_{r_k}^2=\varepsilon_{*k}^2\cdot2^{-2R/M}\cdot\left[\prod_{i=1}^M\sigma_{x_i}^2\right]^{1/M}\\ +min\lbrace\sigma_{r,SBC}^2\rbrace=M\cdot\varepsilon_*^2\cdot2^{-\frac{2R}{M}}\cdot\left[\prod_{i=1}^M\sigma_{x_i}^2\right]^{\frac{1}{M}} +$$
+ +

每个子带的采样率变为总带宽的 1/M,总的信息比特速率为 $R \cdot f/M$,为了与 PCM 进行比较,假设 SBC 和 PCM 的编码速率相等:

+
$$ +R_{PCM} \cdot f = R_{SBC} \cdot f / M\\ +\Rarr R_{PCM} = R_{SBC}/M +$$
+ +

此时可推出 SBC 较于 PCM 的信噪比增益为

+
$$ +max\{G_{SBC}\}=\frac{\sigma_{r,PCM}^{2}}{\sigma_{r,SBC}^{2}}=\frac{2^{-2R_{PCM}}\sigma_{x}^{2}}{M\cdot2^{-\frac{2R_{SBC}}{M}}\cdot[\prod_{k=1}^{M}\sigma_{xk}^{2}]^{\frac{1}{M}}}\\=\frac{2^{-\frac{2R_{SBC}}{M}}\sigma_{x}^{2}}{M\cdot2^{-\frac{2R_{SBC}}{M}}\cdot[\prod_{k=1}^{M}\sigma_{xk}^{2}]^{\frac{1}{M}}}=\frac{\sigma_{x}^{2}}{M\cdot[\prod_{k=1}^{M}\sigma_{xk}^{2}]^{\frac{1}{M}}}\\=\frac{\frac{1}{M}\sigma_{x}^{2}}{[\prod_{k=1}^{M}\sigma_{xk}^{2}]^{1/M}}=\frac{\frac{1}{M}\sum_{k=1}^{M}\sigma_{xk}^{2}}{[\prod_{k=1}^{M}\sigma_{xk}^{2}]^{1/M}} +$$
+ +

因此 SBC 的信噪比增益等于子带信号的算术平均和几何平均之比。

+
    +
  • 子带信号能量越大,则分配比特数越多;
  • +
  • 最佳分配条件下,各个子带的量化噪声相同;
  • +
  • 若各个子带能量相同,则子带编码的增益为1
  • +
+

多相正交滤波器组

用一组不同频率的余弦信号对低通滤波器进行调制,变成了带通滤波器组:

+
$$ +H_i(z)=\sum_{n=-\infty}^{+\infty}h(n)\cdot cos\left(\pi(2i+1)\cdot\frac{n}{2M}\right)\cdot z^{-n}=\frac12F_i(z)+\frac12G_i(z) +$$
+ +
$$ +F_{i}\big(e^{j\omega}\big)=H(e^{j(\omega-\frac{\pi(2i+1)}{2M})}),\quad i=0,1,\cdots M-1\\G_{i}\big(e^{j\omega}\big)=H(e^{j(\omega+\frac{\pi(2i+1)}{2M})}),\quad i=0,1,\cdots M-1 +$$
+ +

1713963786950

+

分析滤波器:子带滤波,降采样;

+

降采样率过程等价于:采样(b, 将非M倍数的采样点置为0) + 分频(c,抽取 M 倍数上的采样点形成新的信号)

+

1713963998639

+
$$ +\hat{X}_i(z)=\frac1M\sum_{l=0}^{M-1}X_i(z^{\frac1M}W_M^{-l}) +$$
+ +

1713965424496

+

每个子带的输出会产生四种混叠干扰:

+
$$ +\begin{aligned} +U_i(e^{j\omega})& =K_i(e^{j\omega})\cdot Y_i(e^{j\omega}) \\ +&\approx\frac1MK_i(e^{j\omega})\{a_iF_i(e^{j\omega})X(e^{j\omega})+b_iG_i(e^{j\omega})X(e^{j\omega})+ \\ +&a_iF_i(e^{j(\omega+\frac{2\pi}M\cdot i)})X(e^{j(\omega+\frac{2\pi}M\cdot i)})+b_iG_i(e^{j(\omega-\frac{2\pi}M\cdot i)})X(e^{j(\omega-\frac{2\pi}M\cdot i)})+ \\ +&a_iF_i(e^{j(\omega+\frac{2\pi}M\cdot(i+1))})X(e^{j(\omega+\frac{2\pi}M\cdot(i+1))})+b_iG_i(e^{j(\omega-\frac{2\pi}M\cdot(i+1))})X(e^{j(\omega-\frac{2\pi}M\cdot(i+1))})\} \\ +&i=1\sim M-2 +\end{aligned} +$$
+ +

为了解决升采样后的频谱混叠,在综合滤波器部分精确对消混叠信号:

+
$$ +a_id_i=-a_{i-1}d_{i-1},\quad i>0 +$$
+ +

变换域编码

正交变换后编码:

+
$$ +Y = AX +$$
+ +

正交变换满足能量守恒

+
$$ +||Y||^2 = ||X||^2 +$$
+ +

重建信号的误差等于变换域上量化器的误差

+
$$ +E = Y - [Y]\\ +||X - [x]||^2 = ||E||^2 +$$
+ +

比特分配

假设 N 个输入样本组成一个矢量 X,变换域 Y 的每个分量用 $R_k$ 个比特量化

+
$$ +R=\frac1N\sum_{k=0}^{N-1}R_k\\ +\sigma_q^2=\sum_{k=0}^{N-1}\sigma_{q,k}^2=\varepsilon_*^2\cdot\sum_{k=0}^{N-1}2^{-2R_k}\sigma_k^2\\ +\min \sigma_{q}^{2}=\frac{1}{N}\sum_{k=0}^{N-1}\sigma_{q,k}^{2} +$$
+ +
$$ +R_{k,opt}=R+\frac12\log_2\frac{\sigma_{x_k}^2}{\left[\prod_{i=1}^M\sigma_{x_i}^2\right]^{1/N}}\\ +\sigma_{q}^2 = min\{\sigma_{q,k}^2\}=\varepsilon_*^2\cdot2^{-2R}\cdot\left[\prod_{i=1}^M\sigma_{x_i}^2\right]^{\frac{1}{N}} +$$
+ +

相比 PCM 的增益为

+
$$ +\begin{gathered} +G_{TC} =\frac{min\{\sigma_{r,PCM}^{2}\}}{min\{\sigma_{r,TC}^{2}\}}=\frac{\varepsilon_{*}\cdot2^{-2R}\cdot\sigma_{\chi}^{2}}{\varepsilon_{*}\cdot2^{-2R}\cdot\prod_{k=0}^{N-1}[\sigma_{k}^{2}]^{\frac{1}{N}}} \\ +=\frac{\sigma_x^2}{\prod_{k=0}^{N-1}[\sigma_k^2]^{1/N}}=\frac{\frac1N\sum_{k=0}^{N-1}\sigma_k^2}{\prod_{k=0}^{N-1}[\sigma_k^2]^{1/N}} +\end{gathered} +$$
+ +

最佳正交变换 - KL 变换

\ No newline at end of file diff --git a/2024/03/01/Antenna/index.html b/2024/03/01/Antenna/index.html new file mode 100644 index 00000000..b21cc91a --- /dev/null +++ b/2024/03/01/Antenna/index.html @@ -0,0 +1,509 @@ +Principle of Antenna | Guo_Yun + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Principle of Antenna

Introduction of Antenna

Definition of Antenna

+
    +
  • Transmitter and receiver of EM wave
  • +
  • Signal from current to wave
  • +
  • from lumped to distributed
  • +
+

Antenna classifications

+
    +
  • Resonant and non-resonant/leaky/travelling wave
  • +
  • Antenna number: element, multiple antennas, array
  • +
  • Shape: wire, loop, slot, patch/microstrip, cavity
  • +
  • Materials: metallic, dielectric
  • +
  • Property: wideband, narrow band
  • +
  • Yagi-Uda, Vivaldi, Cassegrain
  • +
  • Function: moblie/handset, base station, AiP
  • +
+

Maxwell equations

$$ +\nabla \cdot \vec D = \rho \rightarrow \nabla \cdot \tilde{\vec D} = \rho \\ +\nabla \cdot {\vec B} = 0 \rarr \nabla \cdot \tilde{\vec B} = 0\\ +\nabla \times {\vec E} = -\frac{\partial \vec B}{\partial t} \rarr \nabla \times \tilde{\vec E} = -j\omega \tilde{\vec B}\\ +\nabla \times {\vec H} = \vec J + \frac{\partial \vec D}{\partial t} \rarr \nabla \times \tilde{\vec H} = \vec J + j\omega \tilde{\vec D}\\ +\vec D = \varepsilon \vec E\\ +\vec B = \mu \vec H +$$
+ +
$$ +\nabla^2 \vec F = \nabla(\nabla \cdot \vec F) - \nabla \times (\nabla \times \vec F)\\ +\nabla \times (\nabla f) = 0\\ +\nabla \cdot (\nabla \times \vec F) = 0 +$$
+ +

Auxiliary Potential Functions

Let

+
$$ +\vec B = \nabla \times \vec A\\ +\vec E + j\omega \vec A = -\nabla \phi +$$
+ +
$$ +\nabla \cdot \vec D = \varepsilon \nabla \cdot(-\nabla \phi - j\omega \vec A) = \rho\\ +\Rightarrow \nabla^2\phi + \omega^2\mu\varepsilon\phi = - \frac{\rho}{\varepsilon} - j\omega(\nabla \cdot \vec A + j\omega \mu \varepsilon \phi) +$$
+ +
$$ +\nabla \times \vec H = \frac{1}{\mu}(\nabla(\nabla \cdot \vec A) - \nabla^2\vec A) = \vec J + j\omega \vec D = \vec J + j\omega\varepsilon(-\nabla\phi - j\omega \vec A)\\ +\Rightarrow \nabla^2\vec A + \omega^2\mu\varepsilon\vec A = -\mu \vec J - \nabla(\nabla \cdot \vec A + j\omega\mu\varepsilon\phi) +$$
+ +

Use Lorentz Gauge

+
$$ +\nabla \cdot \vec A + j\omega\mu\varepsilon\phi = 0 +$$
+ +

Then

+
$$ +\nabla^2\vec A + \omega^2\mu\varepsilon\vec A = -\mu \vec J\\ +\nabla^2\phi + \omega^2\mu\varepsilon\phi = - \frac{\rho}{\varepsilon} +$$
+ +

Solve ODE:

+
$$ +\begin{equation} +\nabla^2\phi + k^2\phi = 0(r\ne 0) +\end{equation}\\ +\begin{equation} +\nabla^2\phi + k^2\phi = -\frac{\rho}{\varepsilon}(r=0) +\end{equation} +$$
+ +

For (1)

+
$$ +u(r) = \frac{\phi(r)}{r}\\ +\frac{\rm{d}^2}{\rm{d}r^2}u + k^2u = 0\\ +u = C_1e^{-jkr} + C_2e^{jkr}\\ +\phi = C_1\frac{e^{-jkr}}{r} +$$
+ +

For (2), in arbitrary volume

+
$$ +\iiint_V(\nabla^2\phi + k^2\phi)\mathrm dv = \iiint_V(-\frac{\rho}{\varepsilon}\mathrm dv) = -\frac{q}{\varepsilon}\\ +r \rightarrow 0\\ +\iiint_V(k^2\phi)\mathrm dv = 0\\ +\iiint_V\nabla^2\phi \mathrm dv = \oiint_S \nabla\phi \cdot \mathrm d\vec s = C_1 \oiint_S (\frac{-jkre^{-jkr} - e^{-jkr}}{r^2})\mathrm d\vec s = C_1 (\frac{-jkre^{-jkr} - e^{-jkr}}{r^2})4\pi r^2 = -C_1 4\pi +$$
+ +

Finally,

+
$$ +\phi(r) = \frac{q}{4\pi\varepsilon}\frac{e^{-jkr}}{r} +$$
+ +

Radiation Parameters

Field Zone

Near field: resonant, field;

+

Far field: propagation, wave;

+

Fresnel region: transition;

+

1711090268476

+

Antenna Parameters

    +
  • Radiation patterns
  • +
  • Radiation Intensity
  • +
  • Power Density
  • +
  • Directivity (方向性) and Gain (重要!)
  • +
  • Polarization
  • +
  • Effective Aperture(等效口面) and Aperture efficienty(口面效率)
  • +
+

E 面:与电场方向平行的面

+

H 面:与磁场方向平行的面

+

Pattern Parameters

1711090565574

+

Often use log scale.

+

Power Density

Instantaneous Poynting vector $\vec S(x, y, z, t)$

+

Radiation Power Density = Time average Poynting vector $\vec S_{av}(x, y, z)=\frac1T\int_0^T\vec S(x, y, z, t)\mathrm dt = \frac12\text{Re}[\tilde{\vec E} \times \tilde{\vec H^*}]$

+

Total Radiation Power $P_{rad} = \oiint_S[\tilde{\vec E} \times \tilde{\vec H^*}] \cdot \mathrm d\vec s$

+

Radiation Intensity

$$ +U(\theta, \varphi) = r^2 S(r, \theta, \varphi) +$$
+ +

Isotropic 各向同性

+
$$ +P_{rad} = \int_{0}^{2\pi}\int_{0}^{\pi}U\sin\theta\mathrm d\theta\mathrm d\varphi +$$
+ +

Directivity

$$ +D = \frac{U_{\max}}{U_{av}} = \frac{P_{\max}}{P_{rad}/4\pi} +$$
+ +

1711091202619

+

1711091212947

+

1711693683771

+

1711693701192

+

Gain

1711693749686

+
$$ +G = \frac{U_{\max}}{P_{in}/4\pi} +$$
+ +

Polarization

1711693845822

+

Polarization Mismatch:

+

1711693861642

+

CP

+

1711693936592

+

Effective Aperture and Aperture efficiency

1711694027177

+

1711694083583

+

Circuit Parameters

Input impedance

Input impedance definition:

+
    +
  • the impedance presented by an antenna at its terminals
  • +
  • the ratio of the voltage to current at its terminals
  • +
  • the ratio of the electric to magnetic fields at its terminals
  • +
+

1711694243897

+
Conjugate Matching
$$ +Z_A = Z_g^* +$$
+ +
Mismatching

1711694350257

+
Radiation Resistance
$$ +P_{rad} = \frac12|I_g|^2R_r = \oiint_S\vec S_{av} \cdot \rm d\vec s +$$
+ +

1711694462059

+

Scattering Parameters

1711694619870

+
$$ +\frac{\Gamma^2}{Z_1} + \frac{T^2}{Z_2} = 1 +$$
+ +

1711694639638

+

1711695738159

+

二端口网络通常用于描述二天线问题。$S_{11}$表示天线1的反射,$S_{21}$表示天线1到天线2的耦合,均不利于信号的传播。我们希望让$1 - S_{11}^2 - S_{21}^2$尽可能大。

+

Friis’s Equation

1712471419276

+

1712471436962

+

EIRP

1712471499226

+

赫兹偶极子的辐射电阻: $80\pi^2(\frac{\Delta z}{\lambda})^2$,方向性 $\frac{2}{3}$。

+

Radar Equation

1712473473687

+

RCS(Radar cross section)

+

RCS (σ) of a radar target is an effective area that intercepts the transmitted radar power and then
scatters that power isotropically back to the radar receiver.

+
$$ +\sigma=\lim_{R\to\infty}\frac{W_{o}4\pi R^2}{W_i} +$$
+ +
    +
  • $W_i$, $W_o$ and $R$ are known;
  • +
  • $\sigma$ converges.
  • +
+

Antenna Theorems

$$ +\boxed{P_r=\mathrm{P}_t\mathrm{G}_t\mathrm{G}_r(\frac{\lambda}{4\pi R})^2} +$$
+ +
$$ +P_{r}=P_{t}\mathrm{e}_{r}\mathrm{e}_{t}D_{r}\mathrm{D}_{t}(1-\left|\Gamma_{r}\right|^{2})(1-\left|\Gamma_{t}\right|^{2})(\frac{\lambda}{4\pi R})^{2} +$$
+ +

In radar:

+
$$ +P_{r}=P_{t}\mathrm{G}_{t}\mathrm{G}_{r}\sigma\frac{1}{4\pi}(\frac{\lambda}{4\pi R_{1}R_{2}})^{2} +$$
+ +

Equivalent circuit model

+

1712900712333

+

$R_r$ :接收天线反射会释放能量。

+

Duality Theorem

1712901375924

+

电 -> 磁,不变号;
磁 -> 电,变号。

+

Image Theorem

PEC:完美电导体

+

PMC:完美磁导体

+

定理条件:

+
    +
  • PEC or PMC
  • +
  • Infinite boundary
  • +
+

PEC

+
$$ +\begin{aligned}&\hat{n}\times\vec{E}=0\\&\hat{n}\cdot\vec{B}=0\end{aligned} +$$
+ +

PMC

+
$$ +\begin{aligned}&\hat{n}\times\vec{H}=0\\&\hat{n}\cdot\vec{D}=0\end{aligned} +$$
+ +

1712902160882

+

Note:

+
    +
  • Satisfied with boundary condition;
  • +
  • Mirror source instead of PEC or PMC infinite boundary;
  • +
  • Array: source and mirror source;
  • +
  • Current loop: upper inside, lower outside.
  • +
+

Reciprocity Theorem

In radiation pattern,

+

1712903308547

+

Transmitting pattern of antenna “a”

+
$$ +Z_{_{ba}}(\theta,\varphi)=\frac{V_{_b}(\theta,\varphi)}{I_{_a}} +$$
+ +

Receiving pattern of ante

+
$$ +Z_{ab}(\theta,\varphi)=\frac{V_{a}(\theta,\varphi)}{I_{b}} +$$
+ +

Then,

+
$$ +Z_{ab}(\theta,\phi)=Z_{ba}(\theta,\phi) +$$
+ +

Lorentz Reciprocity Theorem

+
$$ +-\nabla\cdot(\vec{E}_{1}\times\vec{H}_{2}-\vec{E}_{2}\times\vec{H}_{1})=\vec{E}_{1}\cdot\vec{J}_{2}+\vec{H}_{2}\cdot\vec{M}_{1}-\vec{E}_{2}\cdot\vec{J}_{1}-\vec H_1 \cdot \vec M_2\\ +-\oiint_{S}(\vec{E}_{1}\times\vec{H}_{2}-\vec{E}_{2}\times\vec{H}_{1})\cdot ds^{'}=\iiint_{V}\left(\vec{E}_{1}\cdot\vec{J}_{2}+\vec{H}_{2}\cdot\vec{M}_{1}-\vec{E}_{2}\cdot\vec{J}_{1}-\vec H_1 \cdot \vec M_2\right)dv^{'} +$$
+ +

Far field:

+
$$ +\vec{H}_i=\hat{r}\times\vec{E}_i/\eta;\quad d\vec{s}=\hat{n}ds=\hat{r}ds +$$
+ +
$$ +(\vec{E}_1\times\vec{H}_2-\vec{E}_2\times\vec{H}_1)\cdot\hat{r}=(\hat{r}\times\vec{E}_1)\cdot\vec{H}_2-(\hat{r}\times\vec{E}_2)\cdot\vec{H}_1=0 +$$
+ +
$$ +\iiint_{V}\Big(\vec{E}_{1}\cdot\vec{J}_{2}+\vec{H}_{2}\cdot\vec{M}_{1}-\vec{E}_{2}\cdot\vec{J}_{1}-\vec{H}_{1}\cdot\vec{M}_{2}\Big)d\nu^{'}=0\\\iiint_{V}\Big(\vec{E}_{1}\cdot\vec{J}_{2}-\vec{H}_{1}\cdot\vec{M}_{2}\Big)d\nu^{'}=\iiint_{V}\Big(\vec{E}_{2}\cdot\vec{J}_{1}-\vec{H}_{2}\cdot\vec{M}_{1}\Big)d\nu^{'} +$$
+ +

Reaction: Reciprocity theorem: $\langle 1 2\rangle=\langle 2,1\rangle$

+
$$ +\left\langle1,2\right\rangle=\int_{V}(\vec{E}_{1}\cdot\vec{J}_{2}-\vec{H}_{1}\cdot\vec{M}_{2})d\nu\quad\left\langle2,1\right\rangle=\int_{V}(\vec{E}_{2}\cdot\vec{J}_{1}-\vec{H}_{2}\cdot\vec{M}_{1})d\nu +$$
+ +

If only current-source

+
$$ +\iiint_V\vec{E}_1\cdot\vec{J}_2d\nu=\iiint_V\vec{E}_2\cdot\vec{J}_1d\nu\\ +\vec{E}_1\cdot\vec{J}_2=\vec{E_2} \cdot \vec{J_1} +$$
+ +

Non-reciprocity

+

Electron plasma (non-reciprocal media)

+
$$ +\varepsilon = \begin{bmatrix}\varepsilon_{xx}&+ig&0\\-ig&\varepsilon_{yy}&0\\0&0&\varepsilon_{zz}\end{bmatrix} +$$
+ +

Huygen’s Principle

1712905110844

+

1712905233876

+

1712905317317

+

Dipole Antenna

Hertz Dipole

    +
  • Infinite short length;
  • +
  • Uniform distribution;
  • +
  • Infinite small radius;
  • +
+
$$ +E_\theta=\frac{I\Delta z}{4\pi}j\omega\mu\frac{e^{-jkr}}r\sin\theta \\ +H_\varphi=\frac{I\Delta z}{4\pi}jk\frac{e^{-jkr}}r{\sin\theta}\\ +\frac{E_\theta}{H_\varphi}=\sqrt{\frac{\mu_0}{\varepsilon_0}}=\eta +$$
+ +

1713506228135

+

1713506258888

+

1713506275022

+

Finite Length Dipole

1713506837120

+
$$ +I=\begin{cases}I_0\sin[k(\dfrac{l}{2}-z')]&0\leq z'\leq\dfrac{l}{2}\\ +I_0\sin[k(\dfrac{l}{2}+z')]&-\dfrac{l}{2}\leq z'\leq0\end{cases} +$$
+ +
$$ +\vec{A}(x,y,z)=A_z\hat{z}=\hat{z}\int_{-l/2}^{l/2}\mu I(z’)\frac{e^{-j\kappa\Lambda}}{4\pi R}dz’\\R=\sqrt{\left(x-x’\right)^2+\left(y-y’\right)^2+\left(z-z’\right)^2} +$$
+ +
$$ +\begin{aligned}&\text{For phase:}&&R\cong r-z'\cos\theta\\&\text{For amplitude:}&&R\cong r\end{aligned} +$$
+ +

R is the distance between observer and source,
r is the distance between observer and origin.

+

Small Dipole

1713506363705

+
$$ +\begin{aligned}&I(z’)\cong I_{in}(1-2|z’|/l)\\&\vec{A}(x,y,z)=A_z\hat{z}=\hat{z}\int_{-l/2}^{l/2}\mu I(z’)\frac{e^{-jkr}}{4\pi r}dz’\end{aligned} +$$
+ +

Then

+
$$ +\vec{A}(x,y,z)=\hat{z}\mu\frac{e^{-jkr}}{4\pi r}\cdot\frac12I_{in}l\\ +\vec{A}(\theta,r)=\frac12I_{in}l\mu\frac{e^{-jkr}}{4\pi r}(-\sin\theta\hat{\theta}+\cos\theta\hat{r}) +$$
+ +
$$ +\vec{E}=j\omega\mu I_{in}l\frac{e^{-jkr}}{8\pi r}\sin\theta\hat{\theta}\\\vec{H}=j\beta I_{in}l\frac{e^{-jkr}}{8\pi r}\sin\theta\hat{\varphi} +$$
+ +

Note: half of the ideal infinitesima(Hertz) dipole

+
$$ +\mathrm{Directivity}:\quad D=\frac{4\pi}{\Omega_A}\Rightarrow D_{\underset{dipole}{\operatorname*{small}}}=1.5 +$$
+ +
$$ +R_{rad}=20\left(\frac{\pi\Delta z}\lambda\right)^2=\frac14R_{rad}^\textit{Hertz dipole} +$$
+ +
$$ +P_{rad}=\frac14\frac{4\pi}3{\left(\frac{I\Delta z}{4\pi}\right)}^2k^2\eta{=}\frac12I^2R_{rad} +$$
+ +

General Case

$$ +E_{\theta}=j\eta\frac{I_0e^{-jkr}}{2\pi r}\Bigg[\frac{\cos(\frac{kl}2\cos\theta)-\cos(\frac{kl}2)}{\sin\theta}\Bigg]\\H_{\varphi}=j\frac{I_0e^{-jkr}}{2\pi r}\Bigg[\frac{\cos(\frac{kl}2\cos\theta)-\cos(\frac{kl}2)}{\sin\theta}\Bigg] +$$
+ +

Beam width: change with length.

+

1713507175699

+
$$ +\begin{aligned} +&\textbf{The time average Poynting vector:}\\ +&\vec{S}_{a\nu}=\hat{r}S_{a\nu}=\frac{1}{2}\mathrm{Re}\bigg[\tilde{\vec{E}}\times\tilde{\vec{H}}^{*}\bigg]=\eta\frac{\big|I_{0}\big|^{2}}{8\pi^{2}r^{2}}\bigg[\frac{\cos(\frac{kl}{2}\cos\theta)-\cos(\frac{kl}{2})}{\sin\theta}\bigg]^{2}\hat{r} \\ +&P_{rad}=\oint_{s}\vec{S}_{a\nu}\cdot d\vec{s}=\int_{0}^{2\pi}\int_{0}^{\pi}\vec{S}_{a\nu}\cdot\vec{r}r^{2}\sin\theta d\theta d\varphi=\eta\frac{\left|I_{0}\right|^{2}}{4\pi}\int_{0}^{\pi}\frac{\left[\cos(\frac{kl}{2}\cos\theta)-\cos(\frac{kl}{2})\right]^{2}}{\sin\theta}d\theta \\ +&\begin{aligned}&\text{The radiation intensity:}\\&&U=r^2S_{av}=\eta\frac{\left|I_0\right|^2}{8\pi^2}\left[\frac{\cos(\frac{kl}2\cos\theta)-\cos(\frac{kl}2)}{\sin\theta}\right]^2\\&&=\frac{\pi}{2}=\frac{\left|I_{0}\right|^{2}}{2}=\frac{k_{0}}{2}=\frac{k_{0}}{2}\end{aligned}& \begin{matrix}{l}\\\end{matrix}) \\ +&\Omega_A=\frac{P_{rad}}{U_{\max}}\quad D=4\pi/\Omega_A\quad A_e=\frac{\lambda^2}{4\pi}D\quad P_{rad}=\frac12I^2R_{rad} +\end{aligned} +$$
+ +

1713507190746

+

1713507205996

+

Input Impedance

Input resistance $R_r$:

+
    +
  • calculated by E and H at port;
  • +
  • take the real part (lossless).
  • +
+

Radiation resistance $R_{rad}$:

+
    +
  • calculated by E and H at far-field;
  • +
+
$$ +P_{rad}=\frac12{\left|I\right|}^2R_{rad}\quad P_{rad}=\frac12{\left|I_{in}\right|}^2R_r +$$
+ +

I is the maximum/peak current.

+

General Relation:

+
$$ +R_r=R_{rad}/\sin^2\left(\frac{kl}2\right) +$$
+ +

Half-wavelength dipole

1713508252106

+
$$ +I(z)=I_0\sin(\frac\pi2-k\left|z\right|) +$$
+ +
$$ +E_\theta(r,\theta,\varphi)=j\eta I_0\frac{e^{-jkr}}{2\pi r}\frac{\cos(\frac\pi2\cos\theta)}{\sin\theta}\\H_\varphi(r,\theta,\varphi)=jI_0\frac{e^{-jkr}}{2\pi r}\frac{\cos(\frac\pi2\cos\theta)}{\sin\theta} +$$
+ +
$$ +\vec{S}_{a\nu}=\hat{r}S_{a\nu}=\frac{1}{2}\operatorname{Re}\bigg[\tilde{\vec{E}}\times\tilde{\vec{H}}^{*}\bigg]=\eta\frac{\big|I_{0}\big|^{2}}{8\pi^{2}r^{2}}\bigg[\frac{\cos(\frac{\pi}{2}\cos\theta)}{\sin\theta}\bigg]^{2}\hat{r}\\ +P_{rad}=\oint_sS_{a\nu}\cdot d\vec{s}=\int_0^{2\pi}\int_0^\pi\vec{S}_{a\nu}\cdot\hat{r}r^2\sin\theta d\theta d\varphi=\eta\frac{\left|I_0\right|^2}{4\pi}\int_0^\pi\frac{\cos^2(\frac\pi2\cos\theta)}{\sin\theta}d\theta +$$
+ +
$$ +D=4\pi/\Omega_{A}=1.643=2.15\mathrm{dBi}\\ +A_e=\frac{\lambda^2}{4\pi}D_0\cong0.13\lambda^2 +$$
+ +

Edge capacitive effect:

+
    +
  • Terminal (open-end)
    current is not ideal zero;
  • +
  • Effective length is longer
  • +
+
$$ +R_r=R_{rad}=\frac{2P_{rad}}{\left|I_0\right|^2}\cong73\left(\Omega\right)\\ +Z_A=73+j43\left(\Omega\right) +$$
+ +

Applications

Wideband Antennas

1713508669926

+

Folded Dipole

1713508784675

+
$$ +Z_=4Z_A +$$
+ +

Increase Input Impedance

+

Log-periodic & Yagi-Uda antenna

1713509120707

+

Dipole Antennas in base station

1713509734724

+

Monopole

1713509771675

+
\ No newline at end of file diff --git a/2024/04/10/DRL/index.html b/2024/04/10/DRL/index.html new file mode 100644 index 00000000..e29c481a --- /dev/null +++ b/2024/04/10/DRL/index.html @@ -0,0 +1,168 @@ +Deep Reinforcement Learning | Guo_Yun + + + + + + + + + + + + + +

Deep Reinforcement Learning

Policy Graident

带权重的梯度下降方法

+
$$ +\nabla_\theta J(\theta)=\mathbb{E}_{\pi_\theta}[\nabla_\theta\log\pi_\theta(a_t|s_t)R(\tau)] +$$
+ +

A2C

$$ +\Delta\theta=\alpha\nabla_\theta(log\pi_\theta(s,a))\hat{q}_w(s,a)\\ +\Delta w=\beta\left(R(s,a)+\gamma\hat{q}_{w}(s_{t+1},a_{t+1})-\hat{q}_{w}(s_{t},a_{t})\right)\nabla_{w}\hat{q}_{w}(s_{t},a_{t})\\ +$$
+ +

Model-Based RL

Model-Based RL

If we know the dynamics of some process:

+

Objective in a Stochastic World

+

The dynamics are stochastic

+

The expectation under these actions in such a stochastic world.

+
$$ +\begin{aligned}p_\theta(\mathbf{s}_1,\ldots,\mathbf{s}_T\mid\mathbf{a}_1,\ldots,\mathbf{a}_T)&=p(\mathbf{s}_1)\prod_{t=1}^Tp(\mathbf{s}_{t+1}\mid\mathbf{s}_t,\mathbf{a}_t)\\\mathbf{a}_1,\ldots,\mathbf{a}_T&=\arg\max_{\mathbf{a}_1,\ldots,\mathbf{a}_T}E\left[\sum_tr(\mathbf{s}_t,\mathbf{a}_t)\mid\mathbf{a}_1,\ldots,\mathbf{a}_T\right]\end{aligned} +$$
+ +

It is suboptimal.

+

Open Loop Planning

Guess and check (Random Shooting)

+
    +
  • Pick action sequences uniformly in the action space
  • +
  • Calculate the Result
  • +
+

Better: Cross Entropy Method

+

Example: MCTS

+

Trajectory Optimization with Derivatives

LQR? Linear Quadratic Regulator

+
$$ +x_{t+1} = Ax_t+ Bu_t\\ +c(x_t, u_t) = x_t^TQx_t + u_t^TRu_t +$$
+ + +

The Q and R are symmetric and ponlositive definite. If not positive, you may optimize the result into negative inf.

+

Value Iteration

+

Model-Free RL

If the model is not known?

+

modelbased RL:

+
    +
  • base policy to collect dataset
  • +
  • learning dynamics model from dataset
  • +
  • plan through dynamics model and give actions
  • +
  • Execute the actions and add the result into data set
  • +
+

Model predictive control (MPC)

+
    +
  • base policy to collect dataset
  • +
  • learning dynamics model from dataset
  • +
  • plan through dynamics model and give actions
  • +
  • only execute the first planned action
  • +
  • append the $(s, a, s^\prime)$ to dataset
  • +
+

Model-based RL with a policy

Why Model based RL with a learned model?

+
    +
  • Data-efficiency
      +
    • Dont need to act in real world
    • +
    +
  • +
  • Multi-task with a model
      +
    • reuse the world model
    • +
    +
  • +
+

But they are unstable and worse asymptotic performance.

+
    +
  1. If the model biased toword the positive side
      +
    • the actions overfit to the learned model
    • +
    +
  2. +
  3. if the trajectory is really long
      +
    • Accumulated errors
    • +
    +
  4. +
+

To resolve 1: use uncertainty

+

Optimize towards expectation of rewards rather than rewards

+

Two types of uncertainty

+
    +
  • Aleatoric or statistical: The reality itself has uncertainty (e.g. Dice)
  • +
  • Epistemic or model uncertainty: You are uncertain about the true function
  • +
+

If use output entropy, it can’t tell apart the type of uncertainty. We need to measure the epistemic uncertainty.

+

How to measure?

+

We use the collected data to train the model, maximize $\log(D|\theta)$ by changing $\theta$

+

Can we instead to measure $\log(\theta|D)$ – the model uncertainty!

+

but it is rather intractable.

+

Model Ensemble!

+

Training multiple models, see if they agree with each other. We have to make the models different(variant).

+

The randomness and SGD is enough to make the models different.

+
    +
  • Every time drag one model and give actions
  • +
  • calculate the reward
  • +
  • add the data into dataset and update policy
  • +
+

To resolve 2 (long rollouts can be error-prone), we can always use short rollouts.

+

combine the real and model data to improve policy

+

Example: DYNA-style MBRL

+

Also can try Baysian Neural Networks.

+

Value-Equivalent Model

You dont have to stimulate the world, just simplify the value fuction ensuring to keep the value is approximately the same with the real one.

+

Use mean square error.

+

Model-Base RL with images

Imitation Learning

Accumulate Error and Covariate Shiift

+

DAgger:

+
    +
  • Train a policy from human data $D$
  • +
  • Run the policy to get dataset $D_\pi$
  • +
  • Ask human to label $D_\pi$ with actions $a_t$
  • +
  • Aggregate: $D \larr D \cup D_\pi$
  • +
+

Techniques: Dataset Resampling / Reweighting

+

Techniques: Pre-Trained Models to extract representations

+

MSE gives the mean value, while the cross-entropy gives the probability. If a task has a probability with 50% left, 50% right, the MSE will give an answer “go forward”.

+

Leverage Demonstrations in DRL

+

DQfD: Deep Q-Learning from Demonstrations

+
\ No newline at end of file diff --git a/2024/04/16/OS/index.html b/2024/04/16/OS/index.html new file mode 100644 index 00000000..557a5c58 --- /dev/null +++ b/2024/04/16/OS/index.html @@ -0,0 +1,54 @@ +操作系统 | Guo_Yun + + + + + + + + + + + + + + + +

操作系统

资源分配图

+

1713266591628

+

存储器管理

\ No newline at end of file diff --git a/2024/04/16/SolidPhysics/index.html b/2024/04/16/SolidPhysics/index.html new file mode 100644 index 00000000..22e7497d --- /dev/null +++ b/2024/04/16/SolidPhysics/index.html @@ -0,0 +1,440 @@ +固体物理 | Guo_Yun + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

固体物理

外场中电子运动状态的变化

布洛赫电子

布洛赫定理

$$ +\psi(x+R_n)=e^{ik\cdot R_n}\psi(x) +$$
+ +

布洛赫波函数:

+
$$ +\boxed{\vec{\psi(r)}=e^{i\vec{k}\cdot\vec{r}}\vec{u(r)}} +$$
+ +

薛定谔方程在周期势场 $V(r)$的本征解。与 $V(r)$有相同的周期。

+

简约布里渊区和周期布里渊区图景

+

1713239832006

+

一维近自由电子近似

利用微扰求解薛定谔方程

+

零级哈密顿量是自由电子的哈密顿量(索末菲模型),周期性势场的作用看成是微扰
适用于解释参与共有化运动的外层价电子的运动状态

+
$$ +H=-\frac{\hbar^2}{2m_0}\frac{d^2}{dx^2}+V(x)=H_0+H^{\prime}\\ +V(x)=\overline{V}+\sum_{n\neq0}V_nexp\biggl[i\frac{2\pi}anx\biggr] +$$
+ +
$$ +\begin{aligned}&H_0=-\frac{\hbar^2}{2m_0}\frac{d^2}{dx^2}+\overline{V}\\&H'=\sum_{n\neq0}V_n\exp\left(i\frac{2\pi nx}a\right)\end{aligned} +$$
+ +

基态(零级解)

+
$$ +E_k^0=\frac{\hbar^2k^2}{2m_0}+\overline{V}\\ +\psi_k^{(0)}=\frac1{\sqrt{L}}e^{ikx} +$$
+ +
$$ +k=\frac{2\pi l_x}{Na} +$$
+ +

利用波恩卡曼条件看作准连续。

+

周期性势场的一级微扰

+
$$ +\Delta V=\sum_{n\neq0}V_nexp\biggl[i\frac{2\pi}{a}nx\biggr] +$$
+ +

一级修正:

+
$$ +E_k^{(1)}=\int\left(\psi_k^0\right)^*[\Delta V]\psi_k^0dx=\left\langle k|\Delta V|k\right\rangle=0 +$$
+ +

二级修正:

+
$$ +E_k^{(2)}=\sum_{k^{\prime}}\frac{\left|\left\langle k^{\prime}|\Delta V|k\right\rangle\right|^2}{E_k^0-E_{k^{\prime}}^0} +$$
+ +

非简并情况下:

+
$$ +E_k^{(2)}=\sum_{n\neq0}\frac{\left|V_n\right|^2}{\frac{\hbar^2}{2m_0}\left[k^2-\left(k+\frac{2\pi}an\right)^2\right]} +$$
+ +

k’对应的波可以看作k状态波在周期性势场各频率分量对应的散射波->自由电子波函数经过周期势场的散射后改变了原有的能量。

+

波函数的一级修正

+
$$ +\psi_k=\frac1{\sqrt{L}}e^{ikx}\left\lbrace1+\sum_{n=0}\frac{V_n}{\frac{\hbar^2}{2m_0}\left[k^2-\left(k+\frac{2\pi n}a\right)^2\right]}\cdot exp\left[i\frac{2\pi}anx\right]\right\rbrace +$$
+ +
$$ +\vec{\psi(r)}=e^{i\vec{k}\cdot\vec{r}}\vec{u(r)} +$$
+ +

被周期函数调幅的平面波。

+

1713240457384

+

如果 k 的取值在布里渊区边界 $k=-\frac{n\pi}a$,散射波矢$k’=k+\frac{2\pi n}a=\frac{\pi n}a$,即布拉格定律 $2dsin\theta=n\lambda$。此时电子的波函数是 $k$ 和 $k’$ 两个平面波叠加的驻波。

+

简并状态的处理方法

+

在布里渊区边界,存在简并状态,能量相等。

+

准经典运动

引入准经典粒子——波包

+

自由电子和晶体电子速度的定义:

+
$$ +v(k_0) = \frac1\hbar \bigg[\frac{d E(k)}{dk}\bigg]_{k_0}\\ +E(k) = \hbar\omega +$$
+ +

速度方向垂直于等能面,如果等能面为球面, 速度的方向与 $k$ 相同。

+

晶体电子的加速度

+
$$ +\hbar\frac{dk}{dt} = F +$$
+ +

由此定义电子的准动量(晶体动量)为 $\hbar k$。可定义有效质量:

+
$$ +\frac{d\upsilon_a}{dt}=\frac1{\hbar^2}\sum_\beta F_\beta\cdot\frac{\partial^2}{\partial k_\beta\partial k_\alpha}E(k)\\ +\frac{d\vec{\upsilon}}{dt}=\frac1{m_0}\vec{F} +$$
+ +

有效质量的“倒数”(矩阵的逆):

+
$$ +\frac1{m_{\alpha\beta}^*}=\frac1{\hbar^2}\frac{\partial^2E}{\partial k_\alpha\partial k_\beta} +$$
+ +
$$ +\begin{pmatrix}\dot{\nu}_x\\\dot{\nu}_y\\\dot{\nu}_z\end{pmatrix}=\dfrac{1}{\hbar^2}\begin{pmatrix}\dfrac{\partial^2E}{\partial k_x^2}&\dfrac{\partial^2E}{\partial k_x\partial k_y}&\dfrac{\partial^2E}{\partial k_x\partial k_z}\\\dfrac{\partial^2E}{\partial k_y\partial k_x}&\dfrac{\partial^2E}{\partial k_y^2}&\dfrac{\partial^2E}{\partial k_y\partial k_z}\\\dfrac{\partial^2E}{\partial k_z\partial k_x}&\dfrac{\partial^2E}{\partial k_z\partial k_y}&\dfrac{\partial^2E}{\partial k_z^2}\end{pmatrix}\begin{pmatrix}F_x\\F_y\\F_z\end{pmatrix} +$$
+ +

选取 $(k_x, k_y, k_z)$ 的主轴方向时

+
$$ +\begin{pmatrix}\dot{\nu}_x\\\dot{\nu}_y\\\dot{\nu}_z\end{pmatrix}=\dfrac{1}{\hbar^2}\begin{pmatrix}\dfrac{\partial^2E}{\partial k_x^2}&0&0\\0&\dfrac{\partial^2E}{\partial k_y^2}&0\\\\0&0&\dfrac{\partial^2E}{\partial k_z^2}\end{pmatrix}\begin{pmatrix}F_x\\F_y\\F_z\end{pmatrix} +$$
+ +

注意:各方向上的有效质量一般不同

+

(1) 质量是标量,而有效质量是张量
晶体中的电子,加速度和外力的方向可以不一致
(2)质量常值,有效质量是变值,有正有负
能带顶附近<0 能带底附近>0
有效质量$m^{*}$与电子质量$m$之间可以有很大的差别, 因为有效质量中实际包含了周期势场的作用

+

晶体所表现出来的有效质量,原因在于电子波在晶体中传播时与晶格交换动量。

+

正有效质量状态出现在能带底附近,体现电子从外场获得的动量,加速度为正。

+

负有效质量状态出现在能带顶附近,由电子从外场获得动量不足以弥补与晶格的碰撞,加速度为负。

+

恒定电场下运动

在周期布里渊图景;

+

在 $k$ 空间里匀速运动

+

1713234834861

+

在实际空间中,电子的运动相当复杂:

+

1713234874686

+

质量无穷大:驻波解。

+

拐点不一定是 $\pi/2a$,结合实际情况。

+

1713235941206

+

1713235941206

+

理想情况(无散射),电子的运动产生震荡的电流。

+

实际情况下,很难观察到来回震荡。

+

1713236189430

+

1713236233045

+

实际情况:带隙部分反射

+

存在势垒穿透

+

隧穿几率:

+
$$ +f\propto E\exp\left[-\frac{\pi^2}\hbar\left(2m_0E_g\right)^{1/2}\left(\frac{E_g}{qE}\right)\right] +$$
+ +

1713236269885

+

准经典运动只适合描述弱电场下电子在同一能带中的运动。

+

导体、绝缘体和半导体的能带解释

满带不导电

不加电场:$E(k)=E(-k)$,占据正反方向波矢的概率相等, 相反速度的电子数量也相等,相互抵消;

+

加电场:k空间里匀速移动,边界上移出的粒子和移入的粒子是一样的,仍然均匀填充。

+

部分填充能带产生电流

无外场:净电流为0

+

有外场:k空间分布向一方移动,有净电流

+

导体的能带模型

部分填充的能带称为导带

+

1713236929581

+

非导体的能带模型

电子恰好填满最低的一系列能带,再高的能带全空

+

满带不导电,空带也不导电

+

1713236984022

+

最高的满带的电子容易被激发到上面的空带,从而使两个带皆变成未满带,产生一定的导电性

+

1713237069207

+

总结:

+

1713237158982

+

半导体能带模型

常温下,T=0K时的满带电子容易被激发到上面的空带,
从而使两个带皆变成未满带,产生一定的导电性

+

1713237357342

+

近满带和空穴

+
    +
  • 速度是电子的速度
  • +
  • 但电荷为正
  • +
+

空穴的波矢:

+

空穴的有效质量,在能带顶部为k_\mathrm{h}=-k_\mathrm{e}

+

正:

+
$$ +\frac1{m_h^*}=-\left(\frac1{\hbar^2}\cdot\frac{d^2E}{dk^2}\right) +$$
+ +

金属和半导体中的输运过程

金属中的电子输运过程

各向同性晶体中的电导率:

+
$$ +\sigma_0=\frac{ne^2\tau\left(E_F\right)}{m^*} +$$
+ +
    +
  1. 电子的质量 →有效质量 (能带理论的必然结果)
  2. +
  3. 弛豫时间只由费米面附近的电子状态决定(量子统计的结果)
  4. +
+

半导体电子输运过程

E-k 关系:

+

考虑三维能带的顶部和底部的 E-k 关系,并引入有效质量得到抛物线近似:

+
$$ +E\left(k\right)=E\left(k_0\right)+\frac{\hbar^2\left(k_x-k_{0x}\right)^2}{2m_x^*}+\frac{\hbar^2\left(k_y-k_{0y}\right)^2}{2m_y^*}+\frac{\hbar^2\left(k_z-k_{0z}\right)^2}{2m_z^*} +$$
+ +

间接带隙:价带的顶部和导带的底部并不是同一个简约波矢k

+

直接带隙:价带的顶部和导带的底部是同一个简约波矢k

+

1715048162767

+

近似成自由电子:

+

1715048234147

+

将自由电子的质量替换为:电子或空穴的有效质量

+

将自由电子的能量替换为:与导带底或价带顶的能量差

+

$E_-$: 电子的;$E_+$:空穴的。

+
$$ +N_-(E)=\frac{4\pi(2m_-^*)^{3/2}}{h^3}\sqrt{(E-E_-)}\\N_+(E)=\frac{4\pi(2m_+^*)^{3/2}}{h^3}\sqrt{(E_+-E)} +$$
+ +

费米能量应在 $E_-$ 和 $E_+$ 之间。

+
$$ +f(E)=\frac1{e^{(E-E_F)/k_BT}+1}\approx e^{-(E-E_F)/k_BT}<<1 +$$
+ +

据此计算电子的浓度:

+
$$ +\begin{aligned} +&n=\int_{E_-}^\infty f(E)N_-(E)dE \\ +&=\frac{4\pi(2m_-^*)^{3/2}}{h^3}\int_{E_-}^\infty e^{-(E-E_F)/k_BT}\sqrt{(E-E_-)}dE \\ +&=\frac{4\pi(2m_-^*)^{3/2}}{h^3}e^{-(E_--E_F)/k_BT}\int_{E_-}^\infty e^{-(E-E_-)/k_BT}\sqrt{(E-E_-)}dE \\ +&=\frac{4\pi(2m_-^*k_BT)^{3/2}}{h^3}e^{-(E_--E_F)/k_BT}\int_0^\infty\xi^{1/2}e^{-\xi}d\xi \\ +&=\frac{2(2\pi m_-^*k_BT)^{3/2}}{h^3}e^{-(E_--E_F)/k_BT}=N_-e^{-(E_--E_F)/k_BT} +\end{aligned} +$$
+ +

$N_-$ 为有效能级密度。

+

空穴的浓度:

+
$$ +\begin{aligned} +&p=\int_{-\infty}^{E_+}(1-f(E))N_+(E)dE \\ +&=\frac{4\pi(2m_+^*)^{3/2}}{h^3}\int_{-\infty}^{E_+}e^{-(E_F-E)/k_BT}\sqrt{(E_+-E)}dE \\ +&=N_+e^{-(E_F-E_+)/k_BT} +\end{aligned} +$$
+ +
$$ +N_+=\frac{2(2\pi m_+^*k_BT)^{3/2}}{h^3} +$$
+ +

在计算价带空穴数时可以等效地用价带顶能级E+代替整个价带,价带的空穴数就如同在价带顶E+处集中了N+个能态所含有的空穴数

+

反直觉的事实:电子浓度与空穴浓度的乘积仅与禁带宽度和温度有关,与费米能级无关。温度一样,电子浓度越高,空穴浓度就越低。

+
$$ +np=N_-N_+exp\biggl(-\frac{E_--E_+}{k_BT}\biggr)=N_-N_+exp\biggl(-\frac{E_g}{k_BT}\biggr) +$$
+ +

本征激发

无杂质及缺陷的半导体称为本征半导体

+
$$ +n_i=n=p=\left(N_-N_+\right)^{1/2}e^{-E_g/2k_BT} +$$
+ +

电子数目与空穴数目相同。

+
$$ +\begin{aligned} +&E_{Fi}=E_--k_BT\ln(N_-/n_i) \\ +&=E_++k_BT\ln(N_+/n_i) \\ +&=\frac12(E_-+E_+)+\frac12k_BT\ln(N_+/N_-) \\ +&=\frac12(E_-+E_+)+\frac34k_BT\ln(m_+^*/m_-^*) +\end{aligned} +$$
+ +

多数半导体的密度分布和金属相反:导带能级密度更大, 价带的更小,也就是说 $N_+>N_-$,即随着温度的升高费米能级在上升。而金属,随着温度的升高,费米能级是下降的。

+

在一般情况下,由于$k_BT$较小,且$m_h*$和$m_e*$相差不大, 所以,本征半导体的费米能$E_{Fi}$近似地在带隙的中间。

+

一般半导体

$E_F$ 升高,则电子浓度增大,空穴浓度减小。

+

通过掺杂来改变载流子的类型和浓度。

+

杂质与杂质激发

掺杂形成了杂质能级,只在掺杂原子局部地区存在。

+

处在杂质能级的电子实际上处于束缚态,只在掺杂原子附近存在,对导电性没有贡献。所以,电子从杂质原子跑出来,并不会形成“空穴”,这些“空穴”处于束缚态,并不会导电。

+

1715051145151

+

1715051313166

+

浅能级杂质

+
    +
  • 上述由替位杂质所形成的施主和受主
  • +
  • 能级靠近导带或价带,又称为浅能级杂质
  • +
  • 杂质能级对电子或空穴的束缚能很小
  • +
  • 电子很容易从施主能级跃迁或跃迁到受主能级
  • +
  • 载流子将以杂质跃迁产生为主
  • +
+

深能级杂质

+

 大多数是多重能级
o 如Au在硅中,有施主能级也有受主能级
o 金为1价,施主能级靠近价带(!),受主能级靠近禁带中部(!)
 深能级杂质附加势作用距离短,1~2个原子
 深能级杂质和缺陷影响
o 有效的复合中心,降低载流子寿命
o 做补偿杂质,提高材料电阻率

+

施主杂质激发

+

假设N型半导体只含一种施主,浓度$N_D$,能级$E_D$

+

那么导带中电子数目显然与空的施主能级的数目相等

+
$$ +n=N_D[1-f(E_D)]=N_D\left[\frac{e^{(E_D-E_F)/k_BT}}{e^{(E_D-E_F)/k_BT}+1}\right]=N_D\frac1{1+e^{-(E_D-E_F)/k_BT}} +$$
+ +

$E_F$ 在掺杂半导体里求不出来,因此尝试消去它,得到:

+

温度很低时($E_i >> k_BT$),少量施主电离激发电子

+
$$ +n\approx\frac{\left[4\left(\frac{N_D}{N_-}\right)e^{E_i/k_BT}\right]^{1/2}}{\left(\frac2{N_-}\right)e^{E_i/k_BT}}=\left(N_-N_D\right)^{1/2}e^{-E_i/2k_BT} +$$
+ +

温度很高时($E_i >> k_BT$),全部施主电离激发电子

+
$$ +\begin{aligned}n=&\frac{-1+\left[1+2{\left(\frac{N_D}{N_-}\right)}e^{E_i/k_BT}+...\right]}{\frac2{N_-}e^{E_i/k_BT}}\approx N_D\\\end{aligned} +$$
+ + + +

一般室温下热激发到导带的电子数也符合上式,按指数关系随温度升高而增加 (慎用!)

+

空穴的浓度是

+
$$ +p = (n_i)^2/n +$$
+ +

费米能级

+
$$ +\begin{aligned} +E_{F}& =E_--k_BT\ln(N_-/n) \\ +&=E_{Fi}+k_BT\ln(n/n_i) +\end{aligned} +$$
+ +

施主杂质的浓度越高,费米能级越靠近导带

+

受主类似:

+

温度很低时($E_i >> k_BT$)

+
$$ +p\thickapprox\left(N_AN_+\right)^{1/2}e^{-E_i/2k_BT} +$$
+ +

温度很高时($E_i << k_BT$)

+
$$ +p\approx N_A +$$
+ +
$$ +\begin{aligned}&E_F=E_++k_BT\ln(N_+/p)\\&=E_{Fi}-k_BT\ln(p/n_i)\end{aligned} +$$
+ +

受主杂质的浓度越高,费米能级越靠近价带

+

考虑施主和受主能级简并和电子自旋取向时引入施主和受主能级基态简并因子gD和gA。

+
$$ +n=\frac{-1+\left[1+4\left(\frac{g_DN_D}{N_-}\right)e^{E_i/k_\mathrm{B}T}\right]^{1/2}}{2\left(\frac{g_D}{N_-}\right)e^{E_i/k_\mathrm{B}T}}\\p=\frac{-1+\left[1+4\left(\frac{g_AN_A}{N_+}\right)e^{E_i/k_\mathrm{B}T}\right]^{1/2}}{2\left(\frac{g_A}{N_+}\right)e^{E_i/k_\mathrm{B}T}} +$$
+ +

1715053184570

+

中间的平台区域意味着施主已经给出了所有电子。

+

在足够高的温度下,由满带到导带的电子激发(本征激发)将成为主要的。

+

1715053408715

+

在足够高的温度下,费米能级同样也接近本征费米能级。

+

以上讨论的是非简并半导体。

+

对于简并半导体,不能再使用玻尔兹曼分布,只能使用费米-狄拉克分布。

+

补偿半导体的载流子浓度

完全电离条件下

+
$$ +n_0+N_a=p_0+N_d\\ +p_0 = n_i^2/n_0 +$$
+ +
$$ +n_0=\frac{(N_d-N_a)}2+\sqrt{\left(\frac{(N_d-N_a)}2\right)^2+n_i^2}\\ +p_0=\frac{(N_a-N_d)}2+\sqrt{\left(\frac{(N_d-N_a)}2\right)^2+n_i^2} +$$
+ +

n-type 和 p-type 的效果可以相互抵消。

+

由于补偿半导体中掺有两种杂质,所以会产生杂质的补偿作用,从而其中能够参加导电的多数载流子,就只有由那些未被补偿的杂质来提供;因此补偿半导体中有效的载流子浓度很小,故电阻率很高。虽然补偿半导体的电阻率很高,但它不同于未掺杂的本征半导体。

+

总的杂质浓度

+
$$ +N_{doping}{=}N_A{+}N_D +$$
+ +

载流子的迁移(漂移)运动

迁移率 $\mu$:单位电场下载流子的平均漂移速度

+
$$ +\sigma=nq\mu +$$
+ + +
$$ +j=nq\left(\mu E\right)\\ +\sigma=\frac{nq^2\tau}{m^*}=nq\frac{q\tau}{m^*}=nq\mu\\ +\mu=\frac{q\tau}{m^*} +$$
+ +
$$ +\sigma=nq\mu_-+pq\mu_+ + +

$$

+

多子导电:

+
$$ +\sigma\approx\begin{cases}nq\mu_-&(n\text{型 })\\pq\mu_+&(p\text{型 })&\end{cases} +$$
+ +

迁移率决定于有效质量以及平均弛豫时间

+
$$ +\mu_-=\frac{q\tau_{cn}}{m_-^*}\quad\mu_+=\frac{q\tau_{cp}}{m_+^*} +$$
+ +

在低温下,杂质的散射是主要的。温度升高时载流子热运动的速度增大,电离杂质的散射作用相应减弱,从而使迁移率增大。

+

在较高温度下,晶格的散射是主要的,温度升高,声子的散射增大,因而迁移率随温度的升高而下降。

+

半导体的电导率σ除了与迁移率有关外,还与载流子的浓度有关。而载流子的浓度随温度的升高以指数形式增加(饱和区除外)。因此除饱和区外,电导率主要以指数形式随温度的升高而迅速增大,表现出很强的热敏性。但是,不是温度越高就越好的,温度升高后,掺杂的特性就没了,导电能力主要由本征激发决定,相当于半导体退化成了一块普通的电阻,也没有什么 PN 结了。

+

这与金属的电导率有明显不同。因为金属的载流子(电子或空穴)浓度与温度无关,温度升高时,传导电子的迁移率因与声子的碰撞更加频繁而减小,所以金属的导电率温度系数为负,温度升高,电导率下降。

+
\ No newline at end of file diff --git a/2024/05/07/hello-world/index.html b/2024/05/07/hello-world/index.html new file mode 100644 index 00000000..20910d27 --- /dev/null +++ b/2024/05/07/hello-world/index.html @@ -0,0 +1,111 @@ +Hello World | Guo_Yun + + + + + + + + + + + + + +

Hello World

Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.

+

Quick Start

Create a new post

1
$ hexo new "My New Post"
+ +

More info: Writing

+

Run server

1
$ hexo server
+ +

More info: Server

+

Generate static files

1
$ hexo generate
+ +

More info: Generating

+

Deploy to remote sites

1
$ hexo deploy
+ +

More info: Deployment

+
$$ +\text{Katex is refined.} +$$
+ +
$$ +\int_{birth}^{death} stu\text{d}y = \text{touch fish} +$$
+ +

Latex 主题

这是h3。

这是h4。

这是h5。

这是正文 Content。

+

这是粗体 Bold。

+

这是斜体 Italic。

+
    +
  • 这是列表 List。
  • +
+
    +
  1. 这是有序列表 Ordered List。
  2. +
+ + + + + + + + + + + + + + + + + + + + + + + + +
这This是is表a格table。.
Thisisatable.
+
\ No newline at end of file diff --git a/archives/2022/09/index.html b/archives/2022/09/index.html new file mode 100644 index 00000000..0b4fd270 --- /dev/null +++ b/archives/2022/09/index.html @@ -0,0 +1,46 @@ +Archive | Guo_Yun + + + + + + + + + +

Archive

25 posts in total

2022

没有更多的黑历史了_(:з」∠)_
\ No newline at end of file diff --git a/archives/2022/10/index.html b/archives/2022/10/index.html new file mode 100644 index 00000000..0c00957e --- /dev/null +++ b/archives/2022/10/index.html @@ -0,0 +1,46 @@ +Archive | Guo_Yun + + + + + + + + + +

Archive

25 posts in total

2022

没有更多的黑历史了_(:з」∠)_
\ No newline at end of file diff --git a/archives/2022/11/index.html b/archives/2022/11/index.html new file mode 100644 index 00000000..16ef7260 --- /dev/null +++ b/archives/2022/11/index.html @@ -0,0 +1,46 @@ +Archive | Guo_Yun + + + + + + + + + +

Archive

25 posts in total

2022

没有更多的黑历史了_(:з」∠)_
\ No newline at end of file diff --git a/archives/2022/index.html b/archives/2022/index.html new file mode 100644 index 00000000..343e384c --- /dev/null +++ b/archives/2022/index.html @@ -0,0 +1,46 @@ +Archive | Guo_Yun + + + + + + + + + +

Archive

25 posts in total

2022

没有更多的黑历史了_(:з」∠)_
\ No newline at end of file diff --git a/archives/2023/01/index.html b/archives/2023/01/index.html new file mode 100644 index 00000000..5f3d271c --- /dev/null +++ b/archives/2023/01/index.html @@ -0,0 +1,46 @@ +Archive | Guo_Yun + + + + + + + + + +

Archive

25 posts in total

2023

没有更多的黑历史了_(:з」∠)_
\ No newline at end of file diff --git a/archives/2023/02/index.html b/archives/2023/02/index.html new file mode 100644 index 00000000..37e66ae9 --- /dev/null +++ b/archives/2023/02/index.html @@ -0,0 +1,46 @@ +Archive | Guo_Yun + + + + + + + + + +

Archive

25 posts in total

2023

没有更多的黑历史了_(:з」∠)_
\ No newline at end of file diff --git a/archives/2023/09/index.html b/archives/2023/09/index.html new file mode 100644 index 00000000..f1e4c3a0 --- /dev/null +++ b/archives/2023/09/index.html @@ -0,0 +1,46 @@ +Archive | Guo_Yun + + + + + + + + + +

Archive

25 posts in total

2023

没有更多的黑历史了_(:з」∠)_
\ No newline at end of file diff --git a/archives/2023/10/index.html b/archives/2023/10/index.html new file mode 100644 index 00000000..ac441614 --- /dev/null +++ b/archives/2023/10/index.html @@ -0,0 +1,46 @@ +Archive | Guo_Yun + + + + + + + + + +

Archive

25 posts in total

2023

没有更多的黑历史了_(:з」∠)_
\ No newline at end of file diff --git a/archives/2023/index.html b/archives/2023/index.html new file mode 100644 index 00000000..739c49da --- /dev/null +++ b/archives/2023/index.html @@ -0,0 +1,46 @@ +Archive | Guo_Yun + + + + + + + + + +
\ No newline at end of file diff --git a/archives/2023/page/2/index.html b/archives/2023/page/2/index.html new file mode 100644 index 00000000..16951946 --- /dev/null +++ b/archives/2023/page/2/index.html @@ -0,0 +1,46 @@ +Archive | Guo_Yun + + + + + + + + + +

Archive

25 posts in total

2023

没有更多的黑历史了_(:з」∠)_
\ No newline at end of file diff --git a/archives/2024/02/index.html b/archives/2024/02/index.html new file mode 100644 index 00000000..fdade6ee --- /dev/null +++ b/archives/2024/02/index.html @@ -0,0 +1,46 @@ +Archive | Guo_Yun + + + + + + + + + +

Archive

25 posts in total

2024

没有更多的黑历史了_(:з」∠)_
\ No newline at end of file diff --git a/archives/2024/03/index.html b/archives/2024/03/index.html new file mode 100644 index 00000000..1bdbd27b --- /dev/null +++ b/archives/2024/03/index.html @@ -0,0 +1,46 @@ +Archive | Guo_Yun + + + + + + + + + +

Archive

25 posts in total

2024

没有更多的黑历史了_(:з」∠)_
\ No newline at end of file diff --git a/archives/2024/04/index.html b/archives/2024/04/index.html new file mode 100644 index 00000000..0aff28b4 --- /dev/null +++ b/archives/2024/04/index.html @@ -0,0 +1,46 @@ +Archive | Guo_Yun + + + + + + + + + +

Archive

25 posts in total

2024

没有更多的黑历史了_(:з」∠)_
\ No newline at end of file diff --git a/archives/2024/05/index.html b/archives/2024/05/index.html new file mode 100644 index 00000000..ca2c7c65 --- /dev/null +++ b/archives/2024/05/index.html @@ -0,0 +1,46 @@ +Archive | Guo_Yun + + + + + + + + + +

Archive

25 posts in total

2024

没有更多的黑历史了_(:з」∠)_
\ No newline at end of file diff --git a/archives/2024/index.html b/archives/2024/index.html new file mode 100644 index 00000000..4e89a115 --- /dev/null +++ b/archives/2024/index.html @@ -0,0 +1,46 @@ +Archive | Guo_Yun + + + + + + + + + +

Archive

25 posts in total

2024

没有更多的黑历史了_(:з」∠)_
\ No newline at end of file diff --git a/archives/index.html b/archives/index.html new file mode 100644 index 00000000..6741d552 --- /dev/null +++ b/archives/index.html @@ -0,0 +1,46 @@ +Archive | Guo_Yun + + + + + + + + + +
\ No newline at end of file diff --git a/archives/page/2/index.html b/archives/page/2/index.html new file mode 100644 index 00000000..d2b33758 --- /dev/null +++ b/archives/page/2/index.html @@ -0,0 +1,46 @@ +Archive | Guo_Yun + + + + + + + + + +
\ No newline at end of file diff --git a/archives/page/3/index.html b/archives/page/3/index.html new file mode 100644 index 00000000..bd5616f9 --- /dev/null +++ b/archives/page/3/index.html @@ -0,0 +1,46 @@ +Archive | Guo_Yun + + + + + + + + + +

Archive

25 posts in total

2022

没有更多的黑历史了_(:з」∠)_
\ No newline at end of file diff --git a/css/README.html b/css/README.html new file mode 100644 index 00000000..28b00d5c --- /dev/null +++ b/css/README.html @@ -0,0 +1,4 @@ +

styl 命名规则

不会被包含至最终生成的 css 中的文件,如变量、辅助函数,使用下划线开头命名。

+ diff --git a/css/fonts.css b/css/fonts.css new file mode 100644 index 00000000..23a33c29 --- /dev/null +++ b/css/fonts.css @@ -0,0 +1,70 @@ +@font-face { + font-family: "宋体"; + font-weight: normal; + font-style: normal; + src: url("/fonts/SIMSUN.TTC"); +} + +@font-face { + font-family: "华文宋体"; + font-weight: normal; + font-style: normal; + src: url("/fonts/STSONG.TTF"); +} + +@font-face { + font-family: "华文宋体"; + font-weight: normal; + font-style: italic; + src: url("/fonts/STKAITI.TTF"); +} + +@font-face { + font-family: "华文楷体"; + font-weight: normal; + font-style: normal; + src: url("/fonts/STKAITI.TTF"); +} + +@font-face { + font-family: "华文仿宋"; + font-weight: normal; + font-style: normal; + src: url("/fonts/STFANGSO.TTF"); +} + +@font-face { + font-family: "SmileySans"; + font-weight: normal; + font-style: normal; + src: url("/fonts/SmileySans-Oblique.otf"); +} + + +@font-face { + font-family: "Latin Modern Roman 10"; + font-weight: normal; + font-style: normal; + src: url("/fonts/LMROMAN10-REGULAR.OTF"); +} + +@font-face { + font-family: "Latin Modern Roman 10"; + font-weight: bold; + font-style: normal; + src: url("/fonts/LMROMAN10-BOLD.OTF"); +} + +@font-face { + font-family: "Latin Modern Roman 10"; + font-weight: normal; + font-style: italic; + src: url("/fonts/LMROMAN10-ITALIC.OTF"); +} + +@font-face { + font-family: "Latin Modern Roman 10"; + font-weight: bold; + font-style: italic; + src: url("/fonts/LMROMAN10-BOLDITALIC.OTF"); +} \ No newline at end of file diff --git a/css/hexo-theme-yun.css b/css/hexo-theme-yun.css new file mode 100644 index 00000000..ca924d57 --- /dev/null +++ b/css/hexo-theme-yun.css @@ -0,0 +1,2115 @@ +html:not(.dark) { + --prism-foreground: #393a34; + --prism-background: #f8f8f8; + --prism-comment: #758575; + --prism-namespace: #444; + --prism-string: #bc8671; + --prism-punctuation: #80817d; + --prism-literal: #36acaa; + --prism-keyword: #248459; + --prism-function: #4d9375; + --prism-deleted: #9a050f; + --prism-class: #2b91af; + --prism-builtin: #800000; + --prism-property: #ce9178; + --prism-regex: #ad502b; +} +html.dark { + --prism-foreground: #a6accd; + --prism-background: #242424; + --prism-namespace: #aaa; + --prism-comment: #758575; + --prism-namespace: #444; + --prism-string: #c3e88d; + --prism-punctuation: #a6accd; + --prism-literal: #36acaa; + --prism-keyword: #89ddff; + --prism-function: #82aaff; + --prism-deleted: #9a050f; + --prism-class: #4ec9b0; + --prism-builtin: #d16969; + --prism-property: #c792ea; + --prism-regex: #ad502b; + --prism-selector: #c3e88d; +} +:root { + --hty-primary-color: #0078e7; + --hty-success-color: #21ba45; + --hty-warning-color: #f2711c; + --hty-danger-color: #db2828; + --hty-info-color: #42b8dd; + --hty-link-color: #0078e7; + --hty-gray-color: #999; + --hty-yellow-color: #ff8718; + --blockquote-border-left-color: var(--smc-border-color); +} +.primary { + color: #005eb4; + --blockquote-border-left-color: var(--hty-primary-color); + --blockquote-bg-color: rgba(0,120,231,0.1); +} +.success { + color: #198f35; + --blockquote-border-left-color: var(--hty-success-color); + --blockquote-bg-color: rgba(33,186,69,0.1); +} +.warning { + color: #cf590c; + --blockquote-border-left-color: var(--hty-warning-color); + --blockquote-bg-color: rgba(242,113,28,0.1); +} +.danger { + color: #b21e1e; + --blockquote-border-left-color: var(--hty-danger-color); + --blockquote-bg-color: rgba(219,40,40,0.1); +} +.info { + color: #24a1c8; + --blockquote-border-left-color: var(--hty-info-color); + --blockquote-bg-color: rgba(66,184,221,0.1); +} +.link { + color: #005eb4; + --blockquote-border-left-color: var(--hty-link-color); + --blockquote-bg-color: rgba(0,120,231,0.1); +} +.gray { + color: #808080; + --blockquote-border-left-color: var(--hty-gray-color); + --blockquote-bg-color: rgba(153,153,153,0.1); +} +.yellow { + color: #e46e00; + --blockquote-border-left-color: var(--hty-yellow-color); + --blockquote-bg-color: rgba(255,135,24,0.1); +} +html:not(.dark) { + --prism-foreground: #393a34; + --prism-background: #f8f8f8; + --prism-comment: #758575; + --prism-namespace: #444; + --prism-string: #bc8671; + --prism-punctuation: #80817d; + --prism-literal: #36acaa; + --prism-keyword: #248459; + --prism-function: #4d9375; + --prism-deleted: #9a050f; + --prism-class: #2b91af; + --prism-builtin: #800000; + --prism-property: #ce9178; + --prism-regex: #ad502b; +} +html.dark { + --prism-foreground: #a6accd; + --prism-background: #242424; + --prism-namespace: #aaa; + --prism-comment: #758575; + --prism-namespace: #444; + --prism-string: #c3e88d; + --prism-punctuation: #a6accd; + --prism-literal: #36acaa; + --prism-keyword: #89ddff; + --prism-function: #82aaff; + --prism-deleted: #9a050f; + --prism-class: #4ec9b0; + --prism-builtin: #d16969; + --prism-property: #c792ea; + --prism-regex: #ad502b; + --prism-selector: #c3e88d; +} +:root { + --hty-mode: 'light'; + --hty-bg-color: #f5f5f5; + --hty-text-color: #333; + --hty-secondary-text-color: #555; + --post-block-bg-color: #fff; + --smc-link-color: #0078e7; + --yun-bg-image: url("https://cdn.yunyoujun.cn/img/bg/stars-timing-0-blur-30px.jpg"); + --banner-line-color: #000; + --banner-char-color: #000; +} +html.dark { + --hty-mode: 'dark'; + --hty-bg-color: #303030; + --hty-text-color: #f2f2f2; + --hty-secondary-text-color: #eee; + --post-block-bg-color: #1b1f2e; + --smc-link-color: #3ca1ff; + --yun-bg-image: url("https://cdn.yunyoujun.cn/img/bg/galaxy.jpg"); + --banner-line-color: #fff; + --banner-char-color: #fff; + --banner-char-bg-color: rgba(0,0,0,0.5); + --banner-char-hover-color: #000; + --post-card-bg-color: rgba(27,31,46,0.9); + --post-card-shadow: 0 1px 8px rgba(27,31,46,0.1); + --sidebar-bg-color: rgba(27,31,46,0.95); + --sidebar-bg-image: url(""); + --page-btn-bg-color: rgba(0,0,0,0.5); + --page-btn-hover-bg-color: rgba(199,228,255,0.9); + --page-btn-active-bg-color: #0078e7; +} +.disable-hover, +.disable-hover * { + pointer-events: none !important; +} +@-moz-keyframes fade-in { + from { + opacity: 0; + } + to { + opacity: 1; + } +} +@-webkit-keyframes fade-in { + from { + opacity: 0; + } + to { + opacity: 1; + } +} +@-o-keyframes fade-in { + from { + opacity: 0; + } + to { + opacity: 1; + } +} +@keyframes fade-in { + from { + opacity: 0; + } + to { + opacity: 1; + } +} +::-webkit-input-placeholder { + color: #fff; +} +.dark .aplayer { + color: #000; +} +body { + font-family: 'PingFang SC', 'Microsoft YaHei', Roboto, Arial, sans-serif; + font-weight: 400; + margin: 0; + padding: 0; + line-height: 2; +} +::selection { + color: #fff; + background: #8e71c1; +} +a { + color: var(--smc-link-color); + text-decoration: none; + transition: color 0.1s; +} +a:hover, +a:focus { + color: #db2828; +} +a:active { + color: #2094ff; +} +h1, +h2, +h3, +h4, +h5, +h6 { + font-weight: inherit; +} +h1 { + font-size: 2.5rem; + font-weight: 400; +} +h2 { + font-size: 2.2rem; + font-weight: 400; +} +h3 { + font-size: 1.9rem; + font-weight: 400; +} +h4 { + font-size: 1.6rem; + font-weight: 400; +} +h5 { + font-size: 1.3rem; + font-weight: 400; +} +h6 { + font-size: 1rem false; +} +button { + outline: none; +} +p { + font-size: inherit; + font-weight: inherit; +} +p:first-child { + margin-top: 0; +} +hr { + opacity: 0.2; + margin: 1rem; +} +details { + border: 1px solid var(--smc-secondary); + margin: 1rem 0; +} +details[open] { + padding: 1rem 1rem 0 1rem; +} +summary { + font-weight: bold; + padding: 0.8rem 0.8rem 0.8rem 1rem; + background-color: rgba(0,120,231,0.1); +} +details[open] summary { + border-bottom: 1px solid var(--smc-secondary); + margin: -1rem -1rem 1rem -1rem; +} +html { + scroll-behavior: smooth; +} +body { + color: var(--hty-text-color); + overflow-y: scroll; + background-color: var(--hty-bg-color, #f5f5f5); +} +body::before { + content: ''; + position: fixed; + width: 100%; + height: 100%; + z-index: -1; + background-image: var(--yun-bg-image); + background-size: cover; + background-position: center; + background-repeat: no-repeat; + animation-name: bgFadeIn; + animation-duration: 2s; + opacity: 1; +} +@-moz-keyframes bgFadeIn { + from { + opacity: 0; + } + to { + opacity: 1; + } +} +@-webkit-keyframes bgFadeIn { + from { + opacity: 0; + } + to { + opacity: 1; + } +} +@-o-keyframes bgFadeIn { + from { + opacity: 0; + } + to { + opacity: 1; + } +} +@keyframes bgFadeIn { + from { + opacity: 0; + } + to { + opacity: 1; + } +} +:root { + --banner-char-bg-color: rgba(255,255,255,0.5); + --banner-char-hover-color: #fff; +} +#banner { + position: relative; + display: flex; + flex-direction: column; + align-items: center; + height: 100vh; +} +#banner .char { + font-family: 'Songti SC', 'Noto Serif SC', STZhongsong, STKaiti, KaiTi, Roboto, serif; + font-size: var(--banner-char-size, 1rem); + font-weight: 900; + background-color: var(--banner-char-bg-color); + line-height: 1; + transition-property: all; + transition-duration: 0.3s; + transition-delay: 0s; +} +#banner .char:hover { + color: var(--banner-char-hover-color); + background-color: var(--banner-char-color); +} +#banner .char-left, +#banner .char-right { + display: flex; + color: var(--banner-char-color); + opacity: 0; +} +#banner .char-left { + border-left: 1px solid var(--banner-line-color); + border-right: 0px solid rgba(0,120,231,0.1); + border-right-width: 0px; + animation-duration: 0.4s; + animation-delay: 0.4s; + animation-fill-mode: forwards; + animation-timing-function: ease-out; +} +#banner .char-right { + border-left: 0px solid rgba(0,120,231,0.1); + border-right: 1px solid var(--banner-line-color); + border-left-width: 0px; + animation-duration: 0.4s; + animation-delay: 0.4s; + animation-fill-mode: forwards; + animation-timing-function: ease-out; +} +.banner-char-container { + display: flex; + flex-direction: column; + align-items: center; +} +.vertical-line-top, +.vertical-line-bottom { + display: flex; + background-color: var(--banner-line-color); + width: 1px; + height: 0; + animation-duration: 0.4s; + animation-fill-mode: forwards; + animation-timing-function: ease-in; +} +.vertical-line-bottom { + position: absolute; + bottom: 0; +} +.cloud { + display: flex; + width: 100%; + position: absolute; + bottom: 0; + left: 0; + right: 0; + z-index: 8; + box-sizing: border-box; + mix-blend-mode: overlay; +} +.cloud .waves { + display: flex; + position: relative; + width: 100%; + height: 100px; +} +@media (max-width: 768px) { + .cloud .waves { + height: 40px; + } +} +.cloud .parallax > use { + animation: move-forever 25s cubic-bezier(0.55, 0.5, 0.45, 0.5) infinite; +} +.cloud .parallax > use:nth-child(1) { + animation-delay: -2s; + animation-duration: 7s; +} +.cloud .parallax > use:nth-child(2) { + animation-delay: -3s; + animation-duration: 10s; +} +.cloud .parallax > use:nth-child(3) { + animation-delay: -4s; + animation-duration: 13s; +} +.cloud .parallax > use:nth-child(4) { + animation-delay: -5s; + animation-duration: 20s; +} +@-moz-keyframes move-forever { + 0% { + transform: translate3d(-90px, 0, 0); + } + 100% { + transform: translate3d(85px, 0, 0); + } +} +@-webkit-keyframes move-forever { + 0% { + transform: translate3d(-90px, 0, 0); + } + 100% { + transform: translate3d(85px, 0, 0); + } +} +@-o-keyframes move-forever { + 0% { + transform: translate3d(-90px, 0, 0); + } + 100% { + transform: translate3d(85px, 0, 0); + } +} +@keyframes move-forever { + 0% { + transform: translate3d(-90px, 0, 0); + } + 100% { + transform: translate3d(85px, 0, 0); + } +} +#goDown { + display: inline-flex; + position: absolute; + bottom: 1rem; + z-index: 9; + animation: float 2s ease-in-out infinite; +} +#goDown .icon { + color: #0078e7; + width: 3rem; + height: 3rem; +} +@-moz-keyframes float { + 0% { + opacity: 1; + transform: translateY(0); + } + 50% { + opacity: 0.8; + transform: translateY(-0.8rem); + } + 100% { + opacity: 1; + transform: translateY(0); + } +} +@-webkit-keyframes float { + 0% { + opacity: 1; + transform: translateY(0); + } + 50% { + opacity: 0.8; + transform: translateY(-0.8rem); + } + 100% { + opacity: 1; + transform: translateY(0); + } +} +@-o-keyframes float { + 0% { + opacity: 1; + transform: translateY(0); + } + 50% { + opacity: 0.8; + transform: translateY(-0.8rem); + } + 100% { + opacity: 1; + transform: translateY(0); + } +} +@keyframes float { + 0% { + opacity: 1; + transform: translateY(0); + } + 50% { + opacity: 0.8; + transform: translateY(-0.8rem); + } + 100% { + opacity: 1; + transform: translateY(0); + } +} +@-moz-keyframes extend-line { + from { + height: 0; + } + to { + height: var(--banner-line-height); + } +} +@-webkit-keyframes extend-line { + from { + height: 0; + } + to { + height: var(--banner-line-height); + } +} +@-o-keyframes extend-line { + from { + height: 0; + } + to { + height: var(--banner-line-height); + } +} +@keyframes extend-line { + from { + height: 0; + } + to { + height: var(--banner-line-height); + } +} +@-moz-keyframes char-move-left { + from { + opacity: 0; + border-right-width: 0; + } + to { + opacity: 1; + border-right-width: var(--banner-empty-border-size, var(--banner-char-size)); + } +} +@-webkit-keyframes char-move-left { + from { + opacity: 0; + border-right-width: 0; + } + to { + opacity: 1; + border-right-width: var(--banner-empty-border-size, var(--banner-char-size)); + } +} +@-o-keyframes char-move-left { + from { + opacity: 0; + border-right-width: 0; + } + to { + opacity: 1; + border-right-width: var(--banner-empty-border-size, var(--banner-char-size)); + } +} +@keyframes char-move-left { + from { + opacity: 0; + border-right-width: 0; + } + to { + opacity: 1; + border-right-width: var(--banner-empty-border-size, var(--banner-char-size)); + } +} +@-moz-keyframes char-move-right { + from { + opacity: 0; + border-left-width: 0; + } + to { + opacity: 1; + border-left-width: var(--banner-empty-border-size, var(--banner-char-size)); + } +} +@-webkit-keyframes char-move-right { + from { + opacity: 0; + border-left-width: 0; + } + to { + opacity: 1; + border-left-width: var(--banner-empty-border-size, var(--banner-char-size)); + } +} +@-o-keyframes char-move-right { + from { + opacity: 0; + border-left-width: 0; + } + to { + opacity: 1; + border-left-width: var(--banner-empty-border-size, var(--banner-char-size)); + } +} +@keyframes char-move-right { + from { + opacity: 0; + border-left-width: 0; + } + to { + opacity: 1; + border-left-width: var(--banner-empty-border-size, var(--banner-char-size)); + } +} +#footer { + font-size: 0.9rem; + color: var(--hty-secondary-text-color); + text-align: center; + padding-top: 1rem; + padding-bottom: 0.5rem; +} +#footer .footer-separator { + margin: 0 0.5rem; +} +#footer .footer-custom-text { + margin-top: 0.3rem; + line-height: 0; +} +#footer .footer-support { + display: flex; + justify-content: center; + align-items: center; +} +#footer .footer-support-logo { + display: inline-flex; + justify-content: center; + align-items: center; + margin: 0.2rem; +} +#animate { + animation: iconAnimate 1.33s ease-in-out infinite; +} +.with-love { + display: inline-block; + margin: 5px 5px 0 5px; + color: #0078E7; +} +.moe-text { + margin: 0 5px; +} +@-moz-keyframes iconAnimate { + 0%, 100% { + transform: scale(1); + } + 10%, 30% { + transform: scale(0.9); + } + 20%, 40%, 60%, 80% { + transform: scale(1.1); + } + 50%, 70% { + transform: scale(1.1); + } +} +@-webkit-keyframes iconAnimate { + 0%, 100% { + transform: scale(1); + } + 10%, 30% { + transform: scale(0.9); + } + 20%, 40%, 60%, 80% { + transform: scale(1.1); + } + 50%, 70% { + transform: scale(1.1); + } +} +@-o-keyframes iconAnimate { + 0%, 100% { + transform: scale(1); + } + 10%, 30% { + transform: scale(0.9); + } + 20%, 40%, 60%, 80% { + transform: scale(1.1); + } + 50%, 70% { + transform: scale(1.1); + } +} +@keyframes iconAnimate { + 0%, 100% { + transform: scale(1); + } + 10%, 30% { + transform: scale(0.9); + } + 20%, 40%, 60%, 80% { + transform: scale(1.1); + } + 50%, 70% { + transform: scale(1.1); + } +} +.link-items { + display: flex; + padding: 0 0.5rem; + text-align: center; + justify-content: center; + flex-wrap: wrap; +} +.link-item { + display: inline-flex; +} +.link-url { + display: inline-flex; + text-align: center; + justify-self: center; + line-height: 1.5; + padding: 0.5rem 1rem; + margin: 0.5rem; + width: 15rem; + transition: 0.2s; + color: var(--primary-color, #000); + border: 1px solid var(--primary-color, #808080); +} +.link-url:hover { + color: #fff; + background-color: var(--primary-color, #808080); + box-shadow: 0 2px 20px var(--primary-color, #808080); +} +@media screen and (max-width: 768px) { + .link-url { + display: flex; + } +} +.link-url .link-left { + display: inline-block; + line-height: 0; +} +.link-url .link-avatar { + width: 4rem; + height: 4rem; + border-radius: 50%; + background-color: #fff; + border: 1px solid var(--primary-color, #808080); + transition: 0.5s; +} +.link-url .link-avatar:hover { + box-shadow: 0 0 20px rgba(0,0,0,0.1); +} +.link-url .link-info { + padding-left: 0.6rem; +} +.link-url .link-blog { + font-family: 'Songti SC', 'Noto Serif SC', STZhongsong, STKaiti, KaiTi, Roboto, serif; + font-weight: 900; + margin: 0.42rem 0; +} +.link-url .link-desc { + font-size: 0.8rem; + margin-top: 0.5rem; + width: 10.5rem; + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; +} +#content { + overflow: visible; +} +#recent-posts { + row-gap: 1rem; + padding: 1rem 0; +} +#page, +#archive, +#tag, +#category { + margin: 0 1rem 1rem 1rem; + background-color: var(--post-block-bg-color); + padding: 1rem 0.5rem; +} +@media screen and (max-width: 768px) { + #page, + #archive, + #tag, + #category { + margin: 0 0 1rem 0; + } +} +.page-subtitle { + text-align: center; + color: var(--hty-secondary-text-color); + font-size: 1rem; + margin: 0.5rem; +} +.category-lists, +.tag-cloud { + text-align: center; + padding: 1rem 2rem; +} +.category-lists a, +.tag-cloud a { + display: inline-block; + margin: 0 0.4rem; + text-decoration: none; +} +.category-lists { + text-align: left; +} +.category-lists .category-list { + padding-inline-start: 0px; +} +.category-lists .category-list-item { + list-style: none; + color: var(--hty-text-color); +} +.category-lists .category-list-item:hover::before { + color: #0078e7; +} +.category-lists .category-list-item::before { + content: '📂'; +} +.category-lists .category-list-child .category-list-item::before { + content: '📁'; +} +.category-lists .category-list-link { + color: var(--hty-text-color); + border-bottom: 1px dotted #999; +} +.category-lists .category-list-count::before { + content: ' [ '; +} +.category-lists .category-list-count::after { + content: ' ] '; +} +.wordcloud { + position: relative; + display: block; + margin: 0 auto; + text-align: center; +} +.wordcloud #wordcloud-canvas, +.wordcloud #wordcloud-sidebar-canvas { + cursor: url("$cursor-pointer"), pointer; +} +.wordcloud #wordbox { + pointer-events: none; + position: absolute; + box-shadow: 0 0 100px 100px rgba(0,0,0,0.1); + border-radius: 50px; +} +.wordcloud #wordbox-sidebar { + pointer-events: none; + position: absolute; +} +:root { + --page-btn-bg-color: rgba(255,255,255,0.5); + --page-btn-hover-bg-color: rgba(0,120,231,0.7); + --page-btn-active-bg-color: rgba(32,148,255,0.9); +} +.page-number-basic, +.pagination .space, +.pagination .prev, +.pagination .next, +.pagination .page-number { + display: inline-block; + width: 2rem; + height: 2rem; + margin: 0; + background-color: var(--page-btn-bg-color); + transition: 0.2s; +} +.pagination { + text-align: center; +} +.pagination .prev, +.pagination .next, +.pagination .page-number, +.pagination .space { + color: var(--hty-text-color) !important; + text-decoration: none; + background-color: var(--page-btn-bg-color); +} +.pagination .prev:hover, +.pagination .next:hover, +.pagination .page-number:hover, +.pagination .space:hover { + font-weight: normal; + color: var(--hty-bg-color) !important; + background: var(--page-btn-hover-bg-color); +} +.pagination .prev:active, +.pagination .next:active, +.pagination .page-number:active, +.pagination .space:active { + color: var(--hty-bg-color) !important; + background: var(--page-btn-active-bg-color); +} +.pagination .prev.current, +.pagination .next.current, +.pagination .page-number.current, +.pagination .space.current { + font-weight: normal; + background: var(--page-btn-active-bg-color); + color: var(--hty-bg-color) !important; + cursor: default; +} +.post-block { + color: var(--hty-text-color); + margin: 0 1rem; + padding: 1rem; + background-color: var(--post-block-bg-color); +} +@media screen and (max-width: 768px) { + .post-block { + margin: 0; + padding-top: 2.5rem; + } +} +.post-body { + padding: 0 5rem; +} +@media screen and (max-width: 1024px) { + .post-body { + padding: 0 0.5rem; + } +} +@media screen and (max-width: 768px) { + .post-body { + padding: 0 0.5rem; + } +} +.post-meta { + font-size: 14px; + color: var(--hty-secondary-text-color); +} +.post-meta .icon { + margin-bottom: -1px; +} +.post-description { + font-weight: normal; + padding: 0.5rem; +} +.post-author { + display: flex; + justify-content: center; +} +.post-author .author-avatar { + display: inline-flex; + justify-content: center; + align-items: center; + line-height: 0; +} +.post-author .author-avatar img { + border-radius: 50%; + height: 1rem; + width: 1rem; + padding: 2px; + border: 2px solid #d3d3d3; +} +.post-author .author-name { + margin-left: 0.5rem; + font-size: 1rem; +} +.post-meta-item-icon { + display: inline-block; + color: var(--text-color, --hty-secondary-text-color); +} +.post-meta-divider { + height: 25px; + color: var(--hty-secondary-text-color); + margin: 0 0.5rem; +} +.post-eof { + margin: 50px auto; + width: 50%; + height: 1px; + background: #0078e7; + opacity: 0.1; +} +.post-copyright { + font-size: 0.9rem; + margin: 0.5rem 5rem 1rem 5rem; + padding: 0.5rem 1rem; + border-left: 4px solid #ff5252; + background-color: var(--hty-bg-color); + list-style: none; + word-break: break-all; + position: relative; + overflow: hidden; +} +@media screen and (max-width: 768px) { + .post-copyright { + margin: 0.5rem 0; + } +} +.post-copyright::after { + position: absolute; + color: #fff; + background: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 496 512'%3E%3Cpath fill='gray' d='M245.8 214.9l-33.2 17.3c-9.4-19.6-25.2-20-27.4-20-22.2 0-33.3 14.6-33.3 43.9 0 23.5 9.2 43.8 33.3 43.8 14.4 0 24.6-7 30.5-21.3l30.6 15.5a73.2 73.2 0 01-65.1 39c-22.6 0-74-10.3-74-77 0-58.7 43-77 72.6-77 30.8-.1 52.7 11.9 66 35.8zm143 0l-32.7 17.3c-9.5-19.8-25.7-20-27.9-20-22.1 0-33.2 14.6-33.2 43.9 0 23.5 9.2 43.8 33.2 43.8 14.5 0 24.7-7 30.5-21.3l31 15.5c-2 3.8-21.3 39-65 39-22.7 0-74-9.9-74-77 0-58.7 43-77 72.6-77C354 179 376 191 389 214.8zM247.7 8C104.7 8 0 123 0 256c0 138.4 113.6 248 247.6 248C377.5 504 496 403 496 256 496 118 389.4 8 247.6 8zm.8 450.8c-112.5 0-203.7-93-203.7-202.8 0-105.5 85.5-203.3 203.8-203.3A201.7 201.7 0 01451.3 256c0 121.7-99.7 202.9-202.9 202.9z'/%3E%3C/svg%3E"); + content: ' '; + height: 10rem; + width: 10rem; + right: -2rem; + top: -2rem; + opacity: 0.1; +} +.tag-name { + padding: 0 0.1rem; +} +.hty-button { + font-family: Roboto, sans-serif; + background-color: transparent; + margin: 0 1rem; + padding: 0 0.5rem; + border-radius: 2px; + color: #0078e7; + transition-property: all; + transition-duration: 0.3s; + transition-delay: 0s; + display: inline-flex; + align-items: center; + justify-content: center; + border: none; + min-height: 2rem; + min-width: 4rem; + outline: none; + line-height: 2; + font-size: 0.9rem; + font-weight: 500; + letter-spacing: 0.09rem; + -webkit-font-smoothing: antialiased; +} +.hty-button:hover { + background-color: rgba(0,120,231,0.05); +} +.hty-button--raised { + background-color: var(--hty-primary-color, #0078e7); + box-shadow: 0px 2px 10px -1px rgba(0,0,0,0.3); + color: #fff; +} +.hty-button--raised:focus { + color: #eee; +} +.hty-button--raised:hover { + color: #fff; + background-color: rgba(0,120,231,0.9); +} +.hty-icon-button { + display: inline-flex; + border: none; + width: 3rem; + height: 3rem; + align-items: center; + justify-content: center; + border-radius: 50%; + line-height: 1; + transition-property: all; + transition-duration: 0.3s; + transition-delay: 0s; +} +.hty-icon-button:hover { + background-color: rgba(0,120,231,0.1); +} +.hty-icon-button:active { + background-color: rgba(0,120,231,0.3); +} +.button-glow { + animation-duration: 2s; + animation-iteration-count: infinite; + animation-name: glowing; + animation-direction: alternate; +} +@-moz-keyframes glowing { + from { + box-shadow: 0 0 0 rgba(0,0,0,0); + } + to { + box-shadow: 0 0 20px rgba(0,120,231,0.3); + } +} +@-webkit-keyframes glowing { + from { + box-shadow: 0 0 0 rgba(0,0,0,0); + } + to { + box-shadow: 0 0 20px rgba(0,120,231,0.3); + } +} +@-o-keyframes glowing { + from { + box-shadow: 0 0 0 rgba(0,0,0,0); + } + to { + box-shadow: 0 0 20px rgba(0,120,231,0.3); + } +} +@keyframes glowing { + from { + box-shadow: 0 0 0 rgba(0,0,0,0); + } + to { + box-shadow: 0 0 20px rgba(0,120,231,0.3); + } +} +.hty-card { + position: relative; + display: flex; + flex-direction: column; + box-sizing: border-box; + transition-property: all; + transition-duration: 0.3s; + transition-delay: 0s; +} +.hty-card:hover { + box-shadow: 0 0 1rem rgba(0,0,0,0.1); +} +::-webkit-scrollbar { + width: 8px; + height: 8px; +} +::-webkit-scrollbar-track { + border-radius: 2px; + background-color: rgba(255,255,255,0.1); +} +::-webkit-scrollbar-thumb { + border-radius: 2px; + background-color: rgba(0,120,231,0.5); +} +::-webkit-scrollbar-thumb:window-inactive { + background-color: rgba(0,120,231,0.3); +} +::-webkit-scrollbar-thumb:hover { + background-color: rgba(0,120,231,0.7); +} +::-webkit-scrollbar-thumb:active { + background-color: rgba(0,120,231,0.9); +} +.iconfont { + font-size: 1.2rem; +} +.icon { + width: 1rem; + height: 1rem; + vertical-align: -0.15em; + fill: currentColor; + overflow: hidden; +} +.fireworks { + position: fixed; + left: 0; + top: 0; + z-index: 11; + pointer-events: none; +} +.spinner { + width: 60px; + height: 60px; + border: 1px solid #0078e7; + margin: 100px auto; + animation: rotateplane 1.2s infinite ease-in-out; +} +@-moz-keyframes rotateplane { + 0% { + transform: perspective(120px) rotateX(0deg) rotateY(0deg); + -webkit-transform: perspective(120px) rotateX(0deg) rotateY(0deg); + } + 50% { + transform: perspective(120px) rotateX(-180deg) rotateY(0deg); + -webkit-transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg); + } + 100% { + transform: perspective(120px) rotateX(-180deg) rotateY(-180deg); + -webkit-transform: perspective(120px) rotateX(-180deg) rotateY(-180deg); + } +} +@-webkit-keyframes rotateplane { + 0% { + transform: perspective(120px) rotateX(0deg) rotateY(0deg); + -webkit-transform: perspective(120px) rotateX(0deg) rotateY(0deg); + } + 50% { + transform: perspective(120px) rotateX(-180deg) rotateY(0deg); + -webkit-transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg); + } + 100% { + transform: perspective(120px) rotateX(-180deg) rotateY(-180deg); + -webkit-transform: perspective(120px) rotateX(-180deg) rotateY(-180deg); + } +} +@-o-keyframes rotateplane { + 0% { + transform: perspective(120px) rotateX(0deg) rotateY(0deg); + -webkit-transform: perspective(120px) rotateX(0deg) rotateY(0deg); + } + 50% { + transform: perspective(120px) rotateX(-180deg) rotateY(0deg); + -webkit-transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg); + } + 100% { + transform: perspective(120px) rotateX(-180deg) rotateY(-180deg); + -webkit-transform: perspective(120px) rotateX(-180deg) rotateY(-180deg); + } +} +@keyframes rotateplane { + 0% { + transform: perspective(120px) rotateX(0deg) rotateY(0deg); + -webkit-transform: perspective(120px) rotateX(0deg) rotateY(0deg); + } + 50% { + transform: perspective(120px) rotateX(-180deg) rotateY(0deg); + -webkit-transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg); + } + 100% { + transform: perspective(120px) rotateX(-180deg) rotateY(-180deg); + -webkit-transform: perspective(120px) rotateX(-180deg) rotateY(-180deg); + } +} +:root { + --post-card-bg-color: rgba(255,255,255,0.9); + --post-card-shadow: 0 0 10px rgba(255,255,255,0.1); +} +.post-card { + position: relative; + max-width: 900px; + margin: 0 auto; + transition-property: all; + transition-duration: 0.3s; + transition-delay: 0s; + background-color: var(--post-card-bg-color); + box-shadow: var(--post-card-shadow); +/* tag 容器 */ +} +.post-card:hover { + box-shadow: 0 0px 25px rgba(0,0,0,0.05); +} +.post-card-header { + padding-top: 0.5rem; +} +.post-card-excerpt, +.post-card-excerpt p { + overflow: hidden; + text-overflow: ellipsis; + text-align: left; +} +.post-card-content { + padding: 0.5rem 1rem; +} +.post-card-title { + margin: 0; +} +.post-card__actions { + display: flex; + align-items: center; + min-height: 3rem; + border-top: 1px solid rgba(0,120,231,0.05); + padding-left: 1rem; + padding-right: 1rem; + justify-content: space-between; +} +.post-card__actions .icon { + margin-bottom: -1px; +} +.post-card-tag { + display: inline-flex; + justify-content: flex-end; +} +.tag-item, +.category-item { + font-size: 0.8rem; + position: relative; + color: var(--text-color, #000); + letter-spacing: 1px; +} +.tag-item::before, +.category-item::before { + content: ''; + position: absolute; + bottom: 0; + height: 100%; + width: 0; + right: 0; + background: rgba(0,120,231,0.08); + border-radius: 4px; + transition: width 0.2s ease; +} +.tag-item:hover::before, +.category-item:hover::before { + width: 104%; + left: -2%; +} +.tag-item .icon, +.category-item .icon { + width: 0.8rem; + height: 0.8rem; + padding-left: 0.1rem; +} +.post-top-icon { + position: absolute; + top: 1rem; + right: 1rem; + color: #f2711c; +} +.post-top-icon .icon { + width: 1.5rem; + height: 1.5rem; +} +.code-container { + position: relative; +} +.code-container:hover .copy-btn { + opacity: 1; +} +.copy-btn { + position: absolute; + opacity: 0; + color: #808080; + cursor: pointer; + line-height: 1.5; + padding: 1px 4px; + transition: opacity 0.2s; + top: 2px; + right: 2px; + border-radius: 4px; +} +.copy-btn:hover { + background-color: rgba(255,255,255,0.1); +} +.post-collapse { + position: relative; + margin: 0 5rem 2rem 5rem; +} +@media screen and (max-width: 1024px) { + .post-collapse { + margin: 0 2rem 1rem 2rem; + } +} +@media screen and (max-width: 768px) { + .post-collapse { + margin: 0 1rem 0.5rem 1rem; + } +} +.post-collapse-title { + font-size: 2rem; + text-align: center; +} +.post-collapse .collection-title { + position: relative; + margin: 0; + border-bottom: 2px solid rgba(0,120,231,0.6); +} +.post-collapse .collection-title::before { + content: ''; + position: absolute; + top: 50%; + width: 2px; + height: 50%; + background: rgba(0,120,231,0.3); +} +.post-collapse .collection-title .archive-year { + font-family: 'Source Code Pro', Consolas, Monaco, SFMono-Regular, 'Ubuntu Mono', Menlo, monospace; + color: #0078e7; + margin: 0 1.5rem; +} +.post-collapse .collection-title .archive-year::before { + content: ''; + position: absolute; + left: 0; + top: 35%; + margin-left: -11px; + margin-top: -4px; + width: 1.5rem; + height: 1.5rem; + background: #0078e7; + border-radius: 50%; +} +.post-collapse .post-item { + position: relative; +} +.post-collapse .post-item::before { + content: ''; + position: absolute; + width: 2px; + height: 100%; + background: rgba(0,120,231,0.3); +} +.post-collapse .post-header { + position: relative; + border-bottom: 2px solid rgba(0,120,231,0.3); + display: flex; +} +.post-collapse .post-header::before { + content: ''; + position: absolute; + left: 0; + top: 1.6rem; + width: 0.5rem; + height: 0.5rem; + margin-left: -4px; + border-radius: 50%; + border: 1px solid #0078e7; + background-color: #fff; + z-index: 1; + transition-property: all; + transition-duration: 0.3s; + transition-delay: 0s; + transition-property: background; +} +.post-collapse .post-header:hover::before { + background: #0078e7; +} +.post-collapse .post-header .post-title { + margin-left: 0.1rem; + padding: 0; + font-size: 1rem; + display: inline-flex; + align-items: center; +} +.post-collapse .post-header .post-title .post-title-link .icon { + width: 1.1rem; + height: 1.1rem; + margin-right: 0.3rem; +} +.post-collapse .post-header .post-meta { + font-family: 'Source Code Pro', Consolas, Monaco, SFMono-Regular, 'Ubuntu Mono', Menlo, monospace; + font-size: 1rem; + margin: 1rem 0 1rem 1.2rem; + white-space: nowrap; +} +.last-word { + font-size: 1rem; + margin-top: 1rem; + margin-bottom: 0; +} +.post-header { + position: relative; + text-align: center; +} +.post-header .post-title { + margin: 0; + padding: 10px; + font-size: 1.5rem; + font-weight: 900; + font-family: 'Songti SC', 'Noto Serif SC', STZhongsong, STKaiti, KaiTi, Roboto, serif; +} +.post-header .post-title .icon { + width: 1.6rem; + height: 1.6rem; + margin-right: 0.3rem; +} +.post-header .post-title .post-title-link { + position: relative; + padding: 0.7rem 1.2rem; +} +.post-header .post-title .post-title-link .icon { + width: 1.6rem; + height: 1.6rem; + margin-right: 0.4rem; +} +.post-header .post-title .post-title-link::before, +.post-header .post-title .post-title-link::after { + content: ''; + position: absolute; + width: 10px; + height: 10px; + opacity: 0; + border: 2px solid; + transition: 0.3s; + transition-timing-function: cubic-bezier(0.17, 0.67, 0.05, 1.29); +} +.post-header .post-title .post-title-link::before { + top: 0; + left: 0; + border-width: 2px 0 0 2px; + transform: translate3d(10px, 10px, 0); +} +.post-header .post-title .post-title-link::after { + right: 0; + bottom: 0; + border-width: 0 2px 2px 0; + transform: translate3d(-10px, -10px, 0); +} +.post-header .post-title .post-title-link:hover::before, +.post-header .post-title .post-title-link:hover::after { + opacity: 1; + transform: translate3d(0, 0, 0); +} +.post-edit-link { + padding: 0 0.2rem; + color: #999; +} +.post-edit-link .icon { + width: 1.5rem; + height: 1.5rem; +} +.markdown-body { + color: var(--hty-text-color); + font-weight: 400; + font-family: 'PingFang SC', 'Microsoft YaHei', Roboto, Arial, sans-serif; + padding: 1rem 0; +} +.markdown-body code, +.markdown-body pre { + font-family: 'Source Code Pro', Consolas, Monaco, SFMono-Regular, 'Ubuntu Mono', Menlo, monospace; +} +.markdown-body blockquote { + padding: 0.6rem 1rem; + border-left: 4px solid var(--blockquote-border-left-color, --smc-border-color); + background-color: var(--blockquote-bg-color, rgba(0,120,231,0.05)); +} +.markdown-body blockquote p { + margin: 0; +} +.markdown-body video { + width: 100%; + max-height: 100vh; +} +.markdown-body iframe { + border: none; + width: 100%; +} +.post-nav { + display: flex; + justify-content: space-between; + margin: 0 1rem; +} +@media screen and (max-width: 768px) { + .post-nav { + margin: 0; + } +} +.post-nav-item { + display: inline-flex; + outline: none; + font-size: 0.9rem; + font-weight: bold; + text-transform: uppercase; + height: 3rem; + transition: 0.4s; +} +.post-nav-item:hover { + background-color: rgba(0,120,231,0.1); + box-shadow: 0 0 15px rgba(0,0,0,0.1); +} +.post-nav-prev { + padding: 0 0.6rem 0 0.1rem; +} +.post-nav-next { + padding: 0 0.1rem 0 0.6rem; +} +.post-nav-prev, +.post-nav-next { + display: flex; + height: 3rem; + align-items: center; + justify-content: center; + color: var(--smc-link-color); + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + transition-property: all; + transition-duration: 0.3s; + transition-delay: 0s; +} +@media screen and (max-width: 768px) { + .post-nav-prev, + .post-nav-next { + max-width: 10rem; + } +} +.post-nav-prev .icon, +.post-nav-next .icon { + width: 1.5rem; + height: 1.5rem; +} +.post-nav-text { + display: inline-block; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} +#reward-container { + padding: 1rem 0; + margin: auto; + text-align: center; +} +#reward-button { + display: inline-flex; + justify-content: center; + align-items: center; + width: 2.5rem; + height: 2.5rem; + color: #df667f; + border-radius: 100%; +} +#reward-button .icon { + width: 1.2rem; + height: 1.2rem; +} +#reward-comment { + margin-top: 0.5rem; +} +#qr img { + width: 10rem; + height: 10rem; + display: inline-block; + margin: 1rem 1rem 0 1rem; + padding: 5px; + border: 1px solid #ccc; + border-radius: 5px; + transition-property: all; + transition-duration: 0.3s; + transition-delay: 0s; + box-shadow: 0 0 2px rgba(0,0,0,0.2); +} +#qr img:hover { + box-shadow: 0 0 15px rgba(0,0,0,0.1); +} +#qr .icon { + width: 1.5rem; + height: 1.5rem; +} +.hamburger { + padding: 0px 0px; + display: inline-block; + transition-property: opacity, filter; + transition-duration: 0.15s; + transition-timing-function: linear; + font: inherit; + color: inherit; + text-transform: none; + background-color: transparent; + border: 0; + margin: 0; + overflow: visible; +} +.hamburger:hover { + opacity: 0.7; +} +.hamburger.is-active:hover { + opacity: 0.7; +} +.hamburger.is-active .hamburger-inner, +.hamburger.is-active .hamburger-inner::before, +.hamburger.is-active .hamburger-inner::after { + background-color: #0078e7; +} +.hamburger-box { + outline: none; + width: 25px; + height: 18px; + display: inline-block; + position: relative; +} +.hamburger-inner { + display: block; + top: 50%; +} +.hamburger-inner, +.hamburger-inner::before, +.hamburger-inner::after { + width: 25px; + height: 2px; + background-color: #0078e7; + border-radius: 3px; + position: absolute; +} +.hamburger-inner::before, +.hamburger-inner::after { + content: ''; + display: block; +} +.hamburger-inner::before { + top: -8px; +} +.hamburger-inner::after { + bottom: -8px; +} +.hamburger--spin .hamburger-inner { + transition-duration: 0.22s; + transition-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19); +} +.hamburger--spin .hamburger-inner::before { + transition: top 0.1s 0.25s ease-in, opacity 0.1s ease-in; +} +.hamburger--spin .hamburger-inner::after { + transition: bottom 0.1s 0.25s ease-in, transform 0.22s cubic-bezier(0.55, 0.055, 0.675, 0.19); +} +.hamburger--spin.is-active .hamburger-inner { + transform: rotate(225deg); + transition-delay: 0.12s; + transition-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1); +} +.hamburger--spin.is-active .hamburger-inner::before { + top: 0; + opacity: 0; + transition: top 0.1s ease-out, opacity 0.1s 0.12s ease-out; +} +.hamburger--spin.is-active .hamburger-inner::after { + bottom: 0; + transform: rotate(-90deg); + transition: bottom 0.1s ease-out, transform 0.22s 0.12s cubic-bezier(0.215, 0.61, 0.355, 1); +} +.sidebar-nav { + padding-left: 0px; + margin-top: 1rem; + margin-bottom: 0; +} +.sidebar-nav .sidebar-nav-item { + border: 1px solid #0078e7; + color: #0078e7; + margin: 0 1.25rem; +} +.sidebar-nav .sidebar-nav-item:hover { + transition-property: all; + transition-duration: 0.3s; + transition-delay: 0s; + background-color: #0078e7; + color: #fff; +} +.sidebar-nav .sidebar-nav-item .icon { + width: 1.5rem; + height: 1.5rem; +} +.sidebar-nav .sidebar-nav-active { + background-color: #0078e7; + color: #fff; + box-shadow: 0 0 10px rgba(0,120,231,0.2); +} +.post-toc { + line-height: 1.8; + padding: 1rem; + font-size: 1.1rem; + font-family: 'Songti SC', 'Noto Serif SC', STZhongsong, STKaiti, KaiTi, Roboto, serif; +} +.post-toc ol { + list-style: none; + text-align: left; + padding-left: 1rem; + margin: 0; +} +.post-toc ol .toc-link { + color: var(--smc-link-color); +} +.post-toc ol .toc-link:hover { + color: #db2828; +} +.post-toc ol .toc-number { + font-family: 'Source Code Pro', Consolas, Monaco, SFMono-Regular, 'Ubuntu Mono', Menlo, monospace; +} +.post-toc ol .toc-child { + font-size: 1rem; + overflow: hidden; + transition: max-height 0.6s ease-in; + max-height: 0; +} +.post-toc ol .toc-item.active>.toc-link { + color: #f2711c; + border-bottom: 1px solid #f2711c; +} +.post-toc ol .toc-item.active>.toc-child { + max-height: 10000px; +} +:root { + --sidebar-bg-image: url("https://cdn.yunyoujun.cn/img/bg/alpha-stars-timing-1.webp"); +} +#menu-btn { + display: none; + position: fixed; + left: 0.8rem; + top: 0.6rem; + line-height: 1; + z-index: 20; + cursor: pointer; +} +@media screen and (max-width: 768px) { + #menu-btn { + display: flex; + } +} +.is-home #menu-btn { + display: flex; +} +.is-home .sidebar { + left: -20rem; + transform: translateX(0); + visibility: hidden; +} +.is-home .sidebar-translate { + transition-property: all; + transition-duration: 0.3s; + transition-delay: 0s; + padding-left: 0; +} +.is-home .sidebar-open .sidebar { + transform: translateX(20rem); + visibility: visible; +} +.is-home .sidebar-open .sidebar-translate { + padding-left: 20rem; +} +@media screen and (max-width: 768px) { + .is-home .sidebar-open .sidebar-translate { + padding-left: 0; + } +} +.sidebar { + position: fixed; + overflow-y: auto; + top: 0; + bottom: 0; + left: 0; + width: 20rem; + background-image: var(--sidebar-bg-image, none); + background-color: var(--sidebar-bg-color, #fff); + background-size: contain; + background-repeat: no-repeat; + background-position: bottom 1rem center; + text-align: center; + z-index: 10; + transition-property: all; + transition-duration: 0.3s; + transition-delay: 0s; + box-shadow: 0 0 2px rgba(0,0,0,0.2); +} +.sidebar:hover { + box-shadow: 0 0 15px rgba(0,0,0,0.1); +} +@media screen and (max-width: 768px) { + .sidebar { + left: -20rem; + transform: translateX(0); + } +} +.sidebar-translate { + padding-left: 20rem; +} +@media screen and (max-width: 768px) { + .sidebar-translate { + padding-left: 0; + } +} +.sidebar .sidebar-panel { + padding: 0.5rem; + display: none; +} +.sidebar .sidebar-panel-active { + display: block; +} +.sidebar .links { + display: block; +} +.sidebar .links-item { + display: inline-flex; +} +.sidebar .links-item .icon { + width: 2rem; + height: 2rem; +} +.sidebar .links-of-author { + display: flex; + flex-wrap: wrap; + justify-content: center; +} +.sidebar .links-of-author .icon { + width: 1.5rem; + height: 1.5rem; +} +.sidebar .links-of-author-item { + line-height: 1; + font-size: 0.9rem; +} +@media screen and (max-width: 768px) { + .sidebar-open .sidebar { + transform: translateX(20rem); + visibility: visible; + } + .sidebar-open .sidebar-overlay { + background-color: rgba(0,0,0,0.3); + position: fixed; + width: 100%; + height: 100vh; + z-index: 9; + transition: 0.4s; + } +} +#site-overview-wrap { + padding-top: 2rem; +} +.site-info.fix-top { + margin-top: -1.5rem; +} +.site-author-avatar { + display: inline-block; + line-height: 0; + position: relative; +} +.site-author-avatar img { + height: 96px; + width: 96px; + max-width: 100%; + margin: 0px; + padding: 4px; + background-color: #fff; + box-shadow: 0 0 10px rgba(0,0,0,0.2); + transition: 0.4s; +} +.site-author-avatar img:hover { + box-shadow: 0 0 30px rgba(0,120,231,0.2); +} +.site-author-avatar img { + border-radius: 50%; +} +.site-author-name { + margin-top: 0; + margin-bottom: 1rem; + line-height: 1.5; +} +.site-name { + color: var(--hty-text-color); + font-family: 'Songti SC', 'Noto Serif SC', STZhongsong, STKaiti, KaiTi, Roboto, serif; + font-weight: 900; +} +.site-subtitle { + color: #999; + display: block; +} +.site-description { + color: var(--hty-secondary-text-color); + font-size: 0.8rem; +} +.site-state { + display: flex; + justify-content: center; + overflow: hidden; + line-height: 1.5; + white-space: nowrap; + text-align: center; + margin-top: 1rem; +} +.site-state-item { + display: flex; + padding: 0 15px; + align-items: center; + border-left: 1px solid #999; +} +.site-state-item:first-child, +.site-state-item:last-child { + line-height: 1; + padding: 0; +} +.site-state-item:first-child { + border-left: none; + border-right: 1px solid #999; +} +.site-state-item:last-child { + border-left: 1px solid #999; +} +.site-state-item:nth-child(2) { + border: none; +} +.site-state-item-icon { + color: var(--hty-text-color); + line-height: 1; +} +.site-state-item-icon .icon { + width: 1.5rem; + height: 1.5rem; +} +.site-state-item-count { + color: var(--hty-text-color); + display: block; + text-align: center; + font-size: 1rem; +} +#back-to-top { + position: relative; + position: fixed; + right: -0.9rem; + bottom: 1.1rem; + z-index: 20; + opacity: 0; + color: #0078e7; + transition-property: all; + transition-duration: 0.3s; + transition-delay: 0s; +} +#back-to-top.show { + transform: translateX(-30px) rotate(360deg); + opacity: 1; +} +#back-to-top .icon { + width: 2.5rem; + height: 2.5rem; +} +.progress-circle { + transition: 0.3s stroke-dashoffset; + transform: rotate(-90deg); + transform-origin: 50% 50%; +} +.progress-circle-container { + position: absolute; +} +#comment { + margin: 0 1rem; + padding: 1rem; + background-color: var(--post-block-bg-color); +} +@media screen and (max-width: 768px) { + #comment { + margin: 0; + } +} +.comment-tooltip { + font-size: 0.8rem; + color: var(--hty-text-color); + padding: 0.5rem; + border: 1px solid #f0f0f0; + margin-bottom: 1rem; +} +#github-issues { + margin: 1rem; +} +iframe.bilibili-video { + width: 100%; + max-width: 800px; + aspect-ratio: 16/9; +} +.heimu { + background-color: var(--hty-text-color); + transition: 0.2s; +} +.heimu:hover { + cursor: pointer; + background-color: transparent; +} +.hidden { + display: none; +} +.text-center { + text-align: center; +} +.text-uppercase { + text-transform: uppercase; +} +.flex { + display: flex; +} +.flex-col { + flex-direction: column; +} +.justfiy-center { + justify-content: center; +} +.items-center { + align-items: center; +} +.flex-center { + display: flex; + justify-content: center; + align-items: center; +} +.w-full { + width: 100%; +} +.shadow-none { + --tw-shadow: 0 0 rgba(0,0,0,0); + --tw-shadow-colored: 0 0 rgba(0,0,0,0); + box-shadow: none !important; +} +.prompt-block { + display: none; + padding: 1rem; + border: 1px solid #d3d3d3; +} diff --git a/css/latex.css b/css/latex.css new file mode 100644 index 00000000..0b037c8f --- /dev/null +++ b/css/latex.css @@ -0,0 +1,512 @@ +@charset "UTF-8"; +:root { + /* == 字体设置 == */ + /* 基准字体 */ + /* 备选:Times, "Times New Roman" */ + --base-Latin-font: "Latin Modern Roman", "Latin Modern Roman 10", Times; + --base-Chinese-font: "华文宋体", "宋体", "微软雅黑"; + --base-font-size: 13pt; + /* 引言字体 */ + --quote-font: "Latin Modern Roman", "Latin Modern Roman 10", Times, + "Times New Roman", "华文仿宋"; + /* em单位为一个正文字符(--base-font-size)大小, + 例如,如果您设置 --base-font-size 为 9.5pt,那么 1.05em = 1.05*9.5pt ≈ 10pt。下面的标题字体等设置也遵循该规则。 + 这样,您就可以仅通过调整基准字体大小,而动态对其他元素大小做出调整。 + 当然,您也可以直接设置以pt或px为单位的数值,将元素的大小固定下来,如 --quote-font-size: 10pt; */ + --quote-font-size: 1.05em; + /* 代码字体(代码中的中文会调用 ui-font) */ + /* "Courier New" 从 Windows 3.1 起成为 Windows 官方提供的字体 */ + /* "Consolas" 从 Windows Vista 起成为 Windows 官方提供的字体 */ + --code-font: "Latin Modern Mono", "Latin Modern Mono 10", "Consolas", "Courier New"; + /* 侧边栏字体 */ + --ui-font: "阿里巴巴普惠体 2.0", "微软雅黑"; + /* source mode 字体 */ + /* 默认调用 code-font 和 ui-font */ + --sourceMode-font: "SF Mono", "阿里巴巴普惠体 2.0", "微软雅黑"; + /* 目录字体 */ + /* 默认调用 base-font */ + --toc-font: ""; + /* 默认调用 base-font-size */ + --toc-font-size: ""; + /* 公式字体 */ + --math-font-size: 1em; + /* 表格字体 */ + /* 默认调用 heading-font */ + --table-title-font: ""; + /* 默认调用 base-font */ + --table-font: ""; + /* 标题字体(总设置) */ + --heading-Latin-font: var(--base-Latin-font); + --heading-Chinese-font: "Noto Serif SC"; + /* 标题字体分别设置 */ + /* 大标题(h1)字体 */ + --title-Chinese-font: "Noto Serif SC"; + --title-font-size: 1.9em; + /* h2字体 */ + --h2-Chinese-font: "Noto Serif SC"; + --h2-font-size: 1.5em; + /* h3字体 */ + --h3-Chinese-font: "Noto Serif SC"; + --h3-font-size: 1.25em; + /* h4字体 */ + --h4-Chinese-font: "华文楷体"; + --h4-font-size: 1.15em; + /* h5字体 */ + --h5-Chinese-font: "华文仿宋"; + --h5-font-size: 1.10em; + /* h6字体 */ + --h6-Chinese-font: "华文仿宋"; + --h6-font-size: 1.05em; + /* 粗体样式设置 */ + /* 加粗风格时使用的字重;400等同于 normal,700等同于 bold,900等同于 heavy */ + --strong-weight: 900; + /* 基础行距 */ + --base-line-height: 1.618em; + /* == 页面设置 == */ + /* 打印页边距 */ + --set-margin: 1.8cm 2cm 1.2cm 2cm !important; + /* == 控制设置 == */ + /* 目录中是否显示一级标题 */ + --toc-show-title: none; + /* == 颜色设置 == */ + /* 超链接颜色 */ + --link-color-light: #2E67D3; + --link-color-dark: #8bb1f9; +} + +body { + padding: 0 !important; + margin: 0 !important; + /* counter-reset: tableHead 0 imgHead 0; */ +} + + + +@media print { + #write { + padding: 0 !important; + } + + @page { + margin: 1.8cm 2cm 1.2cm 2cm !important; + /* 页边距 */ + } +} +.markdown-body { + font-family: var(--base-Latin-font), var(--base-Chinese-font); + font-size: var(--base-font-size); + /* A4标准宽度 */ + max-width: 21cm; + /* column-count: 2; + column-gap: 25px; + column-width: 8cm; + display: inline-block; */ + /* 这里可以试分栏的,但确实不适合实现 */ +} +#write .md-math-block, +#write .md-rawblock, +#write p { + margin-top: 1em; + margin-bottom: 1em; +} +#write p { + text-align: left; + line-height: var(--base-line-height); +} +#write a { + color: var(--link-color-light); +} + +hr { + border-top: solid 1px #ddd; + margin-top: 1.8em; + margin-bottom: 1.8em; +} + +img { + /* 避免图片在导出时被断开 */ + page-break-inside: avoid; +} + +strong { + font-weight: var(--strong-weight); +} + +@media screen { + #write { + padding: var(--set-margin); + /* 添加一个淡蓝色的边框 */ + /* border: 0.8px solid #AAC ; */ + /* 页边阴影 */ + box-shadow: 0 0 24px 12px #cccccc; + } +} +.MathJax { + font-size: var(--math-font-size); +} + +/* typora 编写模式 */ +#typora-source { + font-family: var(--sourceMode-font), var(--code-font), var(--ui-font), monospace; + line-height: 2em; +} + +/* 侧边大纲标题 */ +.sidebar-content .outline-h1 { + counter-reset: outline-h2; +} +.sidebar-content .outline-h2 { + counter-reset: outline-h3; +} +.sidebar-content .outline-h2 .outline-label:before { + counter-increment: outline-h2; + content: counter(outline-h2) " "; +} +.sidebar-content .outline-h3 { + counter-reset: outline-h4; +} +.sidebar-content .outline-h3 .outline-label:before { + counter-increment: outline-h3; + content: counter(outline-h2) "." counter(outline-h3) " "; +} +.sidebar-content .outline-h4 { + counter-reset: outline-h5; +} +.sidebar-content .outline-h4 .outline-label:before { + counter-increment: outline-h4; + content: counter(outline-h2) "." counter(outline-h3) "." counter(outline-h4) " "; +} +.sidebar-content .outline-h5 { + counter-reset: outline-h6; +} +.sidebar-content .outline-h5 .outline-label:before { + counter-increment: outline-h5; + content: counter(outline-h2) "." counter(outline-h3) "." counter(outline-h4) "." counter(outline-h5) " "; +} + +.sidebar-content { + /* 侧边栏的字体修改 */ + font-family: var(--ui-font); + list-style: none; +} + +/* 元数据(如 YAML front matter)的背景框 */ +pre.md-meta-block { + background: #cccccc; + padding: 1.4em; + font-family: var(--code-font), var(--ui-font), monospace; + font-size: 0.8em; +} + +.markdown-body > h3.md-focus:before, +.markdown-body > h4.md-focus:before, +.markdown-body > h5.md-focus:before, +.markdown-body > h6.md-focus:before, +h3.md-focus:before, +h4.md-focus:before, +h5.md-focus:before, +h6.md-focus:before { + color: inherit; + border: inherit; + border-radius: inherit; + position: inherit; + left: initial; + float: none; + top: initial; + font-size: inherit; + padding-left: inherit; + padding-right: inherit; + vertical-align: inherit; + font-weight: inherit; + line-height: inherit; +} + +.markdown-body { + counter-reset: h2 0 h3 0 h4 0 h5 0 h6 0; +} +h1, +.markdown-body h2, +.markdown-body h3, +.markdown-body h4, +.markdown-body h5, +.markdown-body h6 { + font-weight: bold; + page-break-after: avoid !important; +} +h1 { + font-family: var(--heading-Latin-font), var(--title-Chinese-font), serif; + text-align: center; + column-span: all; + font-size: var(--title-font-size); +} +.markdown-body h2 { + font-family: var(--heading-Latin-font), var(--h2-Chinese-font), serif; + font-size: var(--h2-font-size); +} +.markdown-body h3 { + font-family: var(--heading-Latin-font), var(--h3-Chinese-font), serif; + font-size: var(--h3-font-size); + line-height: var(--h3-font-size); +} +.markdown-body h4 { + font-family: var(--heading-Latin-font), var(--h4-Chinese-font), serif; + font-size: var(--h4-font-size); + line-height: var(--h4-font-size); +} +.markdown-body h5 { + font-family: var(--heading-Latin-font), var(--h5-Chinese-font), serif; + font-size: var(--h5-font-size); + line-height: var(--h5-font-size); +} +.markdown-body h6 { + font-family: var(--heading-Latin-font), var(--h6-Chinese-font), serif; + font-size: var(--h6-font-size); + /* 没有写错,为了避免行距太小才这么写 */ + line-height: var(--h5-font-size); +} +h1 { + counter-reset: h2; +} +.markdown-body h2 { + counter-reset: h3; +} +.markdown-body h3 { + counter-reset: h4; +} +.markdown-body h4 { + counter-reset: h5; +} +.markdown-body h5 { + counter-reset: h6; +} + +.markdown-body h2:before { + counter-increment: h2; + content: counter(h2); + margin-right: 1.2em; +} + +.markdown-body h3:before, h3.markdown-body:before { + counter-increment: h3; + content: counter(h2) "." counter(h3); + margin-right: 1.2em; +} + +.markdown-body h4:before, h4.markdown-body:before { + counter-increment: h4; + content: counter(h2) "." counter(h3) "." counter(h4); + margin-right: 1.2em; +} + +.markdown-body h5:before, h5.markdown-body:before { + counter-increment: h5; + content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5); + margin-right: 1.2em; +} + +.markdown-body h6:before, h6.markdown-body:before { + counter-increment: h6; + content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) "." counter(h6); + margin-right: 1.2em; +} + +/* 参考文献(脚注)块 */ +.footnotes { + font-size: 0.95em; +} + +.footnotes-area .footnote-line { + color: var(--text-color); +} +.footnotes-area hr { + border: 0; + color: #00000000; +} + +/* task列表 */ +.md-task-list-item > input { + margin-top: 0.42em; + margin-left: -1.5em; + width: 1em !important; + height: 1em !important; +} + +#write table { + /* 三线表第一条线宽度 */ + border-top: 1.2pt solid; + /* 三线表第二条线宽度 */ + border-bottom: 1.2pt solid; + font-family: var(--table-font), var(--base-Latin-font), var(--base-Chinese-font), serif; + /* font-size: var(--base-font-size); */ + text-align: center; + page-break-inside: avoid; + border-spacing: 6px; + /* 自动布局表格宽度,如果有时内容太紧建议直接加空格吧,我自己看不惯和页面等宽的大表格 */ + width: auto; + /* 使表格默认居中;虽然这个代码不好,但好像没别的实现办法 */ + margin: 0 auto; +} +#write table td { + padding: 2px; +} +#write table tr { + padding: 2px; +} +#write th { + padding: 0px 6px; +} +#write thead { + /* 表格标题(首行)样式 */ + /* 三线表表头的线 */ + border-bottom: 0.5pt solid; + font-family: var(--table-title-font), var(--heading-Latin-font), var(--heading-Chinese-font), serif !important; + font-size: var(--base-font-size); + font-weight: var(--strong-weight); +} + +/* 一个>的引言仅为两字符缩进,使用>>的引言为传统引言样式,具有左竖线、左缩进 */ +blockquote { + font-style: normal; + font-family: var(--quote-font), var(--base-Latin-font), var(--base-Chinese-font), -apple-system, serif; + font-size: var(--quote-font-size); + /* 文字离左边框的距离 */ + padding-left: 2em; + padding-right: 2em; + /* 左边框离页面边的距离 */ + margin-left: 0; +} + +blockquote p:first-child { + padding-top: 1ch; +} + +blockquote p:last-child { + padding-bottom: 1ch; +} + +blockquote blockquote { + border-left: 4px solid #b3b3b3; + padding-left: calc(2ch - 4px); + padding-right: 0; + margin-left: -4px; + border-radius: 0; +} + +/* 行内代码 */ +code { + font-family: var(--code-font), var(--ui-font), monospace; +} + +h1 code, h2 code, h3 code, h4 code, h5 code, h6 code, +p code, +li code { + color: #3c70c6; + background-color: #fefefe; + /* 阴影 */ + box-shadow: 0 0 1px 1px #c8d3df; + font-family: var(--code-font), var(--ui-font), monospace; + box-sizing: border-box; + border-right: 0px; + margin: 0 2px 0 2px; + padding: 0 2px 0 2px; + /* 圆角 */ + border-radius: 2px 2px 2px 2px; +} + +/* 代码块样式 */ +.md-fences, +.CodeMirror pre { + font-size: 1em; +} + +.CodeMirror-wrap { + /* padding: 10px; */ + font-size: 1em; +} + +.CodeMirror-code pre { + font-family: var(--code-font), var(--ui-font), monospace; +} + +/* 目录 */ +.md-toc { + font-size: var(--toc-font-size); +} + +.md-toc-content { + margin-left: 2em; + /* 修复缺失上级标题时无法递增 */ + counter-reset: toc-h2 toc-h3 toc-h4; + page-break-after: always; +} + +.md-toc-inner { + margin-left: 0 !important; + color: var(--text-color) !important; +} + +.md-toc-item { + color: var(--text-color) !important; +} + +/* 目录标题内容属性 */ +.md-toc-h2, +.md-toc-h3, +.md-toc-h4, +.md-toc-h5, +.md-toc-h6 { + font-size: var(--toc-font-size); + font-family: var(--toc-font), var(--base-Latin-font), var(--base-Chinese-font), serif; +} + +.md-toc-h2 { + font-weight: var(--strong-weight); +} + +/* 目录标题前 */ +.md-toc-content .md-toc-h1 { + display: var(--toc-show-title); + counter-reset: toc-h2; +} +.md-toc-content .md-toc-h2 { + counter-reset: toc-h3; +} +.md-toc-content .md-toc-h3 { + counter-reset: toc-h4; +} +.md-toc-content .md-toc-h4 { + counter-reset: toc-h5; +} +.md-toc-content .md-toc-h5 { + counter-reset: toc-h6; +} +.md-toc-content .md-toc-h2:before { + counter-increment: toc-h2; + content: counter(toc-h2); + margin-right: 1em; + font-weight: var(--strong-weight); +} +.md-toc-content .md-toc-h3:before { + counter-increment: toc-h3; + content: counter(toc-h2) "." counter(toc-h3); + margin-left: 1.5em; + margin-right: 0.5em; +} +.md-toc-content .md-toc-h4:before { + counter-increment: toc-h4; + content: counter(toc-h2) "." counter(toc-h3) "." counter(toc-h4); + margin-left: 3.5em; + margin-right: 0.5em; +} +.md-toc-content .md-toc-h5:before { + counter-increment: toc-h5; + content: counter(toc-h2) "." counter(toc-h3) "." counter(toc-h4) "." counter(toc-h5); + margin-left: 5.5em; + margin-right: 0.5em; +} +.md-toc-content .md-toc-h6:before { + counter-increment: toc-h6; + content: counter(toc-h2) "." counter(toc-h3) "." counter(toc-h4) "." counter(toc-h5) "." counter(toc-h6); + margin-left: 7.5em; + margin-right: 0.5em; +} diff --git a/css/latex_backup.css b/css/latex_backup.css new file mode 100644 index 00000000..d4e5a6ac --- /dev/null +++ b/css/latex_backup.css @@ -0,0 +1,573 @@ +@charset "UTF-8"; +:root { + /* == 字体设置 == */ + /* 基准字体 */ + /* 备选:Times, "Times New Roman" */ + --base-Latin-font: "Latin Modern Roman", "Latin Modern Roman 10", Times; + --base-Chinese-font: "宋体", "华文宋体", "Noto Serif CJK SC", "微软雅黑"; + --base-font-size: 13pt; + /* 引言字体 */ + --quote-font: "Latin Modern Roman", "Latin Modern Roman 10", Times, + "Times New Roman", "华文仿宋"; + /* em单位为一个正文字符(--base-font-size)大小, + 例如,如果您设置 --base-font-size 为 9.5pt,那么 1.05em = 1.05*9.5pt ≈ 10pt。下面的标题字体等设置也遵循该规则。 + 这样,您就可以仅通过调整基准字体大小,而动态对其他元素大小做出调整。 + 当然,您也可以直接设置以pt或px为单位的数值,将元素的大小固定下来,如 --quote-font-size: 10pt; */ + --quote-font-size: 1.05em; + /* 代码字体(代码中的中文会调用 ui-font) */ + /* "Courier New" 从 Windows 3.1 起成为 Windows 官方提供的字体 */ + /* "Consolas" 从 Windows Vista 起成为 Windows 官方提供的字体 */ + --code-font: "Latin Modern Mono", "Latin Modern Mono 10", "Consolas", "Courier New"; + /* 侧边栏字体 */ + --ui-font: "阿里巴巴普惠体 2.0", "微软雅黑"; + /* source mode 字体 */ + /* 默认调用 code-font 和 ui-font */ + --sourceMode-font: "SF Mono", "阿里巴巴普惠体 2.0", "微软雅黑"; + /* 目录字体 */ + /* 默认调用 base-font */ + --toc-font: ""; + /* 默认调用 base-font-size */ + --toc-font-size: ""; + /* 公式字体 */ + --math-font-size: 1em; + /* 表格字体 */ + /* 默认调用 heading-font */ + --table-title-font: ""; + /* 默认调用 base-font */ + --table-font: ""; + /* 标题字体(总设置) */ + --heading-Latin-font: var(--base-Latin-font); + --heading-Chinese-font: "华光小标宋_CNKI"; + /* 标题字体分别设置 */ + /* 大标题(h1)字体 */ + --title-Chinese-font: "华光小标宋_CNKI"; + --title-font-size: 1.9em; + /* h2字体 */ + --h2-Chinese-font: "华光小标宋_CNKI"; + --h2-font-size: 1.5em; + /* h3字体 */ + --h3-Chinese-font: "华光小标宋_CNKI"; + --h3-font-size: 1.25em; + /* h4字体 */ + --h4-Chinese-font: "华文楷体"; + --h4-font-size: 1.15em; + /* h5字体 */ + --h5-Chinese-font: "华文仿宋"; + --h5-font-size: 1.10em; + /* h6字体 */ + --h6-Chinese-font: "华文仿宋"; + --h6-font-size: 1.05em; + /* 粗体样式设置 */ + /* 加粗风格时使用的字重;400等同于 normal,700等同于 bold,900等同于 heavy */ + --strong-weight: 900; + /* 基础行距 */ + --base-line-height: 1.618em; + /* == 页面设置 == */ + /* 打印页边距 */ + --set-margin: 1.8cm 2cm 1.2cm 2cm !important; + /* == 控制设置 == */ + /* 目录中是否显示一级标题 */ + --toc-show-title: none; + /* == 颜色设置 == */ + /* 超链接颜色 */ + --link-color-light: #2E67D3; + --link-color-dark: #8bb1f9; +} + +body { + padding: 0 !important; + margin: 0 !important; + /* counter-reset: tableHead 0 imgHead 0; */ +} + + + +@media print { + #write { + padding: 0 !important; + } + + @page { + margin: 1.8cm 2cm 1.2cm 2cm !important; + /* 页边距 */ + } +} +#write { + font-family: var(--base-Latin-font), var(--base-Chinese-font); + font-size: var(--base-font-size); + /* A4标准宽度 */ + max-width: 21cm; + background-color: white; + /* column-count: 2; + column-gap: 25px; + column-width: 8cm; + display: inline-block; */ + /* 这里可以试分栏的,但确实不适合实现 */ +} +#write .md-math-block, +#write .md-rawblock, +#write p { + margin-top: 1em; + margin-bottom: 1em; +} +#write p { + text-align: left; + line-height: var(--base-line-height); +} +#write a { + color: var(--link-color-light); +} + +hr { + border-top: solid 1px #ddd; + margin-top: 1.8em; + margin-bottom: 1.8em; +} + +img { + /* 避免图片在导出时被断开 */ + page-break-inside: avoid; +} + +strong { + font-weight: var(--strong-weight); +} + +@media screen { + #write { + padding: var(--set-margin); + /* 添加一个淡蓝色的边框 */ + /* border: 0.8px solid #AAC ; */ + /* 页边阴影 */ + box-shadow: 0 0 24px 12px #cccccc; + } +} +.MathJax { + font-size: var(--math-font-size); +} + +/* typora 编写模式 */ +#typora-source { + font-family: var(--sourceMode-font), var(--code-font), var(--ui-font), monospace; + line-height: 2em; +} + +/* 侧边大纲标题 */ +.sidebar-content .outline-h1 { + counter-reset: outline-h2; +} +.sidebar-content .outline-h2 { + counter-reset: outline-h3; +} +.sidebar-content .outline-h2 .outline-label:before { + counter-increment: outline-h2; + content: counter(outline-h2) " "; +} +.sidebar-content .outline-h3 { + counter-reset: outline-h4; +} +.sidebar-content .outline-h3 .outline-label:before { + counter-increment: outline-h3; + content: counter(outline-h2) "." counter(outline-h3) " "; +} +.sidebar-content .outline-h4 { + counter-reset: outline-h5; +} +.sidebar-content .outline-h4 .outline-label:before { + counter-increment: outline-h4; + content: counter(outline-h2) "." counter(outline-h3) "." counter(outline-h4) " "; +} +.sidebar-content .outline-h5 { + counter-reset: outline-h6; +} +.sidebar-content .outline-h5 .outline-label:before { + counter-increment: outline-h5; + content: counter(outline-h2) "." counter(outline-h3) "." counter(outline-h4) "." counter(outline-h5) " "; +} + +.sidebar-content { + /* 侧边栏的字体修改 */ + font-family: var(--ui-font); + list-style: none; +} + +/* 元数据(如 YAML front matter)的背景框 */ +pre.md-meta-block { + background: #cccccc; + padding: 1.4em; + font-family: var(--code-font), var(--ui-font), monospace; + font-size: 0.8em; +} + +#write > h3.md-focus:before, +#write > h4.md-focus:before, +#write > h5.md-focus:before, +#write > h6.md-focus:before, +h3.md-focus:before, +h4.md-focus:before, +h5.md-focus:before, +h6.md-focus:before { + color: inherit; + border: inherit; + border-radius: inherit; + position: inherit; + left: initial; + float: none; + top: initial; + font-size: inherit; + padding-left: inherit; + padding-right: inherit; + vertical-align: inherit; + font-weight: inherit; + line-height: inherit; +} + +#write { + counter-reset: h2 0 h3 0 h4 0 h5 0 h6 0; +} +#write h1, +.markdown-body h2, +.markdown-body h3, +.markdown-body h4, +.markdown-body h5, +.markdown-body h6 { + font-weight: bold; + page-break-after: avoid !important; +} +.post-header .post-title h1 { + font-family: var(--heading-Latin-font), var(--title-Chinese-font), serif; + text-align: center; + column-span: all; + font-size: var(--title-font-size); +} +.markdown-body h2 { + font-family: var(--heading-Latin-font), var(--h2-Chinese-font), serif; + font-size: var(--h2-font-size); +} +.markdown-body h3 { + font-family: var(--heading-Latin-font), var(--h3-Chinese-font), serif; + font-size: var(--h3-font-size); + line-height: var(--h3-font-size); +} +.markdown-body h4 { + font-family: var(--heading-Latin-font), var(--h4-Chinese-font), serif; + font-size: var(--h4-font-size); + line-height: var(--h4-font-size); +} +.markdown-body h5 { + font-family: var(--heading-Latin-font), var(--h5-Chinese-font), serif; + font-size: var(--h5-font-size); + line-height: var(--h5-font-size); +} +.markdown-body h6 { + font-family: var(--heading-Latin-font), var(--h6-Chinese-font), serif; + font-size: var(--h6-font-size); + /* 没有写错,为了避免行距太小才这么写 */ + line-height: var(--h5-font-size); +} +.markdown-body h1 { + counter-reset: h2; +} +.markdown-body h2 { + counter-reset: h3; +} +.markdown-body h3 { + counter-reset: h4; +} +.markdown-body h4 { + counter-reset: h5; +} +.markdown-body h5 { + counter-reset: h6; +} + +.markdown-body h2:before { + counter-increment: h2; + content: counter(h2); + margin-right: 1.2em; +} + +.markdown-body h3:before, h3.md-focus.md-heading:before { + counter-increment: h3; + content: counter(h2) "." counter(h3); + margin-right: 1.2em; +} + +.markdown-body h4:before, h4.md-focus.md-heading:before { + counter-increment: h4; + content: counter(h2) "." counter(h3) "." counter(h4); + margin-right: 1.2em; +} + +.markdown-body h5:before, h5.md-focus.md-heading:before { + counter-increment: h5; + content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5); + margin-right: 1.2em; +} + +.markdown-body h6:before, h6.md-focus.md-heading:before { + counter-increment: h6; + content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) "." counter(h6); + margin-right: 1.2em; +} + +/* 参考文献(脚注)块 */ +.footnotes { + font-size: 0.95em; +} + +.footnotes-area .footnote-line { + color: var(--text-color); +} +.footnotes-area hr { + border: 0; + color: #00000000; +} + +/* 无序列表 */ +ul { + list-style: disc; +} +ul ul { + /*list-style: circle;*/ + /* 请勿删除“–”后的空格, 他们对缩进有一定影响, 下同 */ + list-style: "–   "; +} +ul ul ul { + list-style: "◦  "; +} + +/* 有序列表 */ +ol { + list-style: decimal; +} +ol ol { + counter-reset: liist; + list-style: none; +} +ol ol li { + counter-increment: liist; + position: relative; +} +ol ol li::before { + content: "(" counter(liist,lower-alpha) ")"; + position: absolute; + left: -1.8em; +} +ol ol ol { + counter-reset: liiist; + list-style: none; + margin: 0; +} +ol ol ol li { + counter-increment: liiist; + position: relative; +} +ol ol ol li::before { + content: counter(liiist,lower-roman) "."; + align-self: flex-end; + position: absolute; + left: -4.5em; + /* -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box;*/ + /* 为了让项目编号是重新用句点对齐而不是左对齐 */ + width: 4em; + text-align: right; +} + +li { + position: relative; +} + +ol, ul { + padding-inline-start: 2em; +} + +/* task列表 */ +.md-task-list-item > input { + margin-top: 0.42em; + margin-left: -1.5em; + width: 1em !important; + height: 1em !important; +} + +#write table { + /* 三线表第一条线宽度 */ + border-top: 1.2pt solid; + /* 三线表第二条线宽度 */ + border-bottom: 1.2pt solid; + font-family: var(--table-font), var(--base-Latin-font), var(--base-Chinese-font), serif; + /* font-size: var(--base-font-size); */ + text-align: center; + page-break-inside: avoid; + border-spacing: 6px; + /* 自动布局表格宽度,如果有时内容太紧建议直接加空格吧,我自己看不惯和页面等宽的大表格 */ + width: auto; + /* 使表格默认居中;虽然这个代码不好,但好像没别的实现办法 */ + margin: 0 auto; +} +#write table td { + padding: 2px; +} +#write table tr { + padding: 2px; +} +#write th { + padding: 0px 6px; +} +#write thead { + /* 表格标题(首行)样式 */ + /* 三线表表头的线 */ + border-bottom: 0.5pt solid; + font-family: var(--table-title-font), var(--heading-Latin-font), var(--heading-Chinese-font), serif !important; + font-size: var(--base-font-size); + font-weight: var(--strong-weight); +} + +/* 一个>的引言仅为两字符缩进,使用>>的引言为传统引言样式,具有左竖线、左缩进 */ +blockquote { + font-style: normal; + font-family: var(--quote-font), var(--base-Latin-font), var(--base-Chinese-font), -apple-system, serif; + font-size: var(--quote-font-size); + /* 文字离左边框的距离 */ + padding-left: 2em; + padding-right: 2em; + /* 左边框离页面边的距离 */ + margin-left: 0; +} + +blockquote p:first-child { + padding-top: 1ch; +} + +blockquote p:last-child { + padding-bottom: 1ch; +} + +blockquote blockquote { + border-left: 4px solid #b3b3b3; + padding-left: calc(2ch - 4px); + padding-right: 0; + margin-left: -4px; + border-radius: 0; +} + +/* 行内代码 */ +code { + font-family: var(--code-font), var(--ui-font), monospace; +} + +h1 code, h2 code, h3 code, h4 code, h5 code, h6 code, +p code, +li code { + color: #3c70c6; + background-color: #fefefe; + /* 阴影 */ + box-shadow: 0 0 1px 1px #c8d3df; + font-family: var(--code-font), var(--ui-font), monospace; + box-sizing: border-box; + border-right: 0px; + margin: 0 2px 0 2px; + padding: 0 2px 0 2px; + /* 圆角 */ + border-radius: 2px 2px 2px 2px; +} + +/* 代码块样式 */ +.md-fences, +.CodeMirror pre { + font-size: 1em; +} + +.CodeMirror-wrap { + /* padding: 10px; */ + font-size: 1em; +} + +.CodeMirror-code pre { + font-family: var(--code-font), var(--ui-font), monospace; +} + +/* 目录 */ +.md-toc { + font-size: var(--toc-font-size); +} + +.md-toc-content { + margin-left: 2em; + /* 修复缺失上级标题时无法递增 */ + counter-reset: toc-h2 toc-h3 toc-h4; + page-break-after: always; +} + +.md-toc-inner { + margin-left: 0 !important; + color: var(--text-color) !important; +} + +.md-toc-item { + color: var(--text-color) !important; +} + +/* 目录标题内容属性 */ +.md-toc-h2, +.md-toc-h3, +.md-toc-h4, +.md-toc-h5, +.md-toc-h6 { + font-size: var(--toc-font-size); + font-family: var(--toc-font), var(--base-Latin-font), var(--base-Chinese-font), serif; +} + +.md-toc-h2 { + font-weight: var(--strong-weight); +} + +/* 目录标题前 */ +.md-toc-content .md-toc-h1 { + display: var(--toc-show-title); + counter-reset: toc-h2; +} +.md-toc-content .md-toc-h2 { + counter-reset: toc-h3; +} +.md-toc-content .md-toc-h3 { + counter-reset: toc-h4; +} +.md-toc-content .md-toc-h4 { + counter-reset: toc-h5; +} +.md-toc-content .md-toc-h5 { + counter-reset: toc-h6; +} +.md-toc-content .md-toc-h2:before { + counter-increment: toc-h2; + content: counter(toc-h2); + margin-right: 1em; + font-weight: var(--strong-weight); +} +.md-toc-content .md-toc-h3:before { + counter-increment: toc-h3; + content: counter(toc-h2) "." counter(toc-h3); + margin-left: 1.5em; + margin-right: 0.5em; +} +.md-toc-content .md-toc-h4:before { + counter-increment: toc-h4; + content: counter(toc-h2) "." counter(toc-h3) "." counter(toc-h4); + margin-left: 3.5em; + margin-right: 0.5em; +} +.md-toc-content .md-toc-h5:before { + counter-increment: toc-h5; + content: counter(toc-h2) "." counter(toc-h3) "." counter(toc-h4) "." counter(toc-h5); + margin-left: 5.5em; + margin-right: 0.5em; +} +.md-toc-content .md-toc-h6:before { + counter-increment: toc-h6; + content: counter(toc-h2) "." counter(toc-h3) "." counter(toc-h4) "." counter(toc-h5) "." counter(toc-h6); + margin-left: 7.5em; + margin-right: 0.5em; +} diff --git a/fonts/LMROMAN10-BOLD.OTF b/fonts/LMROMAN10-BOLD.OTF new file mode 100644 index 00000000..7d6afa73 Binary files /dev/null and b/fonts/LMROMAN10-BOLD.OTF differ diff --git a/fonts/LMROMAN10-BOLDITALIC.OTF b/fonts/LMROMAN10-BOLDITALIC.OTF new file mode 100644 index 00000000..98297be4 Binary files /dev/null and b/fonts/LMROMAN10-BOLDITALIC.OTF differ diff --git a/fonts/LMROMAN10-ITALIC.OTF b/fonts/LMROMAN10-ITALIC.OTF new file mode 100644 index 00000000..b3698737 Binary files /dev/null and b/fonts/LMROMAN10-ITALIC.OTF differ diff --git a/fonts/LMROMAN10-REGULAR.OTF b/fonts/LMROMAN10-REGULAR.OTF new file mode 100644 index 00000000..6a96b468 Binary files /dev/null and b/fonts/LMROMAN10-REGULAR.OTF differ diff --git a/fonts/SIMSUN.TTC b/fonts/SIMSUN.TTC new file mode 100644 index 00000000..6ca8de3d Binary files /dev/null and b/fonts/SIMSUN.TTC differ diff --git a/fonts/STFANGSO.TTF b/fonts/STFANGSO.TTF new file mode 100644 index 00000000..441f2883 Binary files /dev/null and b/fonts/STFANGSO.TTF differ diff --git a/fonts/STKAITI.TTF b/fonts/STKAITI.TTF new file mode 100644 index 00000000..50441161 Binary files /dev/null and b/fonts/STKAITI.TTF differ diff --git a/fonts/STSONG.TTF b/fonts/STSONG.TTF new file mode 100644 index 00000000..38706053 Binary files /dev/null and b/fonts/STSONG.TTF differ diff --git a/fonts/SmileySans-Oblique.otf b/fonts/SmileySans-Oblique.otf new file mode 100644 index 00000000..38a13654 Binary files /dev/null and b/fonts/SmileySans-Oblique.otf differ diff --git a/images/AI/1713166706648.png b/images/AI/1713166706648.png new file mode 100644 index 00000000..d5ed384f Binary files /dev/null and b/images/AI/1713166706648.png differ diff --git a/images/AI/1713169419702.png b/images/AI/1713169419702.png new file mode 100644 index 00000000..f7d78f2d Binary files /dev/null and b/images/AI/1713169419702.png differ diff --git a/images/AI/1713171795959.png b/images/AI/1713171795959.png new file mode 100644 index 00000000..3663c428 Binary files /dev/null and b/images/AI/1713171795959.png differ diff --git a/images/AI/1713171808270.png b/images/AI/1713171808270.png new file mode 100644 index 00000000..7a695ce4 Binary files /dev/null and b/images/AI/1713171808270.png differ diff --git a/images/AI/1713771652191.png b/images/AI/1713771652191.png new file mode 100644 index 00000000..8e036038 Binary files /dev/null and b/images/AI/1713771652191.png differ diff --git a/images/AI/1713772489046.png b/images/AI/1713772489046.png new file mode 100644 index 00000000..9554dbf8 Binary files /dev/null and b/images/AI/1713772489046.png differ diff --git a/images/AI/1713775669844.png b/images/AI/1713775669844.png new file mode 100644 index 00000000..12d45b45 Binary files /dev/null and b/images/AI/1713775669844.png differ diff --git a/images/AI/1713776156049.png b/images/AI/1713776156049.png new file mode 100644 index 00000000..36154125 Binary files /dev/null and b/images/AI/1713776156049.png differ diff --git a/images/AI/1713776168789.png b/images/AI/1713776168789.png new file mode 100644 index 00000000..0f820b2f Binary files /dev/null and b/images/AI/1713776168789.png differ diff --git a/images/AI/1714379335929.png b/images/AI/1714379335929.png new file mode 100644 index 00000000..358757ec Binary files /dev/null and b/images/AI/1714379335929.png differ diff --git a/images/AI/1714379943169.png b/images/AI/1714379943169.png new file mode 100644 index 00000000..5671bbdb Binary files /dev/null and b/images/AI/1714379943169.png differ diff --git a/images/AI/1714380111476.png b/images/AI/1714380111476.png new file mode 100644 index 00000000..4e2c3f68 Binary files /dev/null and b/images/AI/1714380111476.png differ diff --git a/images/AI/1714380132725.png b/images/AI/1714380132725.png new file mode 100644 index 00000000..955b3b6e Binary files /dev/null and b/images/AI/1714380132725.png differ diff --git a/images/AI/1714380159356.png b/images/AI/1714380159356.png new file mode 100644 index 00000000..b89415d9 Binary files /dev/null and b/images/AI/1714380159356.png differ diff --git a/images/AI/1714380233071.png b/images/AI/1714380233071.png new file mode 100644 index 00000000..5a9a4c90 Binary files /dev/null and b/images/AI/1714380233071.png differ diff --git a/images/AI/1714380343254.png b/images/AI/1714380343254.png new file mode 100644 index 00000000..02010070 Binary files /dev/null and b/images/AI/1714380343254.png differ diff --git a/images/AI/1714380578105.png b/images/AI/1714380578105.png new file mode 100644 index 00000000..5e192cb6 Binary files /dev/null and b/images/AI/1714380578105.png differ diff --git a/images/AI/1714380763838.png b/images/AI/1714380763838.png new file mode 100644 index 00000000..9447f30c Binary files /dev/null and b/images/AI/1714380763838.png differ diff --git a/images/AI/1714982075164.png b/images/AI/1714982075164.png new file mode 100644 index 00000000..b28ac199 Binary files /dev/null and b/images/AI/1714982075164.png differ diff --git a/images/AI/1714982108981.png b/images/AI/1714982108981.png new file mode 100644 index 00000000..c2a60a5d Binary files /dev/null and b/images/AI/1714982108981.png differ diff --git a/images/AI/1714982133935.png b/images/AI/1714982133935.png new file mode 100644 index 00000000..044e3b66 Binary files /dev/null and b/images/AI/1714982133935.png differ diff --git a/images/AI/1714982188331.png b/images/AI/1714982188331.png new file mode 100644 index 00000000..c44059af Binary files /dev/null and b/images/AI/1714982188331.png differ diff --git a/images/AI/1714982215920.png b/images/AI/1714982215920.png new file mode 100644 index 00000000..b0347b16 Binary files /dev/null and b/images/AI/1714982215920.png differ diff --git a/images/AI/1714982405665.png b/images/AI/1714982405665.png new file mode 100644 index 00000000..36b74f37 Binary files /dev/null and b/images/AI/1714982405665.png differ diff --git a/images/AI/1714983390325.png b/images/AI/1714983390325.png new file mode 100644 index 00000000..c55f8e19 Binary files /dev/null and b/images/AI/1714983390325.png differ diff --git a/images/AI/1714983452419.png b/images/AI/1714983452419.png new file mode 100644 index 00000000..28908361 Binary files /dev/null and b/images/AI/1714983452419.png differ diff --git a/images/AI/1714983641507.png b/images/AI/1714983641507.png new file mode 100644 index 00000000..528111c2 Binary files /dev/null and b/images/AI/1714983641507.png differ diff --git a/images/AI/1714983788461.png b/images/AI/1714983788461.png new file mode 100644 index 00000000..e65e250c Binary files /dev/null and b/images/AI/1714983788461.png differ diff --git a/images/AI/1714983988587.png b/images/AI/1714983988587.png new file mode 100644 index 00000000..90a3b945 Binary files /dev/null and b/images/AI/1714983988587.png differ diff --git a/images/AI/1714984460020.png b/images/AI/1714984460020.png new file mode 100644 index 00000000..fa026625 Binary files /dev/null and b/images/AI/1714984460020.png differ diff --git a/images/AI/1714984778231.png b/images/AI/1714984778231.png new file mode 100644 index 00000000..8366db46 Binary files /dev/null and b/images/AI/1714984778231.png differ diff --git a/images/AI/1714985419724.png b/images/AI/1714985419724.png new file mode 100644 index 00000000..2a1766df Binary files /dev/null and b/images/AI/1714985419724.png differ diff --git a/images/AI/1714985971187.png b/images/AI/1714985971187.png new file mode 100644 index 00000000..235c0624 Binary files /dev/null and b/images/AI/1714985971187.png differ diff --git a/images/AI/1714986050538.png b/images/AI/1714986050538.png new file mode 100644 index 00000000..65f85ea0 Binary files /dev/null and b/images/AI/1714986050538.png differ diff --git a/images/Antenna/1711090268476.png b/images/Antenna/1711090268476.png new file mode 100644 index 00000000..e3b5d75f Binary files /dev/null and b/images/Antenna/1711090268476.png differ diff --git a/images/Antenna/1711090528566.png b/images/Antenna/1711090528566.png new file mode 100644 index 00000000..91b14434 Binary files /dev/null and b/images/Antenna/1711090528566.png differ diff --git a/images/Antenna/1711090565574.png b/images/Antenna/1711090565574.png new file mode 100644 index 00000000..b1c35911 Binary files /dev/null and b/images/Antenna/1711090565574.png differ diff --git a/images/Antenna/1711091202619.png b/images/Antenna/1711091202619.png new file mode 100644 index 00000000..134b196c Binary files /dev/null and b/images/Antenna/1711091202619.png differ diff --git a/images/Antenna/1711091212947.png b/images/Antenna/1711091212947.png new file mode 100644 index 00000000..596804e5 Binary files /dev/null and b/images/Antenna/1711091212947.png differ diff --git a/images/Antenna/1711693683771.png b/images/Antenna/1711693683771.png new file mode 100644 index 00000000..686818fa Binary files /dev/null and b/images/Antenna/1711693683771.png differ diff --git a/images/Antenna/1711693701192.png b/images/Antenna/1711693701192.png new file mode 100644 index 00000000..6902e5f8 Binary files /dev/null and b/images/Antenna/1711693701192.png differ diff --git a/images/Antenna/1711693749686.png b/images/Antenna/1711693749686.png new file mode 100644 index 00000000..d9f08ebe Binary files /dev/null and b/images/Antenna/1711693749686.png differ diff --git a/images/Antenna/1711693845822.png b/images/Antenna/1711693845822.png new file mode 100644 index 00000000..ae234d3b Binary files /dev/null and b/images/Antenna/1711693845822.png differ diff --git a/images/Antenna/1711693861642.png b/images/Antenna/1711693861642.png new file mode 100644 index 00000000..2f846a7c Binary files /dev/null and b/images/Antenna/1711693861642.png differ diff --git a/images/Antenna/1711693936592.png b/images/Antenna/1711693936592.png new file mode 100644 index 00000000..4f94c1f5 Binary files /dev/null and b/images/Antenna/1711693936592.png differ diff --git a/images/Antenna/1711694027177.png b/images/Antenna/1711694027177.png new file mode 100644 index 00000000..7463b94c Binary files /dev/null and b/images/Antenna/1711694027177.png differ diff --git a/images/Antenna/1711694083583.png b/images/Antenna/1711694083583.png new file mode 100644 index 00000000..02980b18 Binary files /dev/null and b/images/Antenna/1711694083583.png differ diff --git a/images/Antenna/1711694243897.png b/images/Antenna/1711694243897.png new file mode 100644 index 00000000..6feafb16 Binary files /dev/null and b/images/Antenna/1711694243897.png differ diff --git a/images/Antenna/1711694350257.png b/images/Antenna/1711694350257.png new file mode 100644 index 00000000..32c4a8c8 Binary files /dev/null and b/images/Antenna/1711694350257.png differ diff --git a/images/Antenna/1711694462059.png b/images/Antenna/1711694462059.png new file mode 100644 index 00000000..56a7658e Binary files /dev/null and b/images/Antenna/1711694462059.png differ diff --git a/images/Antenna/1711694619870.png b/images/Antenna/1711694619870.png new file mode 100644 index 00000000..8e66a93c Binary files /dev/null and b/images/Antenna/1711694619870.png differ diff --git a/images/Antenna/1711694639638.png b/images/Antenna/1711694639638.png new file mode 100644 index 00000000..acef199d Binary files /dev/null and b/images/Antenna/1711694639638.png differ diff --git a/images/Antenna/1711695738159.png b/images/Antenna/1711695738159.png new file mode 100644 index 00000000..5b6fc5b0 Binary files /dev/null and b/images/Antenna/1711695738159.png differ diff --git a/images/Antenna/1712471419276.png b/images/Antenna/1712471419276.png new file mode 100644 index 00000000..0b4e6651 Binary files /dev/null and b/images/Antenna/1712471419276.png differ diff --git a/images/Antenna/1712471436962.png b/images/Antenna/1712471436962.png new file mode 100644 index 00000000..34f74a61 Binary files /dev/null and b/images/Antenna/1712471436962.png differ diff --git a/images/Antenna/1712471499226.png b/images/Antenna/1712471499226.png new file mode 100644 index 00000000..d325a749 Binary files /dev/null and b/images/Antenna/1712471499226.png differ diff --git a/images/Antenna/1712473473687.png b/images/Antenna/1712473473687.png new file mode 100644 index 00000000..0b7d8237 Binary files /dev/null and b/images/Antenna/1712473473687.png differ diff --git a/images/Antenna/1712900712333.png b/images/Antenna/1712900712333.png new file mode 100644 index 00000000..e02e8f6d Binary files /dev/null and b/images/Antenna/1712900712333.png differ diff --git a/images/Antenna/1712901375924.png b/images/Antenna/1712901375924.png new file mode 100644 index 00000000..041aab72 Binary files /dev/null and b/images/Antenna/1712901375924.png differ diff --git a/images/Antenna/1712902160882.png b/images/Antenna/1712902160882.png new file mode 100644 index 00000000..2fec465e Binary files /dev/null and b/images/Antenna/1712902160882.png differ diff --git a/images/Antenna/1712903308547.png b/images/Antenna/1712903308547.png new file mode 100644 index 00000000..ceff3d56 Binary files /dev/null and b/images/Antenna/1712903308547.png differ diff --git a/images/Antenna/1712905110844.png b/images/Antenna/1712905110844.png new file mode 100644 index 00000000..fcbccef9 Binary files /dev/null and b/images/Antenna/1712905110844.png differ diff --git a/images/Antenna/1712905233876.png b/images/Antenna/1712905233876.png new file mode 100644 index 00000000..37a1f0b0 Binary files /dev/null and b/images/Antenna/1712905233876.png differ diff --git a/images/Antenna/1712905317317.png b/images/Antenna/1712905317317.png new file mode 100644 index 00000000..3abc04e4 Binary files /dev/null and b/images/Antenna/1712905317317.png differ diff --git a/images/Antenna/1713506228135.png b/images/Antenna/1713506228135.png new file mode 100644 index 00000000..3c62ad6b Binary files /dev/null and b/images/Antenna/1713506228135.png differ diff --git a/images/Antenna/1713506258888.png b/images/Antenna/1713506258888.png new file mode 100644 index 00000000..707f712c Binary files /dev/null and b/images/Antenna/1713506258888.png differ diff --git a/images/Antenna/1713506275022.png b/images/Antenna/1713506275022.png new file mode 100644 index 00000000..3aa3898f Binary files /dev/null and b/images/Antenna/1713506275022.png differ diff --git a/images/Antenna/1713506363705.png b/images/Antenna/1713506363705.png new file mode 100644 index 00000000..718b6212 Binary files /dev/null and b/images/Antenna/1713506363705.png differ diff --git a/images/Antenna/1713506837120.png b/images/Antenna/1713506837120.png new file mode 100644 index 00000000..e9c29353 Binary files /dev/null and b/images/Antenna/1713506837120.png differ diff --git a/images/Antenna/1713506921640.png b/images/Antenna/1713506921640.png new file mode 100644 index 00000000..dcde7246 Binary files /dev/null and b/images/Antenna/1713506921640.png differ diff --git a/images/Antenna/1713507175699.png b/images/Antenna/1713507175699.png new file mode 100644 index 00000000..df1fa64b Binary files /dev/null and b/images/Antenna/1713507175699.png differ diff --git a/images/Antenna/1713507190746.png b/images/Antenna/1713507190746.png new file mode 100644 index 00000000..f58ae2cf Binary files /dev/null and b/images/Antenna/1713507190746.png differ diff --git a/images/Antenna/1713507205996.png b/images/Antenna/1713507205996.png new file mode 100644 index 00000000..924a6bb8 Binary files /dev/null and b/images/Antenna/1713507205996.png differ diff --git a/images/Antenna/1713508252106.png b/images/Antenna/1713508252106.png new file mode 100644 index 00000000..9575782a Binary files /dev/null and b/images/Antenna/1713508252106.png differ diff --git a/images/Antenna/1713508379111.png b/images/Antenna/1713508379111.png new file mode 100644 index 00000000..2b04a188 Binary files /dev/null and b/images/Antenna/1713508379111.png differ diff --git a/images/Antenna/1713508669926.png b/images/Antenna/1713508669926.png new file mode 100644 index 00000000..c1eb4f9a Binary files /dev/null and b/images/Antenna/1713508669926.png differ diff --git a/images/Antenna/1713508784675.png b/images/Antenna/1713508784675.png new file mode 100644 index 00000000..65ae21a1 Binary files /dev/null and b/images/Antenna/1713508784675.png differ diff --git a/images/Antenna/1713509120707.png b/images/Antenna/1713509120707.png new file mode 100644 index 00000000..ad0f5cef Binary files /dev/null and b/images/Antenna/1713509120707.png differ diff --git a/images/Antenna/1713509734724.png b/images/Antenna/1713509734724.png new file mode 100644 index 00000000..4eca6c31 Binary files /dev/null and b/images/Antenna/1713509734724.png differ diff --git a/images/Antenna/1713509771675.png b/images/Antenna/1713509771675.png new file mode 100644 index 00000000..050a095f Binary files /dev/null and b/images/Antenna/1713509771675.png differ diff --git a/images/DRL/1712925351346.png b/images/DRL/1712925351346.png new file mode 100644 index 00000000..879e07ce Binary files /dev/null and b/images/DRL/1712925351346.png differ diff --git a/images/DRL/1712925354266.png b/images/DRL/1712925354266.png new file mode 100644 index 00000000..879e07ce Binary files /dev/null and b/images/DRL/1712925354266.png differ diff --git a/images/DSA/Dijkstra.jpg b/images/DSA/Dijkstra.jpg new file mode 100644 index 00000000..fc96f124 Binary files /dev/null and b/images/DSA/Dijkstra.jpg differ diff --git a/images/DSA/Duopule.jpg b/images/DSA/Duopule.jpg new file mode 100644 index 00000000..dcb1cf00 Binary files /dev/null and b/images/DSA/Duopule.jpg differ diff --git a/images/DSA/Kruskal.jpg b/images/DSA/Kruskal.jpg new file mode 100644 index 00000000..e4ce9851 Binary files /dev/null and b/images/DSA/Kruskal.jpg differ diff --git a/images/DSA/Prim.jpg b/images/DSA/Prim.jpg new file mode 100644 index 00000000..6aa11b09 Binary files /dev/null and b/images/DSA/Prim.jpg differ diff --git a/images/DSA/waveDuopl.jpg b/images/DSA/waveDuopl.jpg new file mode 100644 index 00000000..667a1f9c Binary files /dev/null and b/images/DSA/waveDuopl.jpg differ diff --git a/images/DSD/2_1.jpg b/images/DSD/2_1.jpg new file mode 100644 index 00000000..54ec0863 Binary files /dev/null and b/images/DSD/2_1.jpg differ diff --git a/images/DSD/2_2.jpg b/images/DSD/2_2.jpg new file mode 100644 index 00000000..98346183 Binary files /dev/null and b/images/DSD/2_2.jpg differ diff --git a/images/DSD/2_3.jpg b/images/DSD/2_3.jpg new file mode 100644 index 00000000..81f76dd9 Binary files /dev/null and b/images/DSD/2_3.jpg differ diff --git a/images/DSD/2_4.jpg b/images/DSD/2_4.jpg new file mode 100644 index 00000000..abe32b06 Binary files /dev/null and b/images/DSD/2_4.jpg differ diff --git a/images/DSD/3_1.jpg b/images/DSD/3_1.jpg new file mode 100644 index 00000000..ea8bee23 Binary files /dev/null and b/images/DSD/3_1.jpg differ diff --git a/images/DSD/3_10.jpg b/images/DSD/3_10.jpg new file mode 100644 index 00000000..8866cafd Binary files /dev/null and b/images/DSD/3_10.jpg differ diff --git a/images/DSD/3_2.jpg b/images/DSD/3_2.jpg new file mode 100644 index 00000000..5ec716b2 Binary files /dev/null and b/images/DSD/3_2.jpg differ diff --git a/images/DSD/3_3.jpg b/images/DSD/3_3.jpg new file mode 100644 index 00000000..20a99f5b Binary files /dev/null and b/images/DSD/3_3.jpg differ diff --git a/images/DSD/3_4.jpg b/images/DSD/3_4.jpg new file mode 100644 index 00000000..5ca18dbb Binary files /dev/null and b/images/DSD/3_4.jpg differ diff --git a/images/DSD/3_5.jpg b/images/DSD/3_5.jpg new file mode 100644 index 00000000..34eecb22 Binary files /dev/null and b/images/DSD/3_5.jpg differ diff --git a/images/DSD/3_6.jpg b/images/DSD/3_6.jpg new file mode 100644 index 00000000..9bfaada0 Binary files /dev/null and b/images/DSD/3_6.jpg differ diff --git a/images/DSD/3_7.jpg b/images/DSD/3_7.jpg new file mode 100644 index 00000000..4228d271 Binary files /dev/null and b/images/DSD/3_7.jpg differ diff --git a/images/DSD/3_8.jpg b/images/DSD/3_8.jpg new file mode 100644 index 00000000..c74d08ad Binary files /dev/null and b/images/DSD/3_8.jpg differ diff --git a/images/DSD/3_9.jpg b/images/DSD/3_9.jpg new file mode 100644 index 00000000..93d0166e Binary files /dev/null and b/images/DSD/3_9.jpg differ diff --git a/images/DSD/4_1.jpg b/images/DSD/4_1.jpg new file mode 100644 index 00000000..8772987b Binary files /dev/null and b/images/DSD/4_1.jpg differ diff --git a/images/DSD/4_10.jpg b/images/DSD/4_10.jpg new file mode 100644 index 00000000..fc93d857 Binary files /dev/null and b/images/DSD/4_10.jpg differ diff --git a/images/DSD/4_2.jpg b/images/DSD/4_2.jpg new file mode 100644 index 00000000..7a440e0f Binary files /dev/null and b/images/DSD/4_2.jpg differ diff --git a/images/DSD/4_3.jpg b/images/DSD/4_3.jpg new file mode 100644 index 00000000..019517d5 Binary files /dev/null and b/images/DSD/4_3.jpg differ diff --git a/images/DSD/4_4.jpg b/images/DSD/4_4.jpg new file mode 100644 index 00000000..e5277942 Binary files /dev/null and b/images/DSD/4_4.jpg differ diff --git a/images/DSD/4_5.jpg b/images/DSD/4_5.jpg new file mode 100644 index 00000000..64a4239e Binary files /dev/null and b/images/DSD/4_5.jpg differ diff --git a/images/DSD/4_6.jpg b/images/DSD/4_6.jpg new file mode 100644 index 00000000..30af2a51 Binary files /dev/null and b/images/DSD/4_6.jpg differ diff --git a/images/DSD/4_7.jpg b/images/DSD/4_7.jpg new file mode 100644 index 00000000..7bc297a8 Binary files /dev/null and b/images/DSD/4_7.jpg differ diff --git a/images/DSD/4_8.jpg b/images/DSD/4_8.jpg new file mode 100644 index 00000000..d689c9c2 Binary files /dev/null and b/images/DSD/4_8.jpg differ diff --git a/images/DSD/4_9.jpg b/images/DSD/4_9.jpg new file mode 100644 index 00000000..5b61cf77 Binary files /dev/null and b/images/DSD/4_9.jpg differ diff --git a/images/DSP/4_2.jpg b/images/DSP/4_2.jpg new file mode 100644 index 00000000..42e1a9e3 Binary files /dev/null and b/images/DSP/4_2.jpg differ diff --git a/images/DSP/5_1.jpg b/images/DSP/5_1.jpg new file mode 100644 index 00000000..686eac04 Binary files /dev/null and b/images/DSP/5_1.jpg differ diff --git a/images/DSP/5_2.jpg b/images/DSP/5_2.jpg new file mode 100644 index 00000000..067cd365 Binary files /dev/null and b/images/DSP/5_2.jpg differ diff --git a/images/OS/1713266591628.png b/images/OS/1713266591628.png new file mode 100644 index 00000000..33cd77f7 Binary files /dev/null and b/images/OS/1713266591628.png differ diff --git a/images/SolidPhysics/1713233318260.png b/images/SolidPhysics/1713233318260.png new file mode 100644 index 00000000..95046e24 Binary files /dev/null and b/images/SolidPhysics/1713233318260.png differ diff --git a/images/SolidPhysics/1713234834861.png b/images/SolidPhysics/1713234834861.png new file mode 100644 index 00000000..20881cbc Binary files /dev/null and b/images/SolidPhysics/1713234834861.png differ diff --git a/images/SolidPhysics/1713234874686.png b/images/SolidPhysics/1713234874686.png new file mode 100644 index 00000000..26b9bb0b Binary files /dev/null and b/images/SolidPhysics/1713234874686.png differ diff --git a/images/SolidPhysics/1713235941206.png b/images/SolidPhysics/1713235941206.png new file mode 100644 index 00000000..ad4b2395 Binary files /dev/null and b/images/SolidPhysics/1713235941206.png differ diff --git a/images/SolidPhysics/1713236189430.png b/images/SolidPhysics/1713236189430.png new file mode 100644 index 00000000..b7869c64 Binary files /dev/null and b/images/SolidPhysics/1713236189430.png differ diff --git a/images/SolidPhysics/1713236233045.png b/images/SolidPhysics/1713236233045.png new file mode 100644 index 00000000..075aca26 Binary files /dev/null and b/images/SolidPhysics/1713236233045.png differ diff --git a/images/SolidPhysics/1713236269885.png b/images/SolidPhysics/1713236269885.png new file mode 100644 index 00000000..d527299a Binary files /dev/null and b/images/SolidPhysics/1713236269885.png differ diff --git a/images/SolidPhysics/1713236929581.png b/images/SolidPhysics/1713236929581.png new file mode 100644 index 00000000..5f9bcc87 Binary files /dev/null and b/images/SolidPhysics/1713236929581.png differ diff --git a/images/SolidPhysics/1713236984022.png b/images/SolidPhysics/1713236984022.png new file mode 100644 index 00000000..f3643795 Binary files /dev/null and b/images/SolidPhysics/1713236984022.png differ diff --git a/images/SolidPhysics/1713237051369.png b/images/SolidPhysics/1713237051369.png new file mode 100644 index 00000000..0fbf59dd Binary files /dev/null and b/images/SolidPhysics/1713237051369.png differ diff --git a/images/SolidPhysics/1713237069207.png b/images/SolidPhysics/1713237069207.png new file mode 100644 index 00000000..5adf7ee9 Binary files /dev/null and b/images/SolidPhysics/1713237069207.png differ diff --git a/images/SolidPhysics/1713237158982.png b/images/SolidPhysics/1713237158982.png new file mode 100644 index 00000000..1ae91669 Binary files /dev/null and b/images/SolidPhysics/1713237158982.png differ diff --git a/images/SolidPhysics/1713237357342.png b/images/SolidPhysics/1713237357342.png new file mode 100644 index 00000000..3a59ab8d Binary files /dev/null and b/images/SolidPhysics/1713237357342.png differ diff --git a/images/SolidPhysics/1713239832006.png b/images/SolidPhysics/1713239832006.png new file mode 100644 index 00000000..6e47df8b Binary files /dev/null and b/images/SolidPhysics/1713239832006.png differ diff --git a/images/SolidPhysics/1713240457384.png b/images/SolidPhysics/1713240457384.png new file mode 100644 index 00000000..b7ed5060 Binary files /dev/null and b/images/SolidPhysics/1713240457384.png differ diff --git a/images/SolidPhysics/1715047577458.png b/images/SolidPhysics/1715047577458.png new file mode 100644 index 00000000..7824373e Binary files /dev/null and b/images/SolidPhysics/1715047577458.png differ diff --git a/images/SolidPhysics/1715048162767.png b/images/SolidPhysics/1715048162767.png new file mode 100644 index 00000000..203f47b9 Binary files /dev/null and b/images/SolidPhysics/1715048162767.png differ diff --git a/images/SolidPhysics/1715048234147.png b/images/SolidPhysics/1715048234147.png new file mode 100644 index 00000000..b46cec23 Binary files /dev/null and b/images/SolidPhysics/1715048234147.png differ diff --git a/images/SolidPhysics/1715048857194.png b/images/SolidPhysics/1715048857194.png new file mode 100644 index 00000000..1cef4d31 Binary files /dev/null and b/images/SolidPhysics/1715048857194.png differ diff --git a/images/SolidPhysics/1715050052696.png b/images/SolidPhysics/1715050052696.png new file mode 100644 index 00000000..cb3697d7 Binary files /dev/null and b/images/SolidPhysics/1715050052696.png differ diff --git a/images/SolidPhysics/1715051145151.png b/images/SolidPhysics/1715051145151.png new file mode 100644 index 00000000..70dc818e Binary files /dev/null and b/images/SolidPhysics/1715051145151.png differ diff --git a/images/SolidPhysics/1715051313166.png b/images/SolidPhysics/1715051313166.png new file mode 100644 index 00000000..a6947482 Binary files /dev/null and b/images/SolidPhysics/1715051313166.png differ diff --git a/images/SolidPhysics/1715052169711.png b/images/SolidPhysics/1715052169711.png new file mode 100644 index 00000000..65bb20e1 Binary files /dev/null and b/images/SolidPhysics/1715052169711.png differ diff --git a/images/SolidPhysics/1715053184570.png b/images/SolidPhysics/1715053184570.png new file mode 100644 index 00000000..bd075966 Binary files /dev/null and b/images/SolidPhysics/1715053184570.png differ diff --git a/images/SolidPhysics/1715053408715.png b/images/SolidPhysics/1715053408715.png new file mode 100644 index 00000000..b0419e6b Binary files /dev/null and b/images/SolidPhysics/1715053408715.png differ diff --git a/images/SolidPhysics/1715053936706.png b/images/SolidPhysics/1715053936706.png new file mode 100644 index 00000000..11949c94 Binary files /dev/null and b/images/SolidPhysics/1715053936706.png differ diff --git a/images/Speech-SP/1713958735363.png b/images/Speech-SP/1713958735363.png new file mode 100644 index 00000000..c9686fec Binary files /dev/null and b/images/Speech-SP/1713958735363.png differ diff --git a/images/Speech-SP/1713958768829.png b/images/Speech-SP/1713958768829.png new file mode 100644 index 00000000..a6f7a8ca Binary files /dev/null and b/images/Speech-SP/1713958768829.png differ diff --git a/images/Speech-SP/1713959362056.png b/images/Speech-SP/1713959362056.png new file mode 100644 index 00000000..d30c7ee5 Binary files /dev/null and b/images/Speech-SP/1713959362056.png differ diff --git a/images/Speech-SP/1713960064882.png b/images/Speech-SP/1713960064882.png new file mode 100644 index 00000000..ccb4b6f6 Binary files /dev/null and b/images/Speech-SP/1713960064882.png differ diff --git a/images/Speech-SP/1713960093567.png b/images/Speech-SP/1713960093567.png new file mode 100644 index 00000000..3678f8cc Binary files /dev/null and b/images/Speech-SP/1713960093567.png differ diff --git a/images/Speech-SP/1713961039467.png b/images/Speech-SP/1713961039467.png new file mode 100644 index 00000000..afc10b1b Binary files /dev/null and b/images/Speech-SP/1713961039467.png differ diff --git a/images/Speech-SP/1713962223184.png b/images/Speech-SP/1713962223184.png new file mode 100644 index 00000000..df189b61 Binary files /dev/null and b/images/Speech-SP/1713962223184.png differ diff --git a/images/Speech-SP/1713963710139.png b/images/Speech-SP/1713963710139.png new file mode 100644 index 00000000..e05fcdd4 Binary files /dev/null and b/images/Speech-SP/1713963710139.png differ diff --git a/images/Speech-SP/1713963726242.png b/images/Speech-SP/1713963726242.png new file mode 100644 index 00000000..3e55ed8a Binary files /dev/null and b/images/Speech-SP/1713963726242.png differ diff --git a/images/Speech-SP/1713963786950.png b/images/Speech-SP/1713963786950.png new file mode 100644 index 00000000..7452356e Binary files /dev/null and b/images/Speech-SP/1713963786950.png differ diff --git a/images/Speech-SP/1713963998639.png b/images/Speech-SP/1713963998639.png new file mode 100644 index 00000000..62051830 Binary files /dev/null and b/images/Speech-SP/1713963998639.png differ diff --git a/images/Speech-SP/1713965424496.png b/images/Speech-SP/1713965424496.png new file mode 100644 index 00000000..ddf8f679 Binary files /dev/null and b/images/Speech-SP/1713965424496.png differ diff --git a/images/StaSP/1711254850893.png b/images/StaSP/1711254850893.png new file mode 100644 index 00000000..c995e3db Binary files /dev/null and b/images/StaSP/1711254850893.png differ diff --git a/images/StaSP/1711255303038.png b/images/StaSP/1711255303038.png new file mode 100644 index 00000000..7289f69a Binary files /dev/null and b/images/StaSP/1711255303038.png differ diff --git a/images/StaSP/1711339154789.png b/images/StaSP/1711339154789.png new file mode 100644 index 00000000..dc126ef5 Binary files /dev/null and b/images/StaSP/1711339154789.png differ diff --git a/images/StaSP/1711339192281.png b/images/StaSP/1711339192281.png new file mode 100644 index 00000000..8b862a95 Binary files /dev/null and b/images/StaSP/1711339192281.png differ diff --git a/images/StaSP/1711339216759.png b/images/StaSP/1711339216759.png new file mode 100644 index 00000000..470e2414 Binary files /dev/null and b/images/StaSP/1711339216759.png differ diff --git a/images/StaSP/1711339249863.png b/images/StaSP/1711339249863.png new file mode 100644 index 00000000..266ea546 Binary files /dev/null and b/images/StaSP/1711339249863.png differ diff --git a/images/StaSP/1711339773571.png b/images/StaSP/1711339773571.png new file mode 100644 index 00000000..bde773df Binary files /dev/null and b/images/StaSP/1711339773571.png differ diff --git a/images/StaSP/1711339786814.png b/images/StaSP/1711339786814.png new file mode 100644 index 00000000..4143d8aa Binary files /dev/null and b/images/StaSP/1711339786814.png differ diff --git a/images/StaSP/1711339831807.png b/images/StaSP/1711339831807.png new file mode 100644 index 00000000..da2226ec Binary files /dev/null and b/images/StaSP/1711339831807.png differ diff --git a/images/StaSP/1711339865703.png b/images/StaSP/1711339865703.png new file mode 100644 index 00000000..d7240c5b Binary files /dev/null and b/images/StaSP/1711339865703.png differ diff --git a/images/StaSP/1711340151724.png b/images/StaSP/1711340151724.png new file mode 100644 index 00000000..72d3be84 Binary files /dev/null and b/images/StaSP/1711340151724.png differ diff --git a/images/StaSP/1711340163113.png b/images/StaSP/1711340163113.png new file mode 100644 index 00000000..01df7af8 Binary files /dev/null and b/images/StaSP/1711340163113.png differ diff --git a/images/StaSP/1711340177961.png b/images/StaSP/1711340177961.png new file mode 100644 index 00000000..c79bfe75 Binary files /dev/null and b/images/StaSP/1711340177961.png differ diff --git a/images/StaSP/1711340277148.png b/images/StaSP/1711340277148.png new file mode 100644 index 00000000..a2bc2ffe Binary files /dev/null and b/images/StaSP/1711340277148.png differ diff --git a/images/StaSP/1711340293644.png b/images/StaSP/1711340293644.png new file mode 100644 index 00000000..e8a9468c Binary files /dev/null and b/images/StaSP/1711340293644.png differ diff --git a/images/StaSP/1712549632251.png b/images/StaSP/1712549632251.png new file mode 100644 index 00000000..b2d970f7 Binary files /dev/null and b/images/StaSP/1712549632251.png differ diff --git a/images/StaSP/1712549637885.png b/images/StaSP/1712549637885.png new file mode 100644 index 00000000..b2d970f7 Binary files /dev/null and b/images/StaSP/1712549637885.png differ diff --git a/images/StaSP/1713066463994.png b/images/StaSP/1713066463994.png new file mode 100644 index 00000000..b9243f78 Binary files /dev/null and b/images/StaSP/1713066463994.png differ diff --git a/images/StaSP/1713150631533.png b/images/StaSP/1713150631533.png new file mode 100644 index 00000000..0dd00782 Binary files /dev/null and b/images/StaSP/1713150631533.png differ diff --git a/images/StaSP/1713150674892.png b/images/StaSP/1713150674892.png new file mode 100644 index 00000000..e22855c6 Binary files /dev/null and b/images/StaSP/1713150674892.png differ diff --git a/images/StaSP/1713150692811.png b/images/StaSP/1713150692811.png new file mode 100644 index 00000000..0b2481aa Binary files /dev/null and b/images/StaSP/1713150692811.png differ diff --git a/images/StaSP/1713150769252.png b/images/StaSP/1713150769252.png new file mode 100644 index 00000000..20829229 Binary files /dev/null and b/images/StaSP/1713150769252.png differ diff --git a/images/StaSP/1713151589324.png b/images/StaSP/1713151589324.png new file mode 100644 index 00000000..f0017201 Binary files /dev/null and b/images/StaSP/1713151589324.png differ diff --git a/images/StaSP/1713152016025.png b/images/StaSP/1713152016025.png new file mode 100644 index 00000000..172d295e Binary files /dev/null and b/images/StaSP/1713152016025.png differ diff --git a/images/StaSP/1713152970273.png b/images/StaSP/1713152970273.png new file mode 100644 index 00000000..f3e45d4d Binary files /dev/null and b/images/StaSP/1713152970273.png differ diff --git a/images/StaSP/1713152987612.png b/images/StaSP/1713152987612.png new file mode 100644 index 00000000..5f964cc7 Binary files /dev/null and b/images/StaSP/1713152987612.png differ diff --git a/images/StaSP/1714360717248.png b/images/StaSP/1714360717248.png new file mode 100644 index 00000000..ec34b5fe Binary files /dev/null and b/images/StaSP/1714360717248.png differ diff --git a/images/StaSP/1714360742651.png b/images/StaSP/1714360742651.png new file mode 100644 index 00000000..67ad6ec8 Binary files /dev/null and b/images/StaSP/1714360742651.png differ diff --git a/images/StaSP/1714360782259.png b/images/StaSP/1714360782259.png new file mode 100644 index 00000000..0447c528 Binary files /dev/null and b/images/StaSP/1714360782259.png differ diff --git a/images/StaSP/1714360809348.png b/images/StaSP/1714360809348.png new file mode 100644 index 00000000..02929a22 Binary files /dev/null and b/images/StaSP/1714360809348.png differ diff --git a/images/StaSP/1714361011137.png b/images/StaSP/1714361011137.png new file mode 100644 index 00000000..21a548fc Binary files /dev/null and b/images/StaSP/1714361011137.png differ diff --git a/images/StaSP/1714361027958.png b/images/StaSP/1714361027958.png new file mode 100644 index 00000000..248d702a Binary files /dev/null and b/images/StaSP/1714361027958.png differ diff --git a/images/StaSP/1714966200160.png b/images/StaSP/1714966200160.png new file mode 100644 index 00000000..bcaaf697 Binary files /dev/null and b/images/StaSP/1714966200160.png differ diff --git a/images/StaSP/1714966226811.png b/images/StaSP/1714966226811.png new file mode 100644 index 00000000..b4311faa Binary files /dev/null and b/images/StaSP/1714966226811.png differ diff --git a/images/StaSP/1714966230536.png b/images/StaSP/1714966230536.png new file mode 100644 index 00000000..b4311faa Binary files /dev/null and b/images/StaSP/1714966230536.png differ diff --git a/images/StaSP/1_1.jpg b/images/StaSP/1_1.jpg new file mode 100644 index 00000000..925ac496 Binary files /dev/null and b/images/StaSP/1_1.jpg differ diff --git a/images/StaSP/2_1.jpg b/images/StaSP/2_1.jpg new file mode 100644 index 00000000..b625c3cf Binary files /dev/null and b/images/StaSP/2_1.jpg differ diff --git a/images/StaSP/2_2.png b/images/StaSP/2_2.png new file mode 100644 index 00000000..4e8bf667 Binary files /dev/null and b/images/StaSP/2_2.png differ diff --git a/images/avatar.jpg b/images/avatar.jpg new file mode 100644 index 00000000..6ba08c0a Binary files /dev/null and b/images/avatar.jpg differ diff --git a/images/csapp1.jpg b/images/csapp1.jpg new file mode 100644 index 00000000..25ea1a9e Binary files /dev/null and b/images/csapp1.jpg differ diff --git a/images/digital/lec_10_1.jpg b/images/digital/lec_10_1.jpg new file mode 100644 index 00000000..6411afb3 Binary files /dev/null and b/images/digital/lec_10_1.jpg differ diff --git a/images/digital/lec_10_10.jpg b/images/digital/lec_10_10.jpg new file mode 100644 index 00000000..7f453380 Binary files /dev/null and b/images/digital/lec_10_10.jpg differ diff --git a/images/digital/lec_10_2.jpg b/images/digital/lec_10_2.jpg new file mode 100644 index 00000000..627e2c69 Binary files /dev/null and b/images/digital/lec_10_2.jpg differ diff --git a/images/digital/lec_10_3.jpg b/images/digital/lec_10_3.jpg new file mode 100644 index 00000000..10fa02d1 Binary files /dev/null and b/images/digital/lec_10_3.jpg differ diff --git a/images/digital/lec_10_4.jpg b/images/digital/lec_10_4.jpg new file mode 100644 index 00000000..53a85476 Binary files /dev/null and b/images/digital/lec_10_4.jpg differ diff --git a/images/digital/lec_10_5.jpg b/images/digital/lec_10_5.jpg new file mode 100644 index 00000000..2d356d4a Binary files /dev/null and b/images/digital/lec_10_5.jpg differ diff --git a/images/digital/lec_10_6.jpg b/images/digital/lec_10_6.jpg new file mode 100644 index 00000000..8e0198f3 Binary files /dev/null and b/images/digital/lec_10_6.jpg differ diff --git a/images/digital/lec_10_7.jpg b/images/digital/lec_10_7.jpg new file mode 100644 index 00000000..04e0140c Binary files /dev/null and b/images/digital/lec_10_7.jpg differ diff --git a/images/digital/lec_10_8.jpg b/images/digital/lec_10_8.jpg new file mode 100644 index 00000000..71c959a1 Binary files /dev/null and b/images/digital/lec_10_8.jpg differ diff --git a/images/digital/lec_10_9.jpg b/images/digital/lec_10_9.jpg new file mode 100644 index 00000000..b22698f3 Binary files /dev/null and b/images/digital/lec_10_9.jpg differ diff --git a/images/digital/lec_11_1.jpg b/images/digital/lec_11_1.jpg new file mode 100644 index 00000000..ab8031d5 Binary files /dev/null and b/images/digital/lec_11_1.jpg differ diff --git a/images/digital/lec_12_1.jpg b/images/digital/lec_12_1.jpg new file mode 100644 index 00000000..60bb3794 Binary files /dev/null and b/images/digital/lec_12_1.jpg differ diff --git a/images/digital/lec_12_2.jpg b/images/digital/lec_12_2.jpg new file mode 100644 index 00000000..f0d85d6e Binary files /dev/null and b/images/digital/lec_12_2.jpg differ diff --git a/images/digital/lec_12_3.jpg b/images/digital/lec_12_3.jpg new file mode 100644 index 00000000..c586c8be Binary files /dev/null and b/images/digital/lec_12_3.jpg differ diff --git a/images/digital/lec_12_4.jpg b/images/digital/lec_12_4.jpg new file mode 100644 index 00000000..488fe19d Binary files /dev/null and b/images/digital/lec_12_4.jpg differ diff --git a/images/digital/lec_12_5.jpg b/images/digital/lec_12_5.jpg new file mode 100644 index 00000000..1fb2d92c Binary files /dev/null and b/images/digital/lec_12_5.jpg differ diff --git a/images/digital/lec_12_6.jpg b/images/digital/lec_12_6.jpg new file mode 100644 index 00000000..68d2e69b Binary files /dev/null and b/images/digital/lec_12_6.jpg differ diff --git a/images/digital/lec_3_1.jpg b/images/digital/lec_3_1.jpg new file mode 100644 index 00000000..7d1d9da8 Binary files /dev/null and b/images/digital/lec_3_1.jpg differ diff --git a/images/digital/lec_4_1.jpg b/images/digital/lec_4_1.jpg new file mode 100644 index 00000000..d68d2879 Binary files /dev/null and b/images/digital/lec_4_1.jpg differ diff --git a/images/digital/lec_4_1.jpg8.jpg b/images/digital/lec_4_1.jpg8.jpg new file mode 100644 index 00000000..10e9f427 Binary files /dev/null and b/images/digital/lec_4_1.jpg8.jpg differ diff --git a/images/digital/lec_4_10.jpg b/images/digital/lec_4_10.jpg new file mode 100644 index 00000000..e6a99d33 Binary files /dev/null and b/images/digital/lec_4_10.jpg differ diff --git a/images/digital/lec_4_11.jpg b/images/digital/lec_4_11.jpg new file mode 100644 index 00000000..4ea6a63b Binary files /dev/null and b/images/digital/lec_4_11.jpg differ diff --git a/images/digital/lec_4_12.jpg b/images/digital/lec_4_12.jpg new file mode 100644 index 00000000..0a221cfd Binary files /dev/null and b/images/digital/lec_4_12.jpg differ diff --git a/images/digital/lec_4_13.jpg b/images/digital/lec_4_13.jpg new file mode 100644 index 00000000..d320ad2b Binary files /dev/null and b/images/digital/lec_4_13.jpg differ diff --git a/images/digital/lec_4_14.jpg b/images/digital/lec_4_14.jpg new file mode 100644 index 00000000..8820dd7b Binary files /dev/null and b/images/digital/lec_4_14.jpg differ diff --git a/images/digital/lec_4_15.jpg b/images/digital/lec_4_15.jpg new file mode 100644 index 00000000..67231a8f Binary files /dev/null and b/images/digital/lec_4_15.jpg differ diff --git a/images/digital/lec_4_16.jpg b/images/digital/lec_4_16.jpg new file mode 100644 index 00000000..28334965 Binary files /dev/null and b/images/digital/lec_4_16.jpg differ diff --git a/images/digital/lec_4_17.jpg b/images/digital/lec_4_17.jpg new file mode 100644 index 00000000..d8bc2f73 Binary files /dev/null and b/images/digital/lec_4_17.jpg differ diff --git a/images/digital/lec_4_2.jpg b/images/digital/lec_4_2.jpg new file mode 100644 index 00000000..4fc7bfdd Binary files /dev/null and b/images/digital/lec_4_2.jpg differ diff --git a/images/digital/lec_4_3.jpg b/images/digital/lec_4_3.jpg new file mode 100644 index 00000000..bd02bdba Binary files /dev/null and b/images/digital/lec_4_3.jpg differ diff --git a/images/digital/lec_4_4.jpg b/images/digital/lec_4_4.jpg new file mode 100644 index 00000000..0cfde19b Binary files /dev/null and b/images/digital/lec_4_4.jpg differ diff --git a/images/digital/lec_4_5.jpg b/images/digital/lec_4_5.jpg new file mode 100644 index 00000000..10f67218 Binary files /dev/null and b/images/digital/lec_4_5.jpg differ diff --git a/images/digital/lec_4_6.jpg b/images/digital/lec_4_6.jpg new file mode 100644 index 00000000..8907c6d2 Binary files /dev/null and b/images/digital/lec_4_6.jpg differ diff --git a/images/digital/lec_4_7.jpg b/images/digital/lec_4_7.jpg new file mode 100644 index 00000000..6cd24eb7 Binary files /dev/null and b/images/digital/lec_4_7.jpg differ diff --git a/images/digital/lec_4_8.jpg b/images/digital/lec_4_8.jpg new file mode 100644 index 00000000..daae1d40 Binary files /dev/null and b/images/digital/lec_4_8.jpg differ diff --git a/images/digital/lec_4_9.jpg b/images/digital/lec_4_9.jpg new file mode 100644 index 00000000..ee90e06f Binary files /dev/null and b/images/digital/lec_4_9.jpg differ diff --git a/images/digital/lec_5_1.jpg b/images/digital/lec_5_1.jpg new file mode 100644 index 00000000..17ff3923 Binary files /dev/null and b/images/digital/lec_5_1.jpg differ diff --git a/images/digital/lec_5_10.jpg b/images/digital/lec_5_10.jpg new file mode 100644 index 00000000..abfae423 Binary files /dev/null and b/images/digital/lec_5_10.jpg differ diff --git a/images/digital/lec_5_11.jpg b/images/digital/lec_5_11.jpg new file mode 100644 index 00000000..ff5cd9d7 Binary files /dev/null and b/images/digital/lec_5_11.jpg differ diff --git a/images/digital/lec_5_12.jpg b/images/digital/lec_5_12.jpg new file mode 100644 index 00000000..de6914d7 Binary files /dev/null and b/images/digital/lec_5_12.jpg differ diff --git a/images/digital/lec_5_13.jpg b/images/digital/lec_5_13.jpg new file mode 100644 index 00000000..3af96d65 Binary files /dev/null and b/images/digital/lec_5_13.jpg differ diff --git a/images/digital/lec_5_14.jpg b/images/digital/lec_5_14.jpg new file mode 100644 index 00000000..3d21dc0b Binary files /dev/null and b/images/digital/lec_5_14.jpg differ diff --git a/images/digital/lec_5_15.jpg b/images/digital/lec_5_15.jpg new file mode 100644 index 00000000..3bc41ff2 Binary files /dev/null and b/images/digital/lec_5_15.jpg differ diff --git a/images/digital/lec_5_16.jpg b/images/digital/lec_5_16.jpg new file mode 100644 index 00000000..f38a5a4b Binary files /dev/null and b/images/digital/lec_5_16.jpg differ diff --git a/images/digital/lec_5_17.jpg b/images/digital/lec_5_17.jpg new file mode 100644 index 00000000..1453a9e1 Binary files /dev/null and b/images/digital/lec_5_17.jpg differ diff --git a/images/digital/lec_5_18.jpg b/images/digital/lec_5_18.jpg new file mode 100644 index 00000000..874a5ec8 Binary files /dev/null and b/images/digital/lec_5_18.jpg differ diff --git a/images/digital/lec_5_19.jpg b/images/digital/lec_5_19.jpg new file mode 100644 index 00000000..f528435b Binary files /dev/null and b/images/digital/lec_5_19.jpg differ diff --git a/images/digital/lec_5_2.jpg b/images/digital/lec_5_2.jpg new file mode 100644 index 00000000..8627c182 Binary files /dev/null and b/images/digital/lec_5_2.jpg differ diff --git a/images/digital/lec_5_20.jpg b/images/digital/lec_5_20.jpg new file mode 100644 index 00000000..235a35be Binary files /dev/null and b/images/digital/lec_5_20.jpg differ diff --git a/images/digital/lec_5_21.jpg b/images/digital/lec_5_21.jpg new file mode 100644 index 00000000..a84e949e Binary files /dev/null and b/images/digital/lec_5_21.jpg differ diff --git a/images/digital/lec_5_22.jpg b/images/digital/lec_5_22.jpg new file mode 100644 index 00000000..337f729e Binary files /dev/null and b/images/digital/lec_5_22.jpg differ diff --git a/images/digital/lec_5_23.jpg b/images/digital/lec_5_23.jpg new file mode 100644 index 00000000..f329114b Binary files /dev/null and b/images/digital/lec_5_23.jpg differ diff --git a/images/digital/lec_5_24.jpg b/images/digital/lec_5_24.jpg new file mode 100644 index 00000000..bac85772 Binary files /dev/null and b/images/digital/lec_5_24.jpg differ diff --git a/images/digital/lec_5_25.jpg b/images/digital/lec_5_25.jpg new file mode 100644 index 00000000..76278c3b Binary files /dev/null and b/images/digital/lec_5_25.jpg differ diff --git a/images/digital/lec_5_26.jpg b/images/digital/lec_5_26.jpg new file mode 100644 index 00000000..349b7aca Binary files /dev/null and b/images/digital/lec_5_26.jpg differ diff --git a/images/digital/lec_5_3.jpg b/images/digital/lec_5_3.jpg new file mode 100644 index 00000000..a553a5b7 Binary files /dev/null and b/images/digital/lec_5_3.jpg differ diff --git a/images/digital/lec_5_4.jpg b/images/digital/lec_5_4.jpg new file mode 100644 index 00000000..2cf0bbb2 Binary files /dev/null and b/images/digital/lec_5_4.jpg differ diff --git a/images/digital/lec_5_5.jpg b/images/digital/lec_5_5.jpg new file mode 100644 index 00000000..eec77c1d Binary files /dev/null and b/images/digital/lec_5_5.jpg differ diff --git a/images/digital/lec_5_6.jpg b/images/digital/lec_5_6.jpg new file mode 100644 index 00000000..72415f31 Binary files /dev/null and b/images/digital/lec_5_6.jpg differ diff --git a/images/digital/lec_5_7.jpg b/images/digital/lec_5_7.jpg new file mode 100644 index 00000000..985d333d Binary files /dev/null and b/images/digital/lec_5_7.jpg differ diff --git a/images/digital/lec_5_8.jpg b/images/digital/lec_5_8.jpg new file mode 100644 index 00000000..ab65d11c Binary files /dev/null and b/images/digital/lec_5_8.jpg differ diff --git a/images/digital/lec_5_9.jpg b/images/digital/lec_5_9.jpg new file mode 100644 index 00000000..dcc406df Binary files /dev/null and b/images/digital/lec_5_9.jpg differ diff --git a/images/digital/lec_6_1.jpg b/images/digital/lec_6_1.jpg new file mode 100644 index 00000000..ad461b67 Binary files /dev/null and b/images/digital/lec_6_1.jpg differ diff --git a/images/digital/lec_6_2.jpg b/images/digital/lec_6_2.jpg new file mode 100644 index 00000000..f4438af0 Binary files /dev/null and b/images/digital/lec_6_2.jpg differ diff --git a/images/digital/lec_6_3.jpg b/images/digital/lec_6_3.jpg new file mode 100644 index 00000000..d96080ad Binary files /dev/null and b/images/digital/lec_6_3.jpg differ diff --git a/images/digital/lec_6_4.jpg b/images/digital/lec_6_4.jpg new file mode 100644 index 00000000..5e538f07 Binary files /dev/null and b/images/digital/lec_6_4.jpg differ diff --git a/images/digital/lec_6_5.jpg b/images/digital/lec_6_5.jpg new file mode 100644 index 00000000..0b3d4fff Binary files /dev/null and b/images/digital/lec_6_5.jpg differ diff --git a/images/digital/lec_6_6.jpg b/images/digital/lec_6_6.jpg new file mode 100644 index 00000000..17bbf808 Binary files /dev/null and b/images/digital/lec_6_6.jpg differ diff --git a/images/digital/lec_6_7.jpg b/images/digital/lec_6_7.jpg new file mode 100644 index 00000000..45b698e3 Binary files /dev/null and b/images/digital/lec_6_7.jpg differ diff --git a/images/digital/lec_6_8.jpg b/images/digital/lec_6_8.jpg new file mode 100644 index 00000000..a727501a Binary files /dev/null and b/images/digital/lec_6_8.jpg differ diff --git a/images/digital/lec_6_9.jpg b/images/digital/lec_6_9.jpg new file mode 100644 index 00000000..abe134d7 Binary files /dev/null and b/images/digital/lec_6_9.jpg differ diff --git a/images/digital/lec_7_.jpg b/images/digital/lec_7_.jpg new file mode 100644 index 00000000..ed457da6 Binary files /dev/null and b/images/digital/lec_7_.jpg differ diff --git a/images/digital/lec_7_1.jpg b/images/digital/lec_7_1.jpg new file mode 100644 index 00000000..eb84319a Binary files /dev/null and b/images/digital/lec_7_1.jpg differ diff --git a/images/digital/lec_7_10.jpg b/images/digital/lec_7_10.jpg new file mode 100644 index 00000000..3aad3294 Binary files /dev/null and b/images/digital/lec_7_10.jpg differ diff --git a/images/digital/lec_7_11.jpg b/images/digital/lec_7_11.jpg new file mode 100644 index 00000000..303a2b7d Binary files /dev/null and b/images/digital/lec_7_11.jpg differ diff --git a/images/digital/lec_7_12.jpg b/images/digital/lec_7_12.jpg new file mode 100644 index 00000000..72a76b2c Binary files /dev/null and b/images/digital/lec_7_12.jpg differ diff --git a/images/digital/lec_7_13.jpg b/images/digital/lec_7_13.jpg new file mode 100644 index 00000000..9c5871cb Binary files /dev/null and b/images/digital/lec_7_13.jpg differ diff --git a/images/digital/lec_7_14.jpg b/images/digital/lec_7_14.jpg new file mode 100644 index 00000000..afa9a33d Binary files /dev/null and b/images/digital/lec_7_14.jpg differ diff --git a/images/digital/lec_7_15.jpg b/images/digital/lec_7_15.jpg new file mode 100644 index 00000000..0f62a7c3 Binary files /dev/null and b/images/digital/lec_7_15.jpg differ diff --git a/images/digital/lec_7_16.jpg b/images/digital/lec_7_16.jpg new file mode 100644 index 00000000..a98e7269 Binary files /dev/null and b/images/digital/lec_7_16.jpg differ diff --git a/images/digital/lec_7_17.jpg b/images/digital/lec_7_17.jpg new file mode 100644 index 00000000..850df169 Binary files /dev/null and b/images/digital/lec_7_17.jpg differ diff --git a/images/digital/lec_7_18.jpg b/images/digital/lec_7_18.jpg new file mode 100644 index 00000000..782bf815 Binary files /dev/null and b/images/digital/lec_7_18.jpg differ diff --git a/images/digital/lec_7_19.jpg b/images/digital/lec_7_19.jpg new file mode 100644 index 00000000..eec02267 Binary files /dev/null and b/images/digital/lec_7_19.jpg differ diff --git a/images/digital/lec_7_2.jpg b/images/digital/lec_7_2.jpg new file mode 100644 index 00000000..189aa6cb Binary files /dev/null and b/images/digital/lec_7_2.jpg differ diff --git a/images/digital/lec_7_20.jpg b/images/digital/lec_7_20.jpg new file mode 100644 index 00000000..0abc6522 Binary files /dev/null and b/images/digital/lec_7_20.jpg differ diff --git a/images/digital/lec_7_21.jpg b/images/digital/lec_7_21.jpg new file mode 100644 index 00000000..1f35a4db Binary files /dev/null and b/images/digital/lec_7_21.jpg differ diff --git a/images/digital/lec_7_22.jpg b/images/digital/lec_7_22.jpg new file mode 100644 index 00000000..f929faa4 Binary files /dev/null and b/images/digital/lec_7_22.jpg differ diff --git a/images/digital/lec_7_23.jpg b/images/digital/lec_7_23.jpg new file mode 100644 index 00000000..6d29bf16 Binary files /dev/null and b/images/digital/lec_7_23.jpg differ diff --git a/images/digital/lec_7_24.jpg b/images/digital/lec_7_24.jpg new file mode 100644 index 00000000..a0fb1dfb Binary files /dev/null and b/images/digital/lec_7_24.jpg differ diff --git a/images/digital/lec_7_3.jpg b/images/digital/lec_7_3.jpg new file mode 100644 index 00000000..7169703d Binary files /dev/null and b/images/digital/lec_7_3.jpg differ diff --git a/images/digital/lec_7_4.jpg b/images/digital/lec_7_4.jpg new file mode 100644 index 00000000..de14e736 Binary files /dev/null and b/images/digital/lec_7_4.jpg differ diff --git a/images/digital/lec_7_5.jpg b/images/digital/lec_7_5.jpg new file mode 100644 index 00000000..a5315db7 Binary files /dev/null and b/images/digital/lec_7_5.jpg differ diff --git a/images/digital/lec_7_6.jpg b/images/digital/lec_7_6.jpg new file mode 100644 index 00000000..dba1af31 Binary files /dev/null and b/images/digital/lec_7_6.jpg differ diff --git a/images/digital/lec_7_7.jpg b/images/digital/lec_7_7.jpg new file mode 100644 index 00000000..919c24a9 Binary files /dev/null and b/images/digital/lec_7_7.jpg differ diff --git a/images/digital/lec_7_9.jpg b/images/digital/lec_7_9.jpg new file mode 100644 index 00000000..5164893d Binary files /dev/null and b/images/digital/lec_7_9.jpg differ diff --git a/images/digital/lec_8_1.jpg b/images/digital/lec_8_1.jpg new file mode 100644 index 00000000..f563e6ee Binary files /dev/null and b/images/digital/lec_8_1.jpg differ diff --git a/images/digital/lec_8_10.jpg b/images/digital/lec_8_10.jpg new file mode 100644 index 00000000..4292e9f7 Binary files /dev/null and b/images/digital/lec_8_10.jpg differ diff --git a/images/digital/lec_8_11.jpg b/images/digital/lec_8_11.jpg new file mode 100644 index 00000000..1b8f344c Binary files /dev/null and b/images/digital/lec_8_11.jpg differ diff --git a/images/digital/lec_8_12.jpg b/images/digital/lec_8_12.jpg new file mode 100644 index 00000000..fecf3fad Binary files /dev/null and b/images/digital/lec_8_12.jpg differ diff --git a/images/digital/lec_8_13.jpg b/images/digital/lec_8_13.jpg new file mode 100644 index 00000000..19e021da Binary files /dev/null and b/images/digital/lec_8_13.jpg differ diff --git a/images/digital/lec_8_14.jpg b/images/digital/lec_8_14.jpg new file mode 100644 index 00000000..ad91eab0 Binary files /dev/null and b/images/digital/lec_8_14.jpg differ diff --git a/images/digital/lec_8_15.jpg b/images/digital/lec_8_15.jpg new file mode 100644 index 00000000..b8dcb748 Binary files /dev/null and b/images/digital/lec_8_15.jpg differ diff --git a/images/digital/lec_8_16.jpg b/images/digital/lec_8_16.jpg new file mode 100644 index 00000000..e0c6f2c1 Binary files /dev/null and b/images/digital/lec_8_16.jpg differ diff --git a/images/digital/lec_8_17.jpg b/images/digital/lec_8_17.jpg new file mode 100644 index 00000000..6498c464 Binary files /dev/null and b/images/digital/lec_8_17.jpg differ diff --git a/images/digital/lec_8_18.jpg b/images/digital/lec_8_18.jpg new file mode 100644 index 00000000..aa5aed33 Binary files /dev/null and b/images/digital/lec_8_18.jpg differ diff --git a/images/digital/lec_8_19.jpg b/images/digital/lec_8_19.jpg new file mode 100644 index 00000000..09512ba3 Binary files /dev/null and b/images/digital/lec_8_19.jpg differ diff --git a/images/digital/lec_8_2.jpg b/images/digital/lec_8_2.jpg new file mode 100644 index 00000000..8250f420 Binary files /dev/null and b/images/digital/lec_8_2.jpg differ diff --git a/images/digital/lec_8_20.jpg b/images/digital/lec_8_20.jpg new file mode 100644 index 00000000..e9023229 Binary files /dev/null and b/images/digital/lec_8_20.jpg differ diff --git a/images/digital/lec_8_21.jpg b/images/digital/lec_8_21.jpg new file mode 100644 index 00000000..37a72fe3 Binary files /dev/null and b/images/digital/lec_8_21.jpg differ diff --git a/images/digital/lec_8_22.jpg b/images/digital/lec_8_22.jpg new file mode 100644 index 00000000..5913af00 Binary files /dev/null and b/images/digital/lec_8_22.jpg differ diff --git a/images/digital/lec_8_23.jpg b/images/digital/lec_8_23.jpg new file mode 100644 index 00000000..0412c18d Binary files /dev/null and b/images/digital/lec_8_23.jpg differ diff --git a/images/digital/lec_8_24.jpg b/images/digital/lec_8_24.jpg new file mode 100644 index 00000000..632a9553 Binary files /dev/null and b/images/digital/lec_8_24.jpg differ diff --git a/images/digital/lec_8_25.jpg b/images/digital/lec_8_25.jpg new file mode 100644 index 00000000..554431e9 Binary files /dev/null and b/images/digital/lec_8_25.jpg differ diff --git a/images/digital/lec_8_26.jpg b/images/digital/lec_8_26.jpg new file mode 100644 index 00000000..0a870102 Binary files /dev/null and b/images/digital/lec_8_26.jpg differ diff --git a/images/digital/lec_8_27.jpg b/images/digital/lec_8_27.jpg new file mode 100644 index 00000000..1bbc75bd Binary files /dev/null and b/images/digital/lec_8_27.jpg differ diff --git a/images/digital/lec_8_28.jpg b/images/digital/lec_8_28.jpg new file mode 100644 index 00000000..341f1c16 Binary files /dev/null and b/images/digital/lec_8_28.jpg differ diff --git a/images/digital/lec_8_29.jpg b/images/digital/lec_8_29.jpg new file mode 100644 index 00000000..98b7fbba Binary files /dev/null and b/images/digital/lec_8_29.jpg differ diff --git a/images/digital/lec_8_3.jpg b/images/digital/lec_8_3.jpg new file mode 100644 index 00000000..300bd32a Binary files /dev/null and b/images/digital/lec_8_3.jpg differ diff --git a/images/digital/lec_8_30.jpg b/images/digital/lec_8_30.jpg new file mode 100644 index 00000000..509b8d3b Binary files /dev/null and b/images/digital/lec_8_30.jpg differ diff --git a/images/digital/lec_8_31.jpg b/images/digital/lec_8_31.jpg new file mode 100644 index 00000000..7c51a56a Binary files /dev/null and b/images/digital/lec_8_31.jpg differ diff --git a/images/digital/lec_8_4.jpg b/images/digital/lec_8_4.jpg new file mode 100644 index 00000000..a64d12fe Binary files /dev/null and b/images/digital/lec_8_4.jpg differ diff --git a/images/digital/lec_8_5.jpg b/images/digital/lec_8_5.jpg new file mode 100644 index 00000000..9aada323 Binary files /dev/null and b/images/digital/lec_8_5.jpg differ diff --git a/images/digital/lec_8_6.jpg b/images/digital/lec_8_6.jpg new file mode 100644 index 00000000..238136f2 Binary files /dev/null and b/images/digital/lec_8_6.jpg differ diff --git a/images/digital/lec_8_7.jpg b/images/digital/lec_8_7.jpg new file mode 100644 index 00000000..909f4bda Binary files /dev/null and b/images/digital/lec_8_7.jpg differ diff --git a/images/digital/lec_8_8.jpg b/images/digital/lec_8_8.jpg new file mode 100644 index 00000000..0db30e0d Binary files /dev/null and b/images/digital/lec_8_8.jpg differ diff --git a/images/digital/lec_8_9.jpg b/images/digital/lec_8_9.jpg new file mode 100644 index 00000000..5aa64465 Binary files /dev/null and b/images/digital/lec_8_9.jpg differ diff --git a/images/digital/lec_9_1.jpg b/images/digital/lec_9_1.jpg new file mode 100644 index 00000000..e31913e0 Binary files /dev/null and b/images/digital/lec_9_1.jpg differ diff --git a/images/digital/lec_9_10.jpg b/images/digital/lec_9_10.jpg new file mode 100644 index 00000000..e34434a7 Binary files /dev/null and b/images/digital/lec_9_10.jpg differ diff --git a/images/digital/lec_9_11.jpg b/images/digital/lec_9_11.jpg new file mode 100644 index 00000000..0e4b2a1b Binary files /dev/null and b/images/digital/lec_9_11.jpg differ diff --git a/images/digital/lec_9_12.jpg b/images/digital/lec_9_12.jpg new file mode 100644 index 00000000..2524ed6e Binary files /dev/null and b/images/digital/lec_9_12.jpg differ diff --git a/images/digital/lec_9_13.jpg b/images/digital/lec_9_13.jpg new file mode 100644 index 00000000..0c33c548 Binary files /dev/null and b/images/digital/lec_9_13.jpg differ diff --git a/images/digital/lec_9_14.jpg b/images/digital/lec_9_14.jpg new file mode 100644 index 00000000..2e5328ed Binary files /dev/null and b/images/digital/lec_9_14.jpg differ diff --git a/images/digital/lec_9_15.jpg b/images/digital/lec_9_15.jpg new file mode 100644 index 00000000..a5aef7c5 Binary files /dev/null and b/images/digital/lec_9_15.jpg differ diff --git a/images/digital/lec_9_2.jpg b/images/digital/lec_9_2.jpg new file mode 100644 index 00000000..6006dcb2 Binary files /dev/null and b/images/digital/lec_9_2.jpg differ diff --git a/images/digital/lec_9_3.jpg b/images/digital/lec_9_3.jpg new file mode 100644 index 00000000..19ac2872 Binary files /dev/null and b/images/digital/lec_9_3.jpg differ diff --git a/images/digital/lec_9_4.jpg b/images/digital/lec_9_4.jpg new file mode 100644 index 00000000..6f7c88cf Binary files /dev/null and b/images/digital/lec_9_4.jpg differ diff --git a/images/digital/lec_9_5.jpg b/images/digital/lec_9_5.jpg new file mode 100644 index 00000000..df64324c Binary files /dev/null and b/images/digital/lec_9_5.jpg differ diff --git a/images/digital/lec_9_6.jpg b/images/digital/lec_9_6.jpg new file mode 100644 index 00000000..769a7adc Binary files /dev/null and b/images/digital/lec_9_6.jpg differ diff --git a/images/digital/lec_9_7.jpg b/images/digital/lec_9_7.jpg new file mode 100644 index 00000000..57eb6072 Binary files /dev/null and b/images/digital/lec_9_7.jpg differ diff --git a/images/digital/lec_9_8.jpg b/images/digital/lec_9_8.jpg new file mode 100644 index 00000000..5685011d Binary files /dev/null and b/images/digital/lec_9_8.jpg differ diff --git a/images/digital/lec_9_9.jpg b/images/digital/lec_9_9.jpg new file mode 100644 index 00000000..7591c893 Binary files /dev/null and b/images/digital/lec_9_9.jpg differ diff --git a/images/oj/1.jpg b/images/oj/1.jpg new file mode 100644 index 00000000..493ad46c Binary files /dev/null and b/images/oj/1.jpg differ diff --git a/images/pht.png b/images/pht.png new file mode 100644 index 00000000..565de72e Binary files /dev/null and b/images/pht.png differ diff --git a/images/physics/Exer9.29.jpg b/images/physics/Exer9.29.jpg new file mode 100644 index 00000000..fe93579f Binary files /dev/null and b/images/physics/Exer9.29.jpg differ diff --git a/images/physics/RealGasTemp.png b/images/physics/RealGasTemp.png new file mode 100644 index 00000000..8e18334a Binary files /dev/null and b/images/physics/RealGasTemp.png differ diff --git a/images/physics/STM.jpg b/images/physics/STM.jpg new file mode 100644 index 00000000..c98449d9 Binary files /dev/null and b/images/physics/STM.jpg differ diff --git a/images/physics/VanGas.png b/images/physics/VanGas.png new file mode 100644 index 00000000..babe0566 Binary files /dev/null and b/images/physics/VanGas.png differ diff --git a/images/physics/VanGasTemp.png b/images/physics/VanGasTemp.png new file mode 100644 index 00000000..ecb33ada Binary files /dev/null and b/images/physics/VanGasTemp.png differ diff --git a/images/physics/abaaba.jpg b/images/physics/abaaba.jpg new file mode 100644 index 00000000..b2f24d75 Binary files /dev/null and b/images/physics/abaaba.jpg differ diff --git a/images/physics/guocheng.png b/images/physics/guocheng.png new file mode 100644 index 00000000..30afedf0 Binary files /dev/null and b/images/physics/guocheng.png differ diff --git a/images/physics/niudunhuan.jpg b/images/physics/niudunhuan.jpg new file mode 100644 index 00000000..41e24627 Binary files /dev/null and b/images/physics/niudunhuan.jpg differ diff --git a/images/physics/rexunhuan.png b/images/physics/rexunhuan.png new file mode 100644 index 00000000..898cc0ad Binary files /dev/null and b/images/physics/rexunhuan.png differ diff --git a/images/physics/shuangfeng.jpg b/images/physics/shuangfeng.jpg new file mode 100644 index 00000000..996a1eb2 Binary files /dev/null and b/images/physics/shuangfeng.jpg differ diff --git a/images/physics/shuangzheshe.jpg b/images/physics/shuangzheshe.jpg new file mode 100644 index 00000000..0d1a8eea Binary files /dev/null and b/images/physics/shuangzheshe.jpg differ diff --git a/images/physics/xunhuantu.png b/images/physics/xunhuantu.png new file mode 100644 index 00000000..819cca8a Binary files /dev/null and b/images/physics/xunhuantu.png differ diff --git a/images/physics/zhilengxunhuan.png b/images/physics/zhilengxunhuan.png new file mode 100644 index 00000000..e0e89338 Binary files /dev/null and b/images/physics/zhilengxunhuan.png differ diff --git "a/images/physics/\345\207\206\345\215\225\350\211\262\345\205\211.jpg" "b/images/physics/\345\207\206\345\215\225\350\211\262\345\205\211.jpg" new file mode 100644 index 00000000..9eaf91b2 Binary files /dev/null and "b/images/physics/\345\207\206\345\215\225\350\211\262\345\205\211.jpg" differ diff --git "a/images/physics/\351\235\236\345\215\225\350\211\262\345\205\211.jpg" "b/images/physics/\351\235\236\345\215\225\350\211\262\345\205\211.jpg" new file mode 100644 index 00000000..4b4fecac Binary files /dev/null and "b/images/physics/\351\235\236\345\215\225\350\211\262\345\205\211.jpg" differ diff --git a/images/prob/L14_1.jpg b/images/prob/L14_1.jpg new file mode 100644 index 00000000..bfa2030a Binary files /dev/null and b/images/prob/L14_1.jpg differ diff --git a/images/prob/L15_1.jpg b/images/prob/L15_1.jpg new file mode 100644 index 00000000..8e54be0b Binary files /dev/null and b/images/prob/L15_1.jpg differ diff --git a/images/prob/L2_1.jpg b/images/prob/L2_1.jpg new file mode 100644 index 00000000..208bf398 Binary files /dev/null and b/images/prob/L2_1.jpg differ diff --git a/images/prob/L6_1.jpg b/images/prob/L6_1.jpg new file mode 100644 index 00000000..bd5f5343 Binary files /dev/null and b/images/prob/L6_1.jpg differ diff --git a/images/ss/lec10_1.jpg b/images/ss/lec10_1.jpg new file mode 100644 index 00000000..7da9f8b7 Binary files /dev/null and b/images/ss/lec10_1.jpg differ diff --git a/images/ss/lec10_2.jpg b/images/ss/lec10_2.jpg new file mode 100644 index 00000000..a7defab4 Binary files /dev/null and b/images/ss/lec10_2.jpg differ diff --git a/images/ss/lec10_3.jpg b/images/ss/lec10_3.jpg new file mode 100644 index 00000000..3549f584 Binary files /dev/null and b/images/ss/lec10_3.jpg differ diff --git a/images/ss/lec10_4.jpg b/images/ss/lec10_4.jpg new file mode 100644 index 00000000..aa7f67fb Binary files /dev/null and b/images/ss/lec10_4.jpg differ diff --git a/images/ss/lec10_5.jpg b/images/ss/lec10_5.jpg new file mode 100644 index 00000000..a3876eb5 Binary files /dev/null and b/images/ss/lec10_5.jpg differ diff --git a/images/ss/lec10_6.jpg b/images/ss/lec10_6.jpg new file mode 100644 index 00000000..d3461561 Binary files /dev/null and b/images/ss/lec10_6.jpg differ diff --git a/images/ss/lec10_7.jpg b/images/ss/lec10_7.jpg new file mode 100644 index 00000000..61ba3829 Binary files /dev/null and b/images/ss/lec10_7.jpg differ diff --git a/images/ss/lec10_8.jpg b/images/ss/lec10_8.jpg new file mode 100644 index 00000000..795c14b6 Binary files /dev/null and b/images/ss/lec10_8.jpg differ diff --git a/images/ss/lec11_1.jpg b/images/ss/lec11_1.jpg new file mode 100644 index 00000000..bd7c1038 Binary files /dev/null and b/images/ss/lec11_1.jpg differ diff --git a/images/ss/lec11_2.jpg b/images/ss/lec11_2.jpg new file mode 100644 index 00000000..6a865f4a Binary files /dev/null and b/images/ss/lec11_2.jpg differ diff --git a/images/ss/lec11_3.jpg b/images/ss/lec11_3.jpg new file mode 100644 index 00000000..b6ac431c Binary files /dev/null and b/images/ss/lec11_3.jpg differ diff --git a/images/ss/lec12_1.jpg b/images/ss/lec12_1.jpg new file mode 100644 index 00000000..6bccaba1 Binary files /dev/null and b/images/ss/lec12_1.jpg differ diff --git a/images/ss/lec12_2.jpg b/images/ss/lec12_2.jpg new file mode 100644 index 00000000..f4c767de Binary files /dev/null and b/images/ss/lec12_2.jpg differ diff --git a/images/ss/lec12_3.jpg b/images/ss/lec12_3.jpg new file mode 100644 index 00000000..b93e236c Binary files /dev/null and b/images/ss/lec12_3.jpg differ diff --git a/images/ss/lec12_4.jpg b/images/ss/lec12_4.jpg new file mode 100644 index 00000000..5cf77423 Binary files /dev/null and b/images/ss/lec12_4.jpg differ diff --git a/images/ss/lec12_5.jpg b/images/ss/lec12_5.jpg new file mode 100644 index 00000000..51572c70 Binary files /dev/null and b/images/ss/lec12_5.jpg differ diff --git a/images/ss/lec12_6.jpg b/images/ss/lec12_6.jpg new file mode 100644 index 00000000..bbbbe70d Binary files /dev/null and b/images/ss/lec12_6.jpg differ diff --git a/images/ss/lec12_7.jpg b/images/ss/lec12_7.jpg new file mode 100644 index 00000000..e5d2043e Binary files /dev/null and b/images/ss/lec12_7.jpg differ diff --git a/images/ss/lec12_8.jpg b/images/ss/lec12_8.jpg new file mode 100644 index 00000000..66cf3fb5 Binary files /dev/null and b/images/ss/lec12_8.jpg differ diff --git a/images/ss/lec13_1.jpg b/images/ss/lec13_1.jpg new file mode 100644 index 00000000..9e523f2f Binary files /dev/null and b/images/ss/lec13_1.jpg differ diff --git a/images/ss/lec14_1.jpg b/images/ss/lec14_1.jpg new file mode 100644 index 00000000..1410b99d Binary files /dev/null and b/images/ss/lec14_1.jpg differ diff --git a/images/ss/lec14_2.jpg b/images/ss/lec14_2.jpg new file mode 100644 index 00000000..bbc017ab Binary files /dev/null and b/images/ss/lec14_2.jpg differ diff --git a/images/ss/lec14_3.jpg b/images/ss/lec14_3.jpg new file mode 100644 index 00000000..6d2ee400 Binary files /dev/null and b/images/ss/lec14_3.jpg differ diff --git a/images/ss/lec14_4.jpg b/images/ss/lec14_4.jpg new file mode 100644 index 00000000..5e42f889 Binary files /dev/null and b/images/ss/lec14_4.jpg differ diff --git a/images/ss/lec14_5.jpg b/images/ss/lec14_5.jpg new file mode 100644 index 00000000..737acbcc Binary files /dev/null and b/images/ss/lec14_5.jpg differ diff --git a/images/ss/lec14_6.jpg b/images/ss/lec14_6.jpg new file mode 100644 index 00000000..31bc0a4b Binary files /dev/null and b/images/ss/lec14_6.jpg differ diff --git a/images/ss/lec14_7.jpg b/images/ss/lec14_7.jpg new file mode 100644 index 00000000..a9919a54 Binary files /dev/null and b/images/ss/lec14_7.jpg differ diff --git a/images/ss/lec15_1.jpg b/images/ss/lec15_1.jpg new file mode 100644 index 00000000..7113a24f Binary files /dev/null and b/images/ss/lec15_1.jpg differ diff --git a/images/ss/lec15_2.jpg b/images/ss/lec15_2.jpg new file mode 100644 index 00000000..b1b17fe7 Binary files /dev/null and b/images/ss/lec15_2.jpg differ diff --git a/images/ss/lec15_3.jpg b/images/ss/lec15_3.jpg new file mode 100644 index 00000000..ee2997ec Binary files /dev/null and b/images/ss/lec15_3.jpg differ diff --git a/images/ss/lec15_4.jpg b/images/ss/lec15_4.jpg new file mode 100644 index 00000000..a3c22657 Binary files /dev/null and b/images/ss/lec15_4.jpg differ diff --git a/images/ss/lec15_5.jpg b/images/ss/lec15_5.jpg new file mode 100644 index 00000000..36353287 Binary files /dev/null and b/images/ss/lec15_5.jpg differ diff --git a/images/ss/lec15_6.jpg b/images/ss/lec15_6.jpg new file mode 100644 index 00000000..92eecd31 Binary files /dev/null and b/images/ss/lec15_6.jpg differ diff --git a/images/ss/lec16_.jpg b/images/ss/lec16_.jpg new file mode 100644 index 00000000..cfb43bc0 Binary files /dev/null and b/images/ss/lec16_.jpg differ diff --git a/images/ss/lec16_1.jpg b/images/ss/lec16_1.jpg new file mode 100644 index 00000000..c7e7b49b Binary files /dev/null and b/images/ss/lec16_1.jpg differ diff --git a/images/ss/lec16_2.jpg b/images/ss/lec16_2.jpg new file mode 100644 index 00000000..22e8501b Binary files /dev/null and b/images/ss/lec16_2.jpg differ diff --git a/images/ss/lec16_3.jpg b/images/ss/lec16_3.jpg new file mode 100644 index 00000000..37f43486 Binary files /dev/null and b/images/ss/lec16_3.jpg differ diff --git a/images/ss/lec16_4.jpg b/images/ss/lec16_4.jpg new file mode 100644 index 00000000..141a9325 Binary files /dev/null and b/images/ss/lec16_4.jpg differ diff --git a/images/ss/lec17_1.jpg b/images/ss/lec17_1.jpg new file mode 100644 index 00000000..8521e216 Binary files /dev/null and b/images/ss/lec17_1.jpg differ diff --git a/images/ss/lec18_1.jpg b/images/ss/lec18_1.jpg new file mode 100644 index 00000000..cc218e4e Binary files /dev/null and b/images/ss/lec18_1.jpg differ diff --git a/images/ss/lec18_2.jpg b/images/ss/lec18_2.jpg new file mode 100644 index 00000000..e3540cb6 Binary files /dev/null and b/images/ss/lec18_2.jpg differ diff --git a/images/ss/lec18_3.jpg b/images/ss/lec18_3.jpg new file mode 100644 index 00000000..dd46590e Binary files /dev/null and b/images/ss/lec18_3.jpg differ diff --git a/images/ss/lec18_34jpg.jpg b/images/ss/lec18_34jpg.jpg new file mode 100644 index 00000000..9f0dcba2 Binary files /dev/null and b/images/ss/lec18_34jpg.jpg differ diff --git a/images/ss/lec18_5jpg.jpg b/images/ss/lec18_5jpg.jpg new file mode 100644 index 00000000..f510aff1 Binary files /dev/null and b/images/ss/lec18_5jpg.jpg differ diff --git a/images/ss/lec18_6.jpg b/images/ss/lec18_6.jpg new file mode 100644 index 00000000..e93ff44f Binary files /dev/null and b/images/ss/lec18_6.jpg differ diff --git a/images/ss/lec19_1jpg.jpg b/images/ss/lec19_1jpg.jpg new file mode 100644 index 00000000..939ef8a2 Binary files /dev/null and b/images/ss/lec19_1jpg.jpg differ diff --git a/images/ss/lec19_2jpg.jpg b/images/ss/lec19_2jpg.jpg new file mode 100644 index 00000000..4f928e5c Binary files /dev/null and b/images/ss/lec19_2jpg.jpg differ diff --git a/images/ss/lec19_3.jpg b/images/ss/lec19_3.jpg new file mode 100644 index 00000000..3cdaef4a Binary files /dev/null and b/images/ss/lec19_3.jpg differ diff --git a/images/ss/lec20_1.jpg b/images/ss/lec20_1.jpg new file mode 100644 index 00000000..c33f97c0 Binary files /dev/null and b/images/ss/lec20_1.jpg differ diff --git a/images/ss/lec20_2.jpg b/images/ss/lec20_2.jpg new file mode 100644 index 00000000..a1bcea06 Binary files /dev/null and b/images/ss/lec20_2.jpg differ diff --git a/images/ss/lec20_3.jpg b/images/ss/lec20_3.jpg new file mode 100644 index 00000000..b7fb3a1a Binary files /dev/null and b/images/ss/lec20_3.jpg differ diff --git a/images/ss/lec20_4.jpg b/images/ss/lec20_4.jpg new file mode 100644 index 00000000..fd3ee975 Binary files /dev/null and b/images/ss/lec20_4.jpg differ diff --git a/images/ss/lec20_5.jpg b/images/ss/lec20_5.jpg new file mode 100644 index 00000000..04d62145 Binary files /dev/null and b/images/ss/lec20_5.jpg differ diff --git a/images/ss/lec20_6.jpg b/images/ss/lec20_6.jpg new file mode 100644 index 00000000..f9bfc32d Binary files /dev/null and b/images/ss/lec20_6.jpg differ diff --git a/images/ss/lec20_7.jpg b/images/ss/lec20_7.jpg new file mode 100644 index 00000000..eec963d4 Binary files /dev/null and b/images/ss/lec20_7.jpg differ diff --git a/images/ss/lec20_8.jpg b/images/ss/lec20_8.jpg new file mode 100644 index 00000000..f0d4beeb Binary files /dev/null and b/images/ss/lec20_8.jpg differ diff --git a/images/ss/lec21_1.jpg b/images/ss/lec21_1.jpg new file mode 100644 index 00000000..c50820fd Binary files /dev/null and b/images/ss/lec21_1.jpg differ diff --git a/images/ss/lec21_10.jpg b/images/ss/lec21_10.jpg new file mode 100644 index 00000000..7e4077ba Binary files /dev/null and b/images/ss/lec21_10.jpg differ diff --git a/images/ss/lec21_2.jpg b/images/ss/lec21_2.jpg new file mode 100644 index 00000000..79be57de Binary files /dev/null and b/images/ss/lec21_2.jpg differ diff --git a/images/ss/lec21_3.jpg b/images/ss/lec21_3.jpg new file mode 100644 index 00000000..54221092 Binary files /dev/null and b/images/ss/lec21_3.jpg differ diff --git a/images/ss/lec21_4.jpg b/images/ss/lec21_4.jpg new file mode 100644 index 00000000..ee8f481b Binary files /dev/null and b/images/ss/lec21_4.jpg differ diff --git a/images/ss/lec21_5.jpg b/images/ss/lec21_5.jpg new file mode 100644 index 00000000..9e688522 Binary files /dev/null and b/images/ss/lec21_5.jpg differ diff --git a/images/ss/lec21_6.jpg b/images/ss/lec21_6.jpg new file mode 100644 index 00000000..3800b1c4 Binary files /dev/null and b/images/ss/lec21_6.jpg differ diff --git a/images/ss/lec21_7.jpg b/images/ss/lec21_7.jpg new file mode 100644 index 00000000..cb366249 Binary files /dev/null and b/images/ss/lec21_7.jpg differ diff --git a/images/ss/lec21_8.jpg b/images/ss/lec21_8.jpg new file mode 100644 index 00000000..ee07f3e2 Binary files /dev/null and b/images/ss/lec21_8.jpg differ diff --git a/images/ss/lec21_9.jpg b/images/ss/lec21_9.jpg new file mode 100644 index 00000000..cb366249 Binary files /dev/null and b/images/ss/lec21_9.jpg differ diff --git a/images/ss/lec22_11.jpg b/images/ss/lec22_11.jpg new file mode 100644 index 00000000..fafe28c3 Binary files /dev/null and b/images/ss/lec22_11.jpg differ diff --git a/images/ss/lec22_12.jpg b/images/ss/lec22_12.jpg new file mode 100644 index 00000000..10f4157f Binary files /dev/null and b/images/ss/lec22_12.jpg differ diff --git a/images/ss/lec22_13.jpg b/images/ss/lec22_13.jpg new file mode 100644 index 00000000..86acf9c3 Binary files /dev/null and b/images/ss/lec22_13.jpg differ diff --git a/images/ss/lec22_14.jpg b/images/ss/lec22_14.jpg new file mode 100644 index 00000000..01eceaac Binary files /dev/null and b/images/ss/lec22_14.jpg differ diff --git a/images/ss/lec22_15.jpg b/images/ss/lec22_15.jpg new file mode 100644 index 00000000..c499759b Binary files /dev/null and b/images/ss/lec22_15.jpg differ diff --git a/images/ss/lec22_16.jpg b/images/ss/lec22_16.jpg new file mode 100644 index 00000000..25d3da08 Binary files /dev/null and b/images/ss/lec22_16.jpg differ diff --git a/images/ss/lec22_17.jpg b/images/ss/lec22_17.jpg new file mode 100644 index 00000000..f14447c7 Binary files /dev/null and b/images/ss/lec22_17.jpg differ diff --git a/images/ss/lec22_18.jpg b/images/ss/lec22_18.jpg new file mode 100644 index 00000000..a61cbd5c Binary files /dev/null and b/images/ss/lec22_18.jpg differ diff --git a/images/ss/lec22_19.jpg b/images/ss/lec22_19.jpg new file mode 100644 index 00000000..f74b0e6e Binary files /dev/null and b/images/ss/lec22_19.jpg differ diff --git a/images/ss/lec22_20.jpg b/images/ss/lec22_20.jpg new file mode 100644 index 00000000..13dd3278 Binary files /dev/null and b/images/ss/lec22_20.jpg differ diff --git a/images/ss/lec23_1.jpg b/images/ss/lec23_1.jpg new file mode 100644 index 00000000..d0f073f4 Binary files /dev/null and b/images/ss/lec23_1.jpg differ diff --git a/images/ss/lec2_.jpg b/images/ss/lec2_.jpg new file mode 100644 index 00000000..5b0a5e51 Binary files /dev/null and b/images/ss/lec2_.jpg differ diff --git a/images/ss/lec2_2.jpg b/images/ss/lec2_2.jpg new file mode 100644 index 00000000..e28485ca Binary files /dev/null and b/images/ss/lec2_2.jpg differ diff --git a/images/ss/lec2_3.jpg b/images/ss/lec2_3.jpg new file mode 100644 index 00000000..b3d71344 Binary files /dev/null and b/images/ss/lec2_3.jpg differ diff --git a/images/ss/lec3_1.jpg b/images/ss/lec3_1.jpg new file mode 100644 index 00000000..cb5b84c2 Binary files /dev/null and b/images/ss/lec3_1.jpg differ diff --git a/images/ss/lec3_2.jpg b/images/ss/lec3_2.jpg new file mode 100644 index 00000000..1f2ea493 Binary files /dev/null and b/images/ss/lec3_2.jpg differ diff --git a/images/ss/lec7_1.jpg b/images/ss/lec7_1.jpg new file mode 100644 index 00000000..c0820748 Binary files /dev/null and b/images/ss/lec7_1.jpg differ diff --git a/images/ss/lec7_2.jpg b/images/ss/lec7_2.jpg new file mode 100644 index 00000000..73f4d691 Binary files /dev/null and b/images/ss/lec7_2.jpg differ diff --git a/images/ss/lec7_3.jpg b/images/ss/lec7_3.jpg new file mode 100644 index 00000000..b08c8dc5 Binary files /dev/null and b/images/ss/lec7_3.jpg differ diff --git a/images/ss/lec7_4.jpg b/images/ss/lec7_4.jpg new file mode 100644 index 00000000..71c5c1f1 Binary files /dev/null and b/images/ss/lec7_4.jpg differ diff --git a/images/ss/lec9_1.jpg b/images/ss/lec9_1.jpg new file mode 100644 index 00000000..f78e1b07 Binary files /dev/null and b/images/ss/lec9_1.jpg differ diff --git a/images/ss/lec9_2.jpg b/images/ss/lec9_2.jpg new file mode 100644 index 00000000..1f4347ef Binary files /dev/null and b/images/ss/lec9_2.jpg differ diff --git a/images/ss/lec9_3.jpg b/images/ss/lec9_3.jpg new file mode 100644 index 00000000..639b7380 Binary files /dev/null and b/images/ss/lec9_3.jpg differ diff --git a/images/ss/lec9_4.jpg b/images/ss/lec9_4.jpg new file mode 100644 index 00000000..9ed713f8 Binary files /dev/null and b/images/ss/lec9_4.jpg differ diff --git a/images/ss/lec9_5.jpg b/images/ss/lec9_5.jpg new file mode 100644 index 00000000..7a12ffb0 Binary files /dev/null and b/images/ss/lec9_5.jpg differ diff --git a/images/ss/lec9_6.jpg b/images/ss/lec9_6.jpg new file mode 100644 index 00000000..863d67b4 Binary files /dev/null and b/images/ss/lec9_6.jpg differ diff --git a/images/stochastic/exer_1.jpg b/images/stochastic/exer_1.jpg new file mode 100644 index 00000000..56e7c6f6 Binary files /dev/null and b/images/stochastic/exer_1.jpg differ diff --git a/images/stuffs/1713000493686.png b/images/stuffs/1713000493686.png new file mode 100644 index 00000000..4e06e4c7 Binary files /dev/null and b/images/stuffs/1713000493686.png differ diff --git "a/images/\350\256\241\347\275\221/3_1.jpg" "b/images/\350\256\241\347\275\221/3_1.jpg" new file mode 100644 index 00000000..99e94d52 Binary files /dev/null and "b/images/\350\256\241\347\275\221/3_1.jpg" differ diff --git "a/images/\350\256\241\347\275\221/3_2.jpg" "b/images/\350\256\241\347\275\221/3_2.jpg" new file mode 100644 index 00000000..0d13b0a4 Binary files /dev/null and "b/images/\350\256\241\347\275\221/3_2.jpg" differ diff --git "a/images/\350\256\241\347\275\221/3_3.jpg" "b/images/\350\256\241\347\275\221/3_3.jpg" new file mode 100644 index 00000000..b26d0981 Binary files /dev/null and "b/images/\350\256\241\347\275\221/3_3.jpg" differ diff --git "a/images/\350\256\241\347\275\221/3_4.jpg" "b/images/\350\256\241\347\275\221/3_4.jpg" new file mode 100644 index 00000000..ca813eb4 Binary files /dev/null and "b/images/\350\256\241\347\275\221/3_4.jpg" differ diff --git "a/images/\350\256\241\347\275\221/3_5.jpg" "b/images/\350\256\241\347\275\221/3_5.jpg" new file mode 100644 index 00000000..41c2baef Binary files /dev/null and "b/images/\350\256\241\347\275\221/3_5.jpg" differ diff --git "a/images/\350\256\241\347\275\221/3_6.jpg" "b/images/\350\256\241\347\275\221/3_6.jpg" new file mode 100644 index 00000000..ac397c6c Binary files /dev/null and "b/images/\350\256\241\347\275\221/3_6.jpg" differ diff --git "a/images/\350\256\241\347\275\221/3_7.jpg" "b/images/\350\256\241\347\275\221/3_7.jpg" new file mode 100644 index 00000000..c1f92714 Binary files /dev/null and "b/images/\350\256\241\347\275\221/3_7.jpg" differ diff --git "a/images/\350\256\241\347\275\221/5_1.jpg" "b/images/\350\256\241\347\275\221/5_1.jpg" new file mode 100644 index 00000000..96e0242a Binary files /dev/null and "b/images/\350\256\241\347\275\221/5_1.jpg" differ diff --git "a/images/\350\256\241\347\275\221/5_2.jpg" "b/images/\350\256\241\347\275\221/5_2.jpg" new file mode 100644 index 00000000..542db0ee Binary files /dev/null and "b/images/\350\256\241\347\275\221/5_2.jpg" differ diff --git "a/images/\351\200\232\347\275\221/1_.jpg" "b/images/\351\200\232\347\275\221/1_.jpg" new file mode 100644 index 00000000..cdc921f4 Binary files /dev/null and "b/images/\351\200\232\347\275\221/1_.jpg" differ diff --git "a/images/\351\200\232\347\275\221/1_1.jpg" "b/images/\351\200\232\347\275\221/1_1.jpg" new file mode 100644 index 00000000..60454c36 Binary files /dev/null and "b/images/\351\200\232\347\275\221/1_1.jpg" differ diff --git "a/images/\351\200\232\347\275\221/2_1.jpg" "b/images/\351\200\232\347\275\221/2_1.jpg" new file mode 100644 index 00000000..44b8332d Binary files /dev/null and "b/images/\351\200\232\347\275\221/2_1.jpg" differ diff --git "a/images/\351\200\232\347\275\221/2_2.jpg" "b/images/\351\200\232\347\275\221/2_2.jpg" new file mode 100644 index 00000000..c9984a64 Binary files /dev/null and "b/images/\351\200\232\347\275\221/2_2.jpg" differ diff --git "a/images/\351\200\232\347\275\221/2_3.jpg" "b/images/\351\200\232\347\275\221/2_3.jpg" new file mode 100644 index 00000000..2e7941f8 Binary files /dev/null and "b/images/\351\200\232\347\275\221/2_3.jpg" differ diff --git "a/images/\351\200\232\347\275\221/2_4.jpg" "b/images/\351\200\232\347\275\221/2_4.jpg" new file mode 100644 index 00000000..48d25941 Binary files /dev/null and "b/images/\351\200\232\347\275\221/2_4.jpg" differ diff --git "a/images/\351\200\232\347\275\221/2_5.jpg" "b/images/\351\200\232\347\275\221/2_5.jpg" new file mode 100644 index 00000000..8a04cbf5 Binary files /dev/null and "b/images/\351\200\232\347\275\221/2_5.jpg" differ diff --git "a/images/\351\200\232\347\275\221/2_6.jpg" "b/images/\351\200\232\347\275\221/2_6.jpg" new file mode 100644 index 00000000..6a14dbc2 Binary files /dev/null and "b/images/\351\200\232\347\275\221/2_6.jpg" differ diff --git "a/images/\351\200\232\347\275\221/2_7.jpg" "b/images/\351\200\232\347\275\221/2_7.jpg" new file mode 100644 index 00000000..15067e01 Binary files /dev/null and "b/images/\351\200\232\347\275\221/2_7.jpg" differ diff --git "a/images/\351\200\232\347\275\221/2_8.jpg" "b/images/\351\200\232\347\275\221/2_8.jpg" new file mode 100644 index 00000000..a7ad4613 Binary files /dev/null and "b/images/\351\200\232\347\275\221/2_8.jpg" differ diff --git "a/images/\351\200\232\347\275\221/2_9.jpg" "b/images/\351\200\232\347\275\221/2_9.jpg" new file mode 100644 index 00000000..c20818df Binary files /dev/null and "b/images/\351\200\232\347\275\221/2_9.jpg" differ diff --git "a/images/\351\200\232\347\275\221/3_1.jpg" "b/images/\351\200\232\347\275\221/3_1.jpg" new file mode 100644 index 00000000..47e3ab37 Binary files /dev/null and "b/images/\351\200\232\347\275\221/3_1.jpg" differ diff --git "a/images/\351\200\232\347\275\221/3_2.jpg" "b/images/\351\200\232\347\275\221/3_2.jpg" new file mode 100644 index 00000000..d8869f60 Binary files /dev/null and "b/images/\351\200\232\347\275\221/3_2.jpg" differ diff --git "a/images/\351\200\232\347\275\221/3_3.jpg" "b/images/\351\200\232\347\275\221/3_3.jpg" new file mode 100644 index 00000000..27e08fe6 Binary files /dev/null and "b/images/\351\200\232\347\275\221/3_3.jpg" differ diff --git "a/images/\351\200\232\347\275\221/3_4.jpg" "b/images/\351\200\232\347\275\221/3_4.jpg" new file mode 100644 index 00000000..eb14d4b4 Binary files /dev/null and "b/images/\351\200\232\347\275\221/3_4.jpg" differ diff --git "a/images/\351\200\232\347\275\221/3_5.jpg" "b/images/\351\200\232\347\275\221/3_5.jpg" new file mode 100644 index 00000000..9c63f037 Binary files /dev/null and "b/images/\351\200\232\347\275\221/3_5.jpg" differ diff --git "a/images/\351\200\232\347\275\221/3_6.jpg" "b/images/\351\200\232\347\275\221/3_6.jpg" new file mode 100644 index 00000000..7fd432be Binary files /dev/null and "b/images/\351\200\232\347\275\221/3_6.jpg" differ diff --git "a/images/\351\200\232\347\275\221/4_1.jpg" "b/images/\351\200\232\347\275\221/4_1.jpg" new file mode 100644 index 00000000..c377e56c Binary files /dev/null and "b/images/\351\200\232\347\275\221/4_1.jpg" differ diff --git "a/images/\351\200\232\347\275\221/4_10.jpg" "b/images/\351\200\232\347\275\221/4_10.jpg" new file mode 100644 index 00000000..466c0a44 Binary files /dev/null and "b/images/\351\200\232\347\275\221/4_10.jpg" differ diff --git "a/images/\351\200\232\347\275\221/4_2.jpg" "b/images/\351\200\232\347\275\221/4_2.jpg" new file mode 100644 index 00000000..37e84594 Binary files /dev/null and "b/images/\351\200\232\347\275\221/4_2.jpg" differ diff --git "a/images/\351\200\232\347\275\221/4_3.jpg" "b/images/\351\200\232\347\275\221/4_3.jpg" new file mode 100644 index 00000000..ade87d06 Binary files /dev/null and "b/images/\351\200\232\347\275\221/4_3.jpg" differ diff --git "a/images/\351\200\232\347\275\221/4_4.jpg" "b/images/\351\200\232\347\275\221/4_4.jpg" new file mode 100644 index 00000000..1c9e6a0d Binary files /dev/null and "b/images/\351\200\232\347\275\221/4_4.jpg" differ diff --git "a/images/\351\200\232\347\275\221/4_5.jpg" "b/images/\351\200\232\347\275\221/4_5.jpg" new file mode 100644 index 00000000..dd5b1a3f Binary files /dev/null and "b/images/\351\200\232\347\275\221/4_5.jpg" differ diff --git "a/images/\351\200\232\347\275\221/4_6.jpg" "b/images/\351\200\232\347\275\221/4_6.jpg" new file mode 100644 index 00000000..3a02e86d Binary files /dev/null and "b/images/\351\200\232\347\275\221/4_6.jpg" differ diff --git "a/images/\351\200\232\347\275\221/4_7.jpg" "b/images/\351\200\232\347\275\221/4_7.jpg" new file mode 100644 index 00000000..fada1fc2 Binary files /dev/null and "b/images/\351\200\232\347\275\221/4_7.jpg" differ diff --git "a/images/\351\200\232\347\275\221/4_8.jpg" "b/images/\351\200\232\347\275\221/4_8.jpg" new file mode 100644 index 00000000..14b38575 Binary files /dev/null and "b/images/\351\200\232\347\275\221/4_8.jpg" differ diff --git "a/images/\351\200\232\347\275\221/4_9.jpg" "b/images/\351\200\232\347\275\221/4_9.jpg" new file mode 100644 index 00000000..2901f73e Binary files /dev/null and "b/images/\351\200\232\347\275\221/4_9.jpg" differ diff --git "a/images/\351\200\232\347\275\221/5_1.jpg" "b/images/\351\200\232\347\275\221/5_1.jpg" new file mode 100644 index 00000000..7f1816a1 Binary files /dev/null and "b/images/\351\200\232\347\275\221/5_1.jpg" differ diff --git "a/images/\351\200\232\347\275\221/5_10.jpg" "b/images/\351\200\232\347\275\221/5_10.jpg" new file mode 100644 index 00000000..95fd875e Binary files /dev/null and "b/images/\351\200\232\347\275\221/5_10.jpg" differ diff --git "a/images/\351\200\232\347\275\221/5_2.jpg" "b/images/\351\200\232\347\275\221/5_2.jpg" new file mode 100644 index 00000000..38d12268 Binary files /dev/null and "b/images/\351\200\232\347\275\221/5_2.jpg" differ diff --git "a/images/\351\200\232\347\275\221/5_3.jpg" "b/images/\351\200\232\347\275\221/5_3.jpg" new file mode 100644 index 00000000..76b046c8 Binary files /dev/null and "b/images/\351\200\232\347\275\221/5_3.jpg" differ diff --git "a/images/\351\200\232\347\275\221/5_4.jpg" "b/images/\351\200\232\347\275\221/5_4.jpg" new file mode 100644 index 00000000..e4af88f5 Binary files /dev/null and "b/images/\351\200\232\347\275\221/5_4.jpg" differ diff --git "a/images/\351\200\232\347\275\221/5_5.jpg" "b/images/\351\200\232\347\275\221/5_5.jpg" new file mode 100644 index 00000000..0dd2d108 Binary files /dev/null and "b/images/\351\200\232\347\275\221/5_5.jpg" differ diff --git "a/images/\351\200\232\347\275\221/5_6.jpg" "b/images/\351\200\232\347\275\221/5_6.jpg" new file mode 100644 index 00000000..49c133b0 Binary files /dev/null and "b/images/\351\200\232\347\275\221/5_6.jpg" differ diff --git "a/images/\351\200\232\347\275\221/5_7.jpg" "b/images/\351\200\232\347\275\221/5_7.jpg" new file mode 100644 index 00000000..09d90ee5 Binary files /dev/null and "b/images/\351\200\232\347\275\221/5_7.jpg" differ diff --git "a/images/\351\200\232\347\275\221/5_8.jpg" "b/images/\351\200\232\347\275\221/5_8.jpg" new file mode 100644 index 00000000..bc7e8177 Binary files /dev/null and "b/images/\351\200\232\347\275\221/5_8.jpg" differ diff --git "a/images/\351\200\232\347\275\221/5_9.jpg" "b/images/\351\200\232\347\275\221/5_9.jpg" new file mode 100644 index 00000000..51f3dcd0 Binary files /dev/null and "b/images/\351\200\232\347\275\221/5_9.jpg" differ diff --git "a/images/\351\207\217\347\255\222/4_2.jpg" "b/images/\351\207\217\347\255\222/4_2.jpg" new file mode 100644 index 00000000..45b631f5 Binary files /dev/null and "b/images/\351\207\217\347\255\222/4_2.jpg" differ diff --git "a/images/\351\207\217\347\255\222/4\342\200\224\342\200\2241.jpg" "b/images/\351\207\217\347\255\222/4\342\200\224\342\200\2241.jpg" new file mode 100644 index 00000000..6e73ec61 Binary files /dev/null and "b/images/\351\207\217\347\255\222/4\342\200\224\342\200\2241.jpg" differ diff --git "a/images/\351\207\217\347\255\222/5_1.jpg" "b/images/\351\207\217\347\255\222/5_1.jpg" new file mode 100644 index 00000000..cb52a36d Binary files /dev/null and "b/images/\351\207\217\347\255\222/5_1.jpg" differ diff --git "a/images/\351\207\217\347\255\222/7_1.jpg" "b/images/\351\207\217\347\255\222/7_1.jpg" new file mode 100644 index 00000000..4d41ba5a Binary files /dev/null and "b/images/\351\207\217\347\255\222/7_1.jpg" differ diff --git "a/images/\351\207\217\347\255\222/8_1.jpg" "b/images/\351\207\217\347\255\222/8_1.jpg" new file mode 100644 index 00000000..5f26bd29 Binary files /dev/null and "b/images/\351\207\217\347\255\222/8_1.jpg" differ diff --git "a/images/\351\207\217\347\255\222/8_2.jpg" "b/images/\351\207\217\347\255\222/8_2.jpg" new file mode 100644 index 00000000..6485a786 Binary files /dev/null and "b/images/\351\207\217\347\255\222/8_2.jpg" differ diff --git "a/images/\351\207\217\347\255\222/8_3.jpg" "b/images/\351\207\217\347\255\222/8_3.jpg" new file mode 100644 index 00000000..7f08ddfa Binary files /dev/null and "b/images/\351\207\217\347\255\222/8_3.jpg" differ diff --git "a/images/\351\207\217\347\255\222/8_4.jpg" "b/images/\351\207\217\347\255\222/8_4.jpg" new file mode 100644 index 00000000..00471a77 Binary files /dev/null and "b/images/\351\207\217\347\255\222/8_4.jpg" differ diff --git "a/images/\351\207\217\347\255\222/xt_2_1.jpg" "b/images/\351\207\217\347\255\222/xt_2_1.jpg" new file mode 100644 index 00000000..764389bb Binary files /dev/null and "b/images/\351\207\217\347\255\222/xt_2_1.jpg" differ diff --git "a/images/\351\207\217\347\255\222/xt_2_2.jpg" "b/images/\351\207\217\347\255\222/xt_2_2.jpg" new file mode 100644 index 00000000..0dc2709c Binary files /dev/null and "b/images/\351\207\217\347\255\222/xt_2_2.jpg" differ diff --git a/index.html b/index.html new file mode 100644 index 00000000..ea0f8770 --- /dev/null +++ b/index.html @@ -0,0 +1,46 @@ +Guo_Yun + + + + + + + + + +
\ No newline at end of file diff --git a/js/analytics/leancloud-visitors.js b/js/analytics/leancloud-visitors.js new file mode 100644 index 00000000..148a5a31 --- /dev/null +++ b/js/analytics/leancloud-visitors.js @@ -0,0 +1 @@ +function u(){function c(e){return e=encodeURI(e),document.getElementById(e).querySelector(".leancloud-visitors-count")}function p(e){let s=document.querySelector(".leancloud_visitors"),n=decodeURI(s.id),t=s.dataset.flagTitle;e("get",`/classes/Counter?where=${encodeURIComponent(JSON.stringify({url:n}))}`).then(o=>o.json()).then(({results:o})=>{if(o.length>0){let r=o[0];c(n).innerText=r.time+1,e("put",`/classes/Counter/${r.objectId}`,{time:{__op:"Increment",amount:1}}).catch(l=>{console.error("Failed to save visitor count",l)})}else e("post","/classes/Counter",{title:t,url:n,time:1}).then(r=>r.json()).then(()=>{c(n).innerText=1}).catch(r=>{console.error("Failed to create",r)})}).catch(o=>{console.error("LeanCloud Counter Error",o)})}function h(e){let n=[...document.querySelectorAll(".leancloud_visitors")].map(t=>decodeURI(t.id));e("get",`/classes/Counter?where=${encodeURIComponent(JSON.stringify({url:{$in:n}}))}`).then(t=>t.json()).then(({results:t})=>{for(let o of n){let r=t.find(l=>l.url===o);c(o).innerText=r?r.time:0}}).catch(t=>{console.error("LeanCloud Counter Error",t)})}let{app_id:i,app_key:f,server_url:m}=CONFIG.leancloudVisitors;function a(e){let s=(n,t,o)=>fetch(`${e}/1.1${t}`,{method:n,headers:{"X-LC-Id":i,"X-LC-Key":f,"Content-Type":"application/json"},body:JSON.stringify(o)});CONFIG.page.isPost?p(s):document.querySelectorAll(".post-title-link").length>=1&&h(s)}let d=m||`https://${i.slice(0,8).toLowerCase()}.api.lncldglobal.com`;d?a(d):fetch(`https://app-router.leancloud.cn/2/route?appId=${i}`).then(e=>e.json()).then(({api_server:e})=>{a(`https://${e}`)})}document.addEventListener("DOMContentLoaded",u);document.addEventListener("pjax:success",u); diff --git a/js/chunk-72ZP56JR.js b/js/chunk-72ZP56JR.js new file mode 100644 index 00000000..bfccbf0b --- /dev/null +++ b/js/chunk-72ZP56JR.js @@ -0,0 +1 @@ +import{a as d}from"./chunk-FEIY7W7S.js";var w={};d(w,{copyright:()=>u,getScript:()=>y,insertCopyCodeBtn:()=>g,isHome:()=>p,registerScrollPercent:()=>f,registerToggleSidebar:()=>b,renderKatex:()=>h,wrapTable:()=>m});HTMLElement.prototype.wrap=function(t){this.parentNode.insertBefore(t,this),this.parentNode.removeChild(this),t.appendChild(this)};function u(){console.log(`%c \u2601\uFE0F hexo-theme-yun ${window.CONFIG.version} %c https://github.com/YunYouJun/hexo-theme-yun`,"color: white; background: #0078E7; padding:5px 0;","padding:4px;border:1px solid #0078E7;")}var p=()=>window.location.pathname===window.CONFIG.root,m=()=>{document.querySelectorAll("table").forEach(t=>{let o=document.createElement("div");o.className="table-container",t.wrap(o)})};function y(t,o,n){if(n)o();else{let r=document.createElement("script");r.onload=()=>{setTimeout(o)},r.src=t,document.head.appendChild(r)}}function g(){document.querySelectorAll("pre[class*='language-']").forEach(o=>{if(!window.CONFIG.copycode)return;let n=document.createElement("div");n.className="code-container",o.wrap(n),n.insertAdjacentHTML("beforeend",'
');let r=n.querySelector(".copy-btn");r.addEventListener("click",()=>{let i=(n.querySelector("code[class*='language-']")||n.querySelector(".token")).innerText,e=document.createElement("textarea");e.style.top=`${window.scrollY}px`,e.style.position="absolute",e.style.opacity="0",e.readOnly=!0,e.value=i,document.body.append(e),e.select(),e.setSelectionRange(0,i.length),e.readOnly=!1;let s=document.execCommand("copy"),a=s?"ri:check-line":"ri:timer-line",l=r.querySelector(".iconify");l.dataset.icon=a,l.setAttribute("style",`color:${s?"green":"red"}`),e.blur(),r.blur(),document.body.removeChild(e)}),n.addEventListener("mouseleave",()=>{setTimeout(()=>{let c=r.querySelector(".iconify");c.dataset.icon="ri:file-copy-line",c.setAttribute("style","color:gray")},200)})})}function h(t){typeof window.renderMathInElement<"u"?window.renderMathInElement(document.body,{delimiters:[{left:"$$",right:"$$",display:!0},{left:"$",right:"$",display:!1},{left:"\\(",right:"\\)",display:!1},{left:"\\[",right:"\\]",display:!0}],...t}):console.error("Please check if you have introduced KaTeX(https://github.com/KaTeX/KaTeX) CDN.")}function f(){let t=document.querySelector("#back-to-top"),o=document.querySelector("#progressCircle");if(!t)return;function n(r){let c=document.body.clientHeight,i=window.innerHeight,e=o.r.baseVal.value*2*Math.PI,s=e-r/(c-i)*e;o.setAttribute("stroke-dasharray",`${e} ${e}`),o.setAttribute("stroke-dashoffset",s.toString())}window.addEventListener("scroll",()=>{t.classList.toggle("show",window.scrollY>64),n(window.scrollY)})}function b(){document.querySelectorAll(".sidebar-toggle").forEach(o=>{o.addEventListener("click",()=>{document.querySelector(".hamburger").classList.toggle("is-active"),document.querySelector(".container").classList.toggle("sidebar-open")})})}export{u as a,p as b,m as c,y as d,g as e,h as f,f as g,b as h,w as i}; diff --git a/js/chunk-FEIY7W7S.js b/js/chunk-FEIY7W7S.js new file mode 100644 index 00000000..d98ecd66 --- /dev/null +++ b/js/chunk-FEIY7W7S.js @@ -0,0 +1 @@ +var d=Object.defineProperty;var e=(c,a)=>{for(var b in a)d(c,b,{get:a[b],enumerable:!0})};export{e as a}; diff --git a/js/comments/disqus.js b/js/comments/disqus.js new file mode 100644 index 00000000..bb405d5f --- /dev/null +++ b/js/comments/disqus.js @@ -0,0 +1 @@ +function t(){let e=typeof window<"u",s=e&&!("onscroll"in window)||typeof navigator<"u"&&/(gle|ing|ro|msn)bot|crawl|spider|yand|duckgo/i.test(navigator.userAgent),o=e&&"IntersectionObserver"in window;if(!s&&o){let n=new IntersectionObserver(i=>{i[0].isIntersecting&&(window.loadDisqus(),n.disconnect())},{threshold:[0]});n.observe(document.getElementById("disqus_thread"))}else window.loadDisqus()}setTimeout(t,100); diff --git a/js/comments/waline.js b/js/comments/waline.js new file mode 100644 index 00000000..fcc6a2f0 --- /dev/null +++ b/js/comments/waline.js @@ -0,0 +1 @@ +import{d as n}from"../chunk-72ZP56JR.js";import"../chunk-FEIY7W7S.js";function i(){n(window.CONFIG.waline.cdn,()=>{window.Waline.init(window.CONFIG.waline.config)},window.Waline)}document.addEventListener("DOMContentLoaded",i);document.addEventListener("pjax:success",i); diff --git a/js/gallery-decrypt.js b/js/gallery-decrypt.js new file mode 100644 index 00000000..8ff79008 --- /dev/null +++ b/js/gallery-decrypt.js @@ -0,0 +1 @@ +import"./chunk-FEIY7W7S.js";function s(e,t){return window.CryptoJS.AES.decrypt(e,t).toString(window.CryptoJS.enc.Utf8)}function i(){let t=document.getElementById("decrypt-password").value,p=document.getElementById("decryptContainer"),m=document.getElementById("lightgallery");if(t){let o=document.querySelectorAll(".photo-list-item"),d=s(o[0].dataset.src,t);d.startsWith("http")||d.startsWith("/")?(p.style.display="none",m.style.display="flex",o.forEach(n=>{let a=s(n.dataset.src,t);n.dataset.src=a;let r=n.querySelector(".photo-list-cover"),c=s(r.alt,t),l=s(r.title,t);n.dataset.subHtml=`

${c}

${l}

`,r.src=a,r.alt=c,r.title=l,n.querySelector("figcaption").innerText=c})):(alert("Decrypt Error!"),window.location.reload())}}function y(){let e=document.getElementById("decryptButton");e&&(e.onclick=i,document.getElementById("decrypt-password").addEventListener("keydown",t=>{t.key==="Enter"&&i()}))}document.addEventListener("DOMContentLoaded",y);document.addEventListener("pjax:success",y);export{s as decrypt,i as decryptAll,y as initGalleryDecrypt}; diff --git a/js/hexo-theme-yun.js b/js/hexo-theme-yun.js new file mode 100644 index 00000000..399ff603 --- /dev/null +++ b/js/hexo-theme-yun.js @@ -0,0 +1 @@ +import{a as n,d as t,i as e}from"./chunk-72ZP56JR.js";import"./chunk-FEIY7W7S.js";window.Yun.utils=e;function i(){window.Yun.utils.registerToggleSidebar(),window.Yun.utils.registerScrollPercent(),window.Yun.utils.insertCopyCodeBtn(),window.Yun.utils.wrapTable(),t(window.CONFIG.vendors.darken,()=>{new window.darken({container:"html",class:"dark",toggle:"#toggle-mode-btn"})},window.darken)}n();document.addEventListener("DOMContentLoaded",i);export{e as utils}; diff --git a/js/pjax.js b/js/pjax.js new file mode 100644 index 00000000..3b7b15c8 --- /dev/null +++ b/js/pjax.js @@ -0,0 +1 @@ +import{b as e,f as n}from"./chunk-72ZP56JR.js";import"./chunk-FEIY7W7S.js";function t(){new window.Pjax({selectors:["title",".js-Pjax","main","aside"]})}function d(){e(),n()}document.addEventListener("DOMContentLoaded",t);document.addEventListener("DOMContentLoaded",e);document.addEventListener("pjax:success",d); diff --git a/js/say.js b/js/say.js new file mode 100644 index 00000000..01f2e832 --- /dev/null +++ b/js/say.js @@ -0,0 +1 @@ +import{b as s}from"./chunk-72ZP56JR.js";import"./chunk-FEIY7W7S.js";function n(o,e,t){let i=document.querySelector("#say-content"),c=document.querySelector("#say-author"),a=document.querySelector("#say-from");i.innerText=o,e&&(c.innerText=e),t&&(a.innerText=`\u300C${t}\u300D`)}function r(){window.CONFIG.say.api&&fetch(window.CONFIG.say.api).then(o=>{if(o.ok)o.json().then(e=>{if(window.CONFIG.say.hitokoto)n(e.hitokoto,e.from_who,e.from);else{let t=e[Math.floor(Math.random()*e.length)];t.content?n(t.content,t.author,t.from):n(t)}});else throw new Error(`${window.CONFIG.say.api}, HTTP error, status = ${o.status}`)}).catch(o=>{console.error(o.message)})}document.addEventListener("DOMContentLoaded",r);document.addEventListener("pjax:success",()=>{s()&&r()});export{r as fetchApiToSay,n as say}; diff --git a/js/search/algolia-search.js b/js/search/algolia-search.js new file mode 100644 index 00000000..446a7e84 --- /dev/null +++ b/js/search/algolia-search.js @@ -0,0 +1,7 @@ +document.addEventListener("DOMContentLoaded",()=>{let a=window.CONFIG.algolia,{indexName:t,appID:n,apiKey:o}=a,s=window.instantsearch({indexName:t,searchClient:window.algoliasearch(n,o),searchFunction:i=>{document.querySelector(".search-input").value&&i.search()}});s.addWidgets([window.instantsearch.widgets.configure({hitsPerPage:a.hits.per_page||8}),window.instantsearch.widgets.searchBox({container:".search-input-container",placeholder:window.CONFIG.i18n.placeholder,showReset:!1,showSubmit:!1,showLoadingIndicator:!1,cssClasses:{input:"search-input"}}),window.instantsearch.widgets.stats({container:"#algolia-stats",templates:{text:i=>`${window.CONFIG.i18n.hits_time.replace(/\$\{hits}/,i.nbHits).replace(/\$\{time}/,i.processingTimeMS)} + + Algolia + +
`}}),window.instantsearch.widgets.hits({container:"#algolia-hits",templates:{item:i=>`${i._highlightResult.title.value}`,empty:i=>`
+ ${window.CONFIG.i18n.empty.replace(/\$\{query}/,i.query)} +
`},cssClasses:{item:"algolia-hit-item"}}),window.instantsearch.widgets.pagination({container:"#algolia-pagination",scrollTo:!1,showFirst:!1,showLast:!1,templates:{first:'',last:'',previous:'',next:''},cssClasses:{root:"pagination",item:"pagination-item",link:"page-number",selectedItem:"current",disabledItem:"disabled-item"}})]),s.start()}); diff --git a/js/search/local-search.js b/js/search/local-search.js new file mode 100644 index 00000000..14015a3c --- /dev/null +++ b/js/search/local-search.js @@ -0,0 +1,3 @@ +document.addEventListener("DOMContentLoaded",()=>{let c=window.CONFIG,d=window.CONFIG.local_search.path;if(!d){console.warn("`hexo-generator-searchdb` plugin is not installed!");return}let t=new LocalSearch({path:d,top_n_per_article:c.localsearch.top_n_per_article,unescape:c.localsearch.unescape}),i=document.querySelector(".search-input"),o=()=>{if(!t.isfetched)return;let s=i.value.trim().toLowerCase(),l=s.split(/[-\s]+/),n=document.querySelector(".search-result-container"),a=[];if(s.length>0&&(a=t.getResultItems(l)),l.length===1&&l[0]==="")n.classList.add("no-result"),n.innerHTML='
';else if(a.length===0)n.classList.add("no-result"),n.innerHTML='
';else{a.sort((e,r)=>e.includedCount!==r.includedCount?r.includedCount-e.includedCount:e.hitCount!==r.hitCount?r.hitCount-e.hitCount:r.id-e.id);let u=c.i18n.hits.replace(/\$\{hits}/,a.length);n.classList.remove("no-result"),n.innerHTML=`
${u}
+
+ `}};t.highlightSearchWords(document.querySelector(".post-body")),c.localsearch.preload&&t.fetchData(),c.localsearch.trigger==="auto"?i.addEventListener("input",o):(document.querySelector(".search-icon").addEventListener("click",o),i.addEventListener("keypress",s=>{s.key==="Enter"&&o()})),window.addEventListener("search:loaded",o),document.querySelectorAll(".popup-trigger").forEach(s=>{s.addEventListener("click",()=>{document.body.classList.add("search-active"),setTimeout(()=>i.focus(),500),t.isfetched||t.fetchData()})})}); diff --git a/js/sidebar.js b/js/sidebar.js new file mode 100644 index 00000000..47910d60 --- /dev/null +++ b/js/sidebar.js @@ -0,0 +1 @@ +function u(o){if(o.classList.contains("active-current"))return;document.querySelectorAll(".post-toc .active").forEach(s=>{s.classList.remove("active","active-current")}),o.classList.add("active","active-current");let c=o.parentNode;for(;!c.matches(".post-toc");)c.matches("li")&&c.classList.add("active"),c=c.parentNode}function f(){let o=document.querySelectorAll(".post-toc li");if(!o.length)return;let c=[...o].map(t=>{let e=t.querySelector(".toc-link"),n=document.getElementById(decodeURI(e.getAttribute("href")).replace("#",""));return e.addEventListener("click",a=>{a.preventDefault(),window.scrollTo(0,n.offsetTop+1)}),n});function s(t){let e=0,n=t[e];if(n.boundingClientRect.top>0)return e=c.indexOf(n.target),e===0?0:e-1;for(;e{let i=document.documentElement.scrollHeight+100;if(i>t){a.disconnect(),r(i);return}let l=s(n);u(o[l])},{rootMargin:`${t}px 0px -100% 0px`,threshold:0});c.forEach(n=>{n&&e.observe(n)})}r(document.documentElement.scrollHeight)}function d(){let o="sidebar-nav-active",c="sidebar-panel-active";function s(){let t=document.querySelector(".sidebar-nav-toc"),e="ri:list-ordered",n="ri:list-unordered";t&&t.addEventListener("click",()=>{if(console.log("click"),t.classList.contains(o)){let i=t.querySelector(".iconify");i.dataset.icon=i.dataset.icon===e?n:e,document.querySelectorAll(".toc-number").forEach(l=>{l.classList.toggle("hidden")})}})}function r(){document.querySelectorAll(".sidebar-nav li").forEach(e=>{e.onclick=function(){this.classList.contains(o)||(document.querySelector(`.${c}`).classList.remove(c),document.querySelector(`#${this.dataset.target}`).classList.add(c),document.querySelector(`.${o}`).classList.remove(o),this.classList.add(o))}})}s(),r(),f()}document.addEventListener("DOMContentLoaded",d);document.addEventListener("pjax:success",d); diff --git a/js/ui/banner.js b/js/ui/banner.js new file mode 100644 index 00000000..fa5f908e --- /dev/null +++ b/js/ui/banner.js @@ -0,0 +1 @@ +import"../chunk-FEIY7W7S.js";function u(t,a){return Math.random()*(a-t)+t}function y(t){let a=0,r=document.querySelector(".vertical-line-top"),o=document.querySelector(".vertical-line-bottom"),s=document.querySelector(".banner-char-container");s.innerHTML="";for(let n=0;n${m}`;let d=`${c}rem`;e.classList.add("char-box"),s.appendChild(e),n%2===0?(e.classList.add("char-left"),e.style.animationName="char-move-left"):(e.classList.add("char-right"),e.style.animationName="char-move-right"),e.style.setProperty("--banner-char-size",d);let h=window.getComputedStyle(document.getElementsByClassName("char-box")[n]).getPropertyValue("width");e.style.setProperty("--banner-empty-border-size",h),a+=c}let i=`calc(50vh - ${a/2}rem)`;r.style.setProperty("--banner-line-height",i),o.style.setProperty("--banner-line-height",i),r.style.animationName="extend-line",o.style.animationName="extend-line"}function l(){document.getElementById("banner")&&setTimeout(()=>{y(window.CONFIG.title)},50)}document.addEventListener("DOMContentLoaded",l);document.addEventListener("pjax:success",l);export{u as random}; diff --git a/js/ui/fireworks.js b/js/ui/fireworks.js new file mode 100644 index 00000000..0134fad2 --- /dev/null +++ b/js/ui/fireworks.js @@ -0,0 +1 @@ +function P(e){let s=["102, 167, 221","62, 131, 225","33, 78, 194"];e=Object.assign({colors:s,numberOfParticles:20,orbitRadius:{min:50,max:100},circleRadius:{min:10,max:20},diffuseRadius:{min:50,max:100},animeDuration:{min:900,max:1500}},e);let u=0,l=0,c=e.colors||s,o=document.querySelector(".fireworks"),t=o.getContext("2d");function m(n){n.width=window.innerWidth,n.height=window.innerHeight,n.style.width=`${window.innerWidth}px`,n.style.height=`${window.innerHeight}px`}function h(n){u=n.clientX||(n.touches[0]?n.touches[0].clientX:n.changedTouches[0].clientX),l=n.clientY||(n.touches[0]?n.touches[0].clientY:n.changedTouches[0].clientY)}function f(n){let a=window.anime.random(0,360)*Math.PI/180,i=window.anime.random(e.diffuseRadius.min,e.diffuseRadius.max),d=[-1,1][window.anime.random(0,1)]*i;return{x:n.x+d*Math.cos(a),y:n.y+d*Math.sin(a)}}function x(n,a){let i={x:n,y:a,color:`rgba(${c[window.anime.random(0,c.length-1)]},${window.anime.random(.2,.8)})`,radius:window.anime.random(e.circleRadius.min,e.circleRadius.max),endPos:null,draw(){}};return i.endPos=f(i),i.draw=function(){t.beginPath(),t.arc(i.x,i.y,i.radius,0,2*Math.PI,!0),t.fillStyle=i.color,t.fill()},i}function b(n,a){let i={x:n,y:a,color:"#000",radius:.1,alpha:.5,lineWidth:6,draw(){}};return i.draw=function(){t.globalAlpha=i.alpha,t.beginPath(),t.arc(i.x,i.y,i.radius,0,2*Math.PI,!0),t.lineWidth=i.lineWidth,t.strokeStyle=i.color,t.stroke(),t.globalAlpha=1},i}function w(n){for(let a=0;a{t.clearRect(0,0,o.width,o.height)}});document.addEventListener("mousedown",n=>{p.play(),h(n),g(u,l)},!1),m(o),window.addEventListener("resize",()=>{m(o)},!1)}document.addEventListener("DOMContentLoaded",()=>{let e={};window.CONFIG.fireworks.colors&&(e.colors=window.CONFIG.fireworks.colors),P(e)}); diff --git a/js/utils.js b/js/utils.js new file mode 100644 index 00000000..5e8e8e6d --- /dev/null +++ b/js/utils.js @@ -0,0 +1 @@ +import{a,b,c,d,e,f,g,h}from"./chunk-72ZP56JR.js";import"./chunk-FEIY7W7S.js";export{a as copyright,d as getScript,e as insertCopyCodeBtn,b as isHome,g as registerScrollPercent,h as registerToggleSidebar,f as renderKatex,c as wrapTable}; diff --git a/page/2/index.html b/page/2/index.html new file mode 100644 index 00000000..52de2ded --- /dev/null +++ b/page/2/index.html @@ -0,0 +1,46 @@ +Guo_Yun + + + + + + + + + +
Powered by Hexo v6.2.0|Theme - Yun v1.10.11
\ No newline at end of file diff --git a/page/3/index.html b/page/3/index.html new file mode 100644 index 00000000..cba533d5 --- /dev/null +++ b/page/3/index.html @@ -0,0 +1,46 @@ +Guo_Yun + + + + + + + + + +
Powered by Hexo v6.2.0|Theme - Yun v1.10.11
\ No newline at end of file diff --git a/tags/note/index.html b/tags/note/index.html new file mode 100644 index 00000000..9e401082 --- /dev/null +++ b/tags/note/index.html @@ -0,0 +1,46 @@ +Tag - note | Guo_Yun + + + + + + + + + +
Powered by Hexo v6.2.0|Theme - Yun v1.10.11
\ No newline at end of file diff --git a/tags/note/page/2/index.html b/tags/note/page/2/index.html new file mode 100644 index 00000000..7adadcd8 --- /dev/null +++ b/tags/note/page/2/index.html @@ -0,0 +1,46 @@ +Tag - note | Guo_Yun + + + + + + + + + +

note

2022

没有更多的黑历史了_(:з」∠)_
Powered by Hexo v6.2.0|Theme - Yun v1.10.11
\ No newline at end of file diff --git a/yun.png b/yun.png new file mode 100644 index 00000000..fb6026b7 Binary files /dev/null and b/yun.png differ diff --git a/yun.svg b/yun.svg new file mode 100644 index 00000000..f54921e8 --- /dev/null +++ b/yun.svg @@ -0,0 +1,21 @@ +