Computer Simulations and Analyses on Parrondos's Paradox
DarkMoon_Dragon · · 个人记录
Computer Simulations and Analyses on Parrondos's Paradox
Leading by LRL,WYB coauthored
P.S. 这是在没有查阅相关马氏链背景下撰写的文章,现在回过来看有很大一部分是「天真的猜想」,不过对一个概率论初学者而言也是十分珍贵的过程
Abstract
现有两个独立的公平赌局 A 和 B,当长期单独进行 A 或 B 时,期望收益都是亏损的。但如果考虑这两个赌局组合进行,则存在一种获利的策略。针对赌局 A, B 的组合模型,我们首先通过马尔可夫链及迭代法定量分析了单一游戏的期望收益。随后通过离散马尔可夫链对帕隆多悖论中的基本模型、交叉模型的进行建模,并提出了通⽤的定量计算单次赌局期望的⽅法,并从马尔可夫矩阵的角度对这个反直觉的现象进行定量分析,然后重新引入了 Harmer 等⼈通过布朗棘轮的类比获得的关于此现象的直观理解。我们最终发现尽管单独进⾏游戏 A 或游戏 B 是负数收益,但是当游戏 AB 以某种模式交替进⾏时,期望收益会变成正数。我们对该模式展开了叙述,并通过计算机模拟进行验证。这种现象被称为帕隆多悖论,其在⾦融市场中有⼴泛的应⽤前景。
关键字:Parrondo's Paradox, Markov Chain, Random Walk, Graph Theory, Probability
1. Introduction
对概率的研究可以追溯到十七世纪,从数学家对赌博问题的研究开始。如今,概率在神经网络、计算智能中的应用大放异彩。其中,马尔可夫模型 [1] 在互联网生态中已有广泛应用,如谷歌网页排名算法。而 Parrondo 提出的悖论 [2] 则是一个可以通过马尔可夫链构造的反直觉模型,这个模型由将两个失败的策略结合,产生一个获胜的策略。本文首先阐述了帕隆多悖论中基本模型的定量分析方法,并解释了为什么负数期望游戏组合进行游玩会产生正数收益。
1.1 Parrondo's Games [2]
1.1.1 Game A
考虑游戏 A:初始资金为
- 其中,
\varepsilon 是一个调整概率的超参数
令随机变量
当
1.1.2 Game B
1.1.2.1 Game B Definition
游戏 B :如果当前资金是
例如
下令
1.1.2.2 Game B Computer Simulation
下图为不同次数的计算机模拟,观察出游戏 B 的收益和次数的线性关系。 (Appendix code i)
-
<img src="https://cdn.jsdelivr.net/gh/KINGLRL/ImageHost/imgs/Parrondos0.png" alt="image-20221113220005230" style="zoom: 67%;" /> FIG. 1. -
<img src="https://cdn.jsdelivr.net/gh/KINGLRL/ImageHost/imgs/Parrondos1.png" alt="image-20221113220035860" style="zoom: 67%;" /> FIG. 2. -
<img src="https://cdn.jsdelivr.net/gh/KINGLRL/ImageHost/imgs/Parrondos2.png" alt="image-20221113220116878" style="zoom: 67%;" /> FIG. 3. -
<img src="https://cdn.jsdelivr.net/gh/KINGLRL/ImageHost/imgs/Parrondos3.png" alt="image-20221113220248664" style="zoom: 67%;" /> FIG. 4. -
取
\varepsilon = -0.005 ,10^7 模拟后可以接近收支平衡:<img src="https://cdn.jsdelivr.net/gh/KINGLRL/ImageHost/imgs/Parrondos4.png" alt="image-20221113220950510" style="zoom: 67%;" />
FIG. 5.
1.1.2.3 Quatitative Analyses on Game B
设现在的资金为
-
A:n \bmod 3 =0 -
B:n \bmod 3=1 -
C:n \bmod 3 =2
根据游戏 B 的定义建立状态转移概率图,容易验证该转移满足马氏性与时齐性:
-
<img src="https://cdn.jsdelivr.net/gh/KINGLRL/ImageHost/imgs/Parrondos5.png" alt="image-20221113223835682" style="zoom: 50%;" />
FIG. 6. 其中有向边
u\to v 表示P(X_n=v \mid X_{n-1}=u)
设
-
\begin{cases} 0.255B_i + 0.745C_i = A_{i+1} \\ 0.095A_i + 0.255C_i = B_{i+1} \\ 0.745B_i + 0.905C_i = C_{i+1} \\ \end{cases}\tag{1}
由于
-
\begin{cases} -A + 0.255B + 0.745C = 0 \\ 0.095A - B + 0.255C = 0 \\ 0.905A + 0.745B - C = 0 \\ \end{cases}\tag{2} \implies \begin{bmatrix} -1 &0.255 &0.745\\ 0.095 &-1 &0.255\\ 0.905 &0.745 &-1\\ \end{bmatrix} \cdot \begin{bmatrix} A \\ B \\ C\\ \end{bmatrix} = \begin{bmatrix} 0 \\ 0 \\ 0\\ \end{bmatrix} \iff \mathbf P \cdot \mathbf y = \mathbf 0
构造常数概率方程
-
\begin{cases} -A + 0.255B + 0.745C = 0 \\ 0.095A - B + 0.255C = 0 \\ A + B + C = 1 \\ \end{cases}\tag{3} \implies \begin{bmatrix} -1 &0.255 &0.745\\ 0.095 &-1 &0.255\\ 1 &1 &1\\ \end{bmatrix} \cdot \begin{bmatrix} A \\ B \\ C\\ \end{bmatrix} = \begin{bmatrix} 0 \\ 0 \\ 1\\ \end{bmatrix} 解得假设收敛的概率为
[A\;B\;C]^\top=[0.3836\;0.1543\;0.4621]^\top .
下构造 Markov Matrix 证明概率收敛于上值:
-
先考虑初始状态
\mathbf{y}_0=\begin{bmatrix} A_0 \\ B_0 \\ C_0\\ \end{bmatrix} = \begin{bmatrix} 1 \\ 0 \\ 0\\ \end{bmatrix} -
根据方程
(1) 构造迭代方程(4) :\mathbf y^{(k+1)} = \begin{bmatrix} 0 &0.255 &0.745\\ 0.095 &0 &0.255\\ 0.905 &0.745 &0\\ \end{bmatrix} \cdot \mathbf y^{(k)} = \mathbf P \cdot y^{(k)} \tag{4} - 根据附录的迭代法收敛定理,对 任意
\mathbf x^{(0)} 序列\{\mathbf x^{(k)}\} 收敛的 充要条件 迭代矩阵的谱半径小于一:\rho (\mathbf P) < 1
构造迭代矩阵
\rho(\mathbf P) \le 1 。则该迭代矩阵不一定对任意初始向量均收敛。计算\mathbf P 的特征值及特征向量有:\begin{aligned} \mathbf P &= \begin{bmatrix} 0 &0.255 &0.745\\ 0.095 &0 &0.255\\ 0.905 &0.745 &0\\ \end{bmatrix} = \mathbf X \mathbf \Lambda \mathbf X^{-1} \\\\ &= \begin{bmatrix} 0.3816 &0.3970 &-0.3970\\ 0.1543 &0.1030 &0.5000\\ 0.4621 &-0.5000 &-0.1030\\ \end{bmatrix} \cdot \begin{bmatrix} 1.0000 &0 &0\\ 0 &-0.8721 &0\\ 0 &0 &-0.1279\\ \end{bmatrix} \cdot \begin{bmatrix} 1.0000 &1.0000 &1.0000\\ 1.0315 &0.6014 &-1.0571\\ -0.5009 &1.5676 &-0.0909\\ \end{bmatrix} \end{aligned} 则迭代
n 次后可表示为\mathbf P^n \cdot \mathbf y \begin{aligned} \mathbf P^n &= \mathbf X \mathbf \Lambda ^n \mathbf X^{-1}\\ &= \begin{bmatrix} & &\\ \mathbf x_1 &\mathbf x_2 &\mathbf x_3\\ & &\\ \end{bmatrix} \cdot \begin{bmatrix} 1 & & \\ &\lambda_2^n &\\ & &\lambda_3^n\\ \end{bmatrix} \cdot \begin{bmatrix} & &\\ &\mathbf X^{-1} &\\ & &\\ \end{bmatrix} \\ \lim_{n\to\infty} \mathbf P^n &= \begin{bmatrix} & &\\ \mathbf x_1 &\mathbf x_1 &\mathbf x_1\\ & &\\ \end{bmatrix} \end{aligned} -
注意到
\mathbf X^{-1} 第一行均为一,实际上 Markov 矩阵的左特征值恒为\mathbf 1^\top -
则当进行无穷次迭代后,由于初始状态
A_0+B_0+C_0=1 ,则(4) 式可写为\lim_{n\to\infty} \mathbf P^n \cdot \mathbf y_0= \begin{bmatrix} & &\\ \mathbf x_1 &\mathbf x_1 &\mathbf x_1\\ & &\\ \end{bmatrix} \cdot \begin{bmatrix} A_0\\ B_0\\ C_0\\ \end{bmatrix} = \begin{bmatrix} \\ \mathbf x_1\\ \\ \end{bmatrix} -
则说明最后概率一定收敛于矩阵
\mathbf P 特征值为1 对应的特征向量,只要初始状态概率和为1 ,则最终结果初始状态无关。
- 根据附录的迭代法收敛定理,对 任意
由上文分析可得最终三种情况的概率为
- 与程序模拟算出的单次期望相契合,得出结论:单独进行游戏
B 平均每局亏损-0.008724
1.2 Markov Chains
1.2.1 Markov Martrix
对于不同的参数
考虑问题
-
转移矩阵中的元素
p_{ij} 代表在n 时刻位于点j ,n+1 时刻走向点i 的概率。且p_{ij} 与n 无关。即下一个概率状态\mathbf y_{n+1} 只与n 时刻状态\mathbf y_{n} 有关,与历史状态无关; -
所有的
p_{ij}>0 且\mathbf P 的每一列之和为一,即所有的概率为正数且每个点的概率出度为一。那么\mathbf 1^\top \mathbf P = \mathbf 1^\top ,即p_{1j}+p_{2j}+\cdots+p_{Nj}=1 . -
状态转移矩阵有最大特征值
\lambda_1=1 且其对应的特征向量\mathbf x_1 >0 (为正) ; -
已知初始概率
\mathbf y_{0} 或其满足的条件。 -
并且可构造对应概率转移图,例如:
<img src="https://cdn.jsdelivr.net/gh/KINGLRL/ImageHost/imgs/Parrondos5.png" alt="image-20221113223835682" style="zoom: 50%;" />
FIG. 7.
形式化地讲,转移方程
转移方程
既然所有的
注意到并非所有的情况下均会收敛,虽然概率不会指数爆炸,但是可能出现跳跃的情况(不收敛),例如
1.2.2 Positive P or Nonegative P
对于转移概率矩阵,
由于
-
\mathbf P_2$ 包含零元素。则可能存在第二个大小为 $1$ 特征向量 $\lambda_2 -
1. 最大的特征值 $\lambda_1$ 及其对应的特征向量 $\mathbf v_1$ 是严格大于零的。 2. 其他特征值 $\lambda_2,\cdots,\lambda_N$ 有 $|\lambda| < \lambda_1$,对 Markov 矩阵有 $\lambda_1 = 1$。
对所有元素严格为正的矩阵
- 所以
\mathbf P^\top 是一个非负矩阵,特征值其一为\lambda=1 ,对应的特征向量\mathbf 1 = (1,1,\cdots,1)^\top
对于一般情况,即矩阵
考虑将特征值小于一的部分单独分解出来,构造
那么,
-
\mathbf A$ 的所有特征值 $|\lambda|<1$,所以 $\lim_{n\to \infty}\mathbf A^n = \mathbf 0
- 找到一个上三角矩阵
\mathbf S = \mathbf M^{-1} \mathbf A\mathbf M ,其范数||\mathbf S||<1 - 那么
\mathbf A^n = (\mathbf M\mathbf S\mathbf M^{-1})^n = \mathbf M \mathbf S^n\mathbf M^{-1} ,有||\mathbf A^n|| \le ||\mathbf M||||\mathbf S||^n||\mathbf M^{-1}||\to0
由于
- 最大的特征值并不是矩阵范数,如果
a,b,c 很大\mathbf S^2,\mathbf S^3 仍然会增长,直至n 较大时特征值将\mathbf S^n 拉回零矩阵。如果要一开始即保证不增长需要||\mathbf S||<1 . - 我们已经有
|\lambda_i| <1 ,如果a,b,c 非常小,则\mathbf S 的范数仍然小于一
由 Schur's Theorem, 任意矩阵
则对非常小的
至此,我们证明了
1.3 Random Walk Problem
1.3.1 Problem Description
事实上,该概率模型可以等价于另一个图论模型:随机游走问题。[5]
-
给定一张简单强连通有向图
G = (V, E) ,对于所有1 ≤ s ≤ n, 1 ≤ t ≤ n\;(s\ne t) ,回答:有一枚棋子起始被放在
v_s ,每秒棋子会从当前点的出边中等概率选择一条走到出边指 向的点,求到达v_t 的期望时间。
1.3.2 Analyses
记
记
转移概率矩阵的构造方法同 1.2,记
若已知
我们记 1.2 中的
-
$$ \begin{aligned} \mathbf G &= \mathbf J + \mathbf P \cdot\mathbf F - \mathbf F \\ \pi\mathbf G &= \pi\mathbf J + \pi\mathbf P \cdot\mathbf F - \pi\mathbf F \\ \pi\mathbf G &= \pi\mathbf J \\ \end{aligned} $$ 所以有 $$ \pi_i g_i = \sum_{j=1}^n \pi_j = 1 $$
通过引入稳态分布,并由附录的矩阵树定理,得到一个非常重要的推论:
- 对于一个强联通图
G=(V,E) 的概率转移矩阵\mathbf P ,\mathbf I - \mathbf P 的秩为n-1
那么只要假定概率收敛,再添加一条初始概率为和
1.4 Brownian Ratchets
<img src="https://cdn.jsdelivr.net/gh/KINGLRL/ImageHost/imgs/Parrondos6.png" alt="image-20221205102905432" style="zoom:67%;" />
- FIG. 8. 一个含有棘轮和棘爪的机器。有两个盒子,一个盒子里有一个叶片,一个轮子只能单向转动,另一个盒子里有一个棘轮和棘爪。每个盒子都处于处于平衡状态的气体分子的热浴中。这两个盒子通过一个隔热的轴机械连接。整个装置可被视为缩小到微观尺寸,这样气体分子就可以随机地轰炸叶片以产生运动。[6]
上图所示的是一个含有棘轮和棘爪的机器。它在 1962 年作为一种永动机由费曼提出。此设计是基于先前波兰物理学家斯莫卢霍夫斯基 (M. Smoluchowski, 1912) 研究工作。斯莫卢霍夫斯基设想出一个机器,可以从温度平衡系统的热能中撷取有用的功。该装置是分子尺度的,利用气体分子的热布朗波动来对外做功。其工作方式如下如图所示,此机器由一小桨轮,和一个由轮轴所联结的棘轮所组成。它们分别处于两个盒子中,每个盒子都处于平衡状态的气体分子的热浴中,且这两个盒子的热浴温度相等,即
费曼校正了斯莫卢霍夫斯基的假想性实验 [7],他证明了棘轮不会一直沿同方向转动[6],因为制转杆也会呈现布朗运动,会上下抖动,因此棘轮的轮齿有时会向后滑动,而不是向前转动。费曼对此装置做了第一个定量分析,得到的结论是,随着时间的流逝,机器向后转动和向前转动会一样多,因此抵消了任何做功的可能;而且很可能由于没有外在的能量来源让它继续转动,最后会丧失能量。实际上,只有给系统输入能量来维持
Magnasco 于 1993 年发表了一篇关于布朗棘轮 [8] 的论文,其中阐述了布朗微粒可以在特定的空间非对称能量势的作用下产生定向移动。
其中一个引人注目的例子是,当一个 (向下) 倾斜的被周期性地 "开” 和 “关”,通过解这个 “交错棘轮” 的福克-普朗克方程,布朗粒子可以 “上坡” 移动 (Doering, 1995).。而如果电位一直保持在 “开” 或 “关” 状态,粒子就会 “下坡” 移动。这是帕朗多悖论的灵感来源:每个独立的状态都是一个“输掉” 的游戏,但当它们交替出现时,会产生让粒子 “上坡运动” 的效果,或说是 “获胜” 的期望。
2.1 Results
2.2.1 Analyses on AB in turns
上文定性、定量系统地分析了游戏
考虑以下情景,如果我们交替进行游戏
-
FIG. 9.
$[a=2,b=2]$ 表示 $AABBAABB\cdots$ 交替进行。 $[a=0,b=0]$ 表示随机进行两种游戏。即问题(3),可以看出其收益为正数。
现在引入新的一种方式来表示这个游戏。如果游戏
下图绘制了
-
<img src="https://cdn.jsdelivr.net/gh/KINGLRL/ImageHost/imgs/Parrondos8.png" alt="image-20221204194630964" style="zoom:150%;" />
FIG. 10.
问题(2) 为
ABBABB\cdots ,单局期望收益有极大值,5.714\times10^{-2}
expectation[b, a] =
a = 1, 6 a = 2, 7 a = 3, 8 a = 4, 9 a = 5, 10
[b = 1 [-6.77011e-03 8.87010e-03 6.24250e-03 3.27970e-03 1.61430e-03
-2.98100e-04 -1.68310e-03 -2.80670e-03 -3.20330e-03 -3.40810e-03]
b = 2 [*5.71431e-02* 1.46251e-02 2.00657e-02 1.01691e-02 9.72610e-03
6.65650e-03 4.37210e-03 2.86550e-03 2.28210e-03 1.31050e-03]
b = 3 [-2.78710e-03 1.08350e-03 4.72100e-04 -1.57590e-03 -2.45330e-03
-3.42490e-03 -3.61850e-03 -4.36010e-03 -4.80130e-03 -5.23950e-03]
b = 4 [ 2.95377e-02 5.19630e-03 1.04617e-02 4.97170e-03 4.93490e-03
3.07010e-03 2.23470e-03 8.96900e-04 -1.38900e-04 -9.17900e-04]
b = 5 [ 1.31690e-03 -1.12750e-03 -2.01900e-04 -2.09470e-03 -2.47510e-03
-2.94870e-03 -3.95350e-03 -4.50690e-03 -4.75770e-03 -4.84930e-03]
b = 6 [ 1.69829e-02 1.71130e-03 5.72630e-03 1.63050e-03 1.79270e-03
3.77000e-05 -8.15100e-04 -1.08530e-03 -1.48770e-03 -2.21610e-03]
b = 7 [ 1.96870e-03 -2.52430e-03 -1.15450e-03 -2.93830e-03 -3.36250e-03
-3.58910e-03 -3.94910e-03 -4.84870e-03 -4.83650e-03 -4.57230e-03]
b = 8 [ 1.05479e-02 -9.95900e-04 2.50430e-03 5.30000e-06 -3.58900e-04
-1.74130e-03 -2.01530e-03 -2.35070e-03 -2.81710e-03 -3.41350e-03]
b = 9 [ 1.25310e-03 -3.56370e-03 -2.05030e-03 -3.86810e-03 -2.76850e-03
-4.27150e-03 -4.09670e-03 -4.78250e-03 -5.19590e-03 -5.46930e-03]
b = 10[ 6.43670e-03 -2.20150e-03 3.11900e-04 -2.10310e-03 -1.19350e-03
-3.07450e-03 -2.87650e-03 -3.68650e-03 -3.58370e-03 -3.52730e-03]]
2.2.2 Quatitative Analysis on (A_{0.005}^1B_{0.005}^1)^n
现针对游戏
画出
记
-
<img src="https://cdn.jsdelivr.net/gh/KINGLRL/ImageHost/imgs/Parrondos9.png" alt="image-20231229145018896" style="zoom:67%;" />
FIG. 11. 这是一个环。每个点的出度和入度均为二保证了这个性质。对于环上随机游走问题,期望是一定收敛的,也为问题的解决提供一种思路。
我们记状态 :
根据上图构造状态转移:
-
如上预期,
\mathbf P 的两个极大特征值为-1 和1 ,最终概率向量将在两个特征向量中来回切换 -
幸运的是,这个矩阵是可以对角化的,我们将
P 对角化后,将特征向量按照 Norm-1 归一化并乘二:A = [0 0 0 0 .255 .745; 0 0 0 .095 0 .255; 0 0 0 .905 .745 0; 0 .505 .495 0 0 0; .495 0 .505 0 0 0; .505 .495 0 0 0 0] [V, D] = eig(A) V = normalize(V, 'norm', 1).*2-
特征矩阵
\mathbf V <img src="赌局.assets/image-20221204215416643.png" alt="image-20221204215416643" style="zoom:50%;" />
其对应的特征值
<img src="赌局.assets/image-20221204212518470.png" alt="image-20221204212518470" style="zoom:50%;" />
-
-
其中,得到保留的特征向量
\mathbf v_1,\mathbf v_3 应具有特殊的性质 (\lambda_1 = -1, \lambda_3 = 1 )\mathbf v_1 = \begin{bmatrix} 0.2347\\ 0.0759\\ 0.6895\\ -0.3796\\ -0.4643\\ -0.1561 \end{bmatrix}, \mathbf v_3 = \begin{bmatrix} 0.2347\\ 0.0759\\ 0.6895\\ 0.3796\\ 0.4643\\ 0.1561 \end{bmatrix} -
考虑任意初始概率向量
\mathbf y 由\mathbf v_1,\mathbf v_2,\cdots, \mathbf v_n 线性表出。取其中不会衰减的两个特征值:\hat {\mathbf y }= c_1\cdot \mathbf v_1 + c_3\cdot \mathbf v_3 \tag{11} 考虑递推关系 :
\begin{aligned} \mathbf y_{n+1} &= \mathbf P\cdot \mathbf y_{n} = -c_1\cdot \mathbf v_1 + c_3\cdot \mathbf v_3 \\ \mathbf y_{n+2} &= \mathbf P\cdot \mathbf y_{n+1} = c_1\cdot \mathbf v_1 + c_3\cdot \mathbf v_3 \\ \end{aligned} \tag{12} 考虑
\mathbf 1^\top \mathbf y_{n} = \mathbf 1^\top \mathbf y_{n+1}=1 , 带入(12) 有c_3=1/2 ,带入(11) 有 :\hat y= c_1\cdot \begin{bmatrix} 0.2347\\ 0.0759\\ 0.6895\\ -0.3796\\ -0.4643\\ -0.1561 \end{bmatrix}+ \begin{bmatrix} 0.2347\\ 0.0759\\ 0.6895\\ 0.3796\\ 0.4643\\ 0.1561 \end{bmatrix} 考虑两个状态下分别前三个元素和后三个元素为零,则有
c_1=1/2 所以对于任意初始向量,当前特征值
\mathbf v_1,\mathbf v_3 的组合系数均为二分之一。 -
即
\lim_{n\to\infty} \mathbf y_n&= \frac 1 2(-1)^n\begin{bmatrix} 0.2347\\ 0.0759\\ 0.6895\\ -0.3796\\ -0.4643\\ -0.1561 \end{bmatrix}+ \frac 1 2 \begin{bmatrix} 0.2347\\ 0.0759\\ 0.6895\\ 0.3796\\ 0.4643\\ 0.1561 \end{bmatrix} \tag{13} -
即得
A 游戏三种状态的概率,B 游戏三种状态的概率:\textrm{Game A : } \mathbf x_A= \begin{bmatrix} A_0\\ A_1\\ A_2\\ B_0\\ B_1\\ B_2 \end{bmatrix}= \begin{bmatrix} 0.2347\\ 0.0759\\ 0.6895\\ 0\\ 0\\ 0 \end{bmatrix}, \textrm{Game B : } \mathbf x_B= \begin{bmatrix} A_0\\ A_1\\ A_2\\ B_0\\ B_1\\ B_2 \end{bmatrix}= \begin{bmatrix} 0\\ 0\\ 0\\ 0.3796\\ 0.4643\\ 0.1561 \end{bmatrix} 带入验证,可以发现
\mathbf P^{2n} = [\mathbf x_A\;\mathbf x_A\cdots\mathbf x_A], \mathbf P^{2n+1} = [\mathbf x_B\;\mathbf x_B\cdots\mathbf x_B] 符合预期。(13) 这种情形,即 1.2 所述的\lambda_2 = -1 时的概率跳跃。 -
由于交替进行,并且游戏
B 中亏钱的概率降低,所以导致最终结果向正期望偏移。如果能矫正概率分布使得B_0 的比率尽量小,则可以做到正数收益。所以本质上说由于游戏A 与游戏B 的交互,导致游戏B 的概率分布变化,从而导致游戏期望收益变成正数。
计算最终单次期望,
-
\begin{aligned} \mathbb E(\bar{x}) &= \sum_{i=1}^3\mathbb E(x \mid A_i)\cdot P(A_i) + \mathbb E(x \mid B_i)\cdot P(B_i) \\ &=-0.010/2+ (0.3796\cdot-0.81+0.4643\cdot0.49+0.1561\cdot 0.49)/2\\ &=-0.00674 \end{aligned} 与程序模拟的期望
-6.77011e-03在误差允许的范围内,故可说明计算正确。
2.2.3 Discussions
对于上面交替进行两种赌局,实际上可以等价考虑为粒子在交替出现的势能场下的布朗运动。考虑一个一维的坐标轴中交替出现两个势能
<img src="https://cdn.jsdelivr.net/gh/KINGLRL/ImageHost/imgs/Parrondos12.png" alt="image-20231229145143987" style="zoom:67%;" />
- FIG. 12. 棘轮势的作用机理。左边的图表,
(a)-(c) ,展示了没有宏观梯度存在且粒子的净运动的方向向右(箭头方向)。右边的图表(d)-(f) 有轻微的梯度,这导致粒子在U_{\text{off}} 作用后整体向做移动,尽管正向粒子的净流量减少了,但粒子整体仍在向右移动。
势能场
考虑上文中的棘轮势,与赌局的结果有着惊人的相似性。
鉴于这两个模型的相似性,我们可以提出一个合理的假设:上述的赌局游戏也有一个和资金状况相关联的 “势场”。如果这个势场存在,为了如何找到这个势场?在一个真实的物理系统中,一种可行的测定方法是将粒子均匀地放置在电势存在的地方,记录它们的起始位置,然后释放这些粒子,直至它们达到平衡,然后记录其停止的位置。例如,如果存在一个如图 12(a) 所示的未知的势,那么结果将如图 13(a) 所示。粒子的轨迹模式与电势的形状直接相关。对于游戏 B,我们可以把本金看作布朗棘轮中的粒子。因此,为了找到游戏 B 的势,我们从不同数量的本金开始,玩一些游戏,直到达到稳定状态,并记录最终的资金。结果如图 13(a) 所示。游戏 B 的资金流动图示为 13(b) 中,每当资金达到 3 的倍数时,状态重复,与 1.1.2.3 中按照同余类定义三种等价状态相同。由此得到的势以图 13(c) 中的实线表示。尽管本金不同,但最终的资金结果可能汇聚在一起(例如,本金分别为 2.3 和 2.5),在结果产生的势中就会形成狭窄的峰。通过将尖刺两侧的分布分布近似为单一分布,可以去除尖刺,以提供更清晰的势图。所得到的动态结果如图 13(c) 中的虚线所示。这由一个对称势和一个不对称势组成,因此可以认为最后的等价势在整个周期内是不对称的。
<img src="https://cdn.jsdelivr.net/gh/KINGLRL/ImageHost/imgs/Parrondos13.png" alt="image-20231229145246593" style="zoom:67%;" />
- FIG. 13.
两个模型都有非常相似的势。因此,我们期望这两个系统的基本特征也是相似的。我们从图 12(b) 中的
References
- Norris J R, Norris J R. Markov chains[M]. Cambridge university press, 1998.
- Harmer G P, Abbott D. Losing strategies can win by Parrondo's paradox[J]. Nature, 1999, 402(6764): 864-864.
- Strang G, Strang G, Strang G, et al. Introduction to linear algebra[M]. Wellesley, MA: Wellesley-Cambridge Press, 1993.
- Perron–Frobenius theorem - Wikipedia (https://en.wikipedia.org/wiki/Perron–Frobenius_theorem)
- IOI2019 中国国家候选队论文集, 浅谈图模型上的随机游走问题, 成都市第七中学,王修涵
- Harmer G P, Abbott D. Parrondo's paradox[J]. Statistical Science, 1999: 206-213.
- Parrondo and Espafiol disagree with the efficiency of the ratchet and pawl engine calculated by Feynman; Parrondo and Espaniol, 1996
- Magnasco M O. Forced thermal ratchets[J]. Physical Review Letters, 1993, 71(10): 1477.
Appendix
A. Code
i. Game B
# 模拟游戏 B 的期望收益
%matplotlib inline
import math
import time
import numpy as np
import torch
from d2l import torch as d2l
import random
x = []
y = []
n = 0
def play(n): # 模拟单次游戏
x = random.randint(1, 10000)
if (n % 3 == 0): # 如果是三倍数
if (x <= 950): return 1
else: return -1
else:
if (x <= 7450): return 1 # 如果不是三的倍数
else: return -1
for i in range(1, 10000000):
n = n + play(n)
y.append(n)
x.append(i)
d2l.plot(x[::], y[::], xlabel='times',
ylabel='money', figsize=(9, 5))
ii. 2D image of [A_{0.005}^aB_{0.005}^b]
# 绘制 AB 轮流进行的二维收益线性图
%matplotlib inline
import math
import time
import numpy as np
import torch
from d2l import torch as d2l
import random
def play1(n):
x = random.randint(1, 10000)
if (n % 3 == 0):
if (x <= 950): return 1
else: return -1
else:
if (x <= 7450): return 1
else: return -1
def play2():
x = random.randint(1, 1000)
if (x <= 495): return 1
else: return -1
times = 10000
def simulate(a = 0, b = 0):
y = []
n = 0
roundcnt = a + b
if (a != 0 and b != 0):
for i in range(1, times):
if (i % roundcnt < a): n = n + play1(n)
else: n = n + play2()
y.append(n)
else: # 随机进行
for i in range(1, times):
if (random.randint(1, 10) > 5): n = n + play1(n)
else: n = n + play2()
y.append(n)
return y
x = list(range(1, times))
params = [(1, 1), (1, 2), (0, 0), (2, 2)]
d2l.plot(x, [simulate(a, b) for a, b in params], xlabel='times of gambling',ylabel='gain', figsize=(9, 5),
legend=[f'[a={a}, b={b}]' for a, b in params])
d2l.plot(x, [simulate(a, b) for a, b in params], xlabel='times of gambling',ylabel='gain', figsize=(9, 5),
legend=[f'[a={a}, b={b}]' for a, b in params])
iii. 3D image of [A_{0.005}^aB_{0.005}^b]
# 绘制 [10,10] 的三维收益关系图
%matplotlib inline
import math
import time
import numpy as np
import torch
import random
from mpl_toolkits import mplot3d
import numpy as np
import matplotlib.pyplot as plt
def play1(n):
x = random.randint(1, 10000)
if (n % 3 == 0):
if (x <= 950): return 1
else: return -1
else:
if (x <= 7450): return 1
else: return -1
def play2():
x = random.randint(1, 1000)
if (x <= 495): return 1
else: return -1
times = 10000000
def simulate(a = 0, b = 0): # 模拟游戏
y = []
n = 0
roundcnt = a + b
if (a != 0 and b != 0):
for i in range(1, times):
if (i % roundcnt < a): n = n + play1(n)
else: n = n + play2()
y.append(n)
else: # 随机进行
for i in range(1, times):
if (random.randint(1, 10) > 5): n = n + play1(n)
else: n = n + play2()
y.append(n)
return y[-1] / times
x = list(range(1, times))
params = [(1, 1), (1, 2), (0, 0), (2, 2)]
X = []
Y = []
Z = []
for x in range(1, 11):
for y in range(1, 11):
X.append(x), Y.append(y), Z.append(simulate(x, y))
X = np.arange(1, 11)
Y = np.arange(1, 11)
X, Y = np.meshgrid(X, Y)
Z = np.array(Z)
Z = Z.reshape((10, 10))
maxz = np.max(Z)
print(Z)
font={'family':'serif',
'style':'italic',
'weight':'normal',
'color':'red',
'size':16
}
fig = plt.figure(figsize=(15, 15))
ax = plt.axes(projection='3d')
XX = np.arange(0.5, 11.5, 1)
YY = np.arange(0.5, 11.5, 1)
XX, YY = np.meshgrid(XX, YY)
Z2 = np.zeros((11, 11))
ax.set_xlim(10, 0)
ax.set_ylim(0, 10)
# 调用plot_surface()函数
ax.plot_surface(X, Y, Z,cmap='plasma', edgecolor='white', alpha=1)
ax.plot_surface(XX, YY, Z2,cmap='plasma',alpha=0.3)
ax.set_title('Simulations')
ax.set_xlabel('times of A')
ax.set_ylabel('times of B')
ax.set_zlabel('Gains ratio')
ax.set(zticklabels=[])
plt.xticks(np.arange(1, 11, 1))
plt.yticks(np.arange(1, 11, 1))
ax.text(1 + 1.6 , 2 , maxz, "Maximum at [1, 2]", fontdict = font)
# ax.invert_xaxis()
plt.show()
B. 迭代方程
向量收敛
向量收敛本质为
一个
常见向量范数
-
L_2$ 范数:$||x||_2=\left(\sum_{i=1}^n x_i^2\right)^{1/2} -
L_1$ 范数:$||x||_1=\sum_{i=1}^n |x_i| -
\infty $ 范数:$||x||_{\infty} = \max_{1\le i\le n}|x_i|
范数等价性
对于
-
\forall \mathbf x \in \mathbb R ^n,\;m||\mathbf x||_{\beta} \le ||\mathbf x||_{\alpha} \le M||x||_{\beta}
一个点列如果在任意一个范数意义下收敛,则在其它所有范数意义下收敛。
那么只用验证无穷范数意义下收敛。
依坐标收敛
满足
依范数收敛
满足
矩阵范数 Matrix Norms
满足条件:
-
非负性
-
齐次性
|| c \cdot \mathbf A|| = |c| \cdot||\mathbf A|| -
三角不等式 Triangle Inequality
||\mathbf A + \mathbf B|| \le || \mathbf A + \mathbf B || -
相融性 Growth factor
||\mathbf A|| 相融性:设
||\mathbf x||,||\mathbf A|| 分别为\mathbb R^n, \mathbb R^{n\times n} 上的范数,如果满足||\mathbf{Ax}|| \le ||\mathbf A|| \cdot ||\mathbf x|| ,则称该矩阵范数与此向量范数相融|| \mathbf A \mathbf x|| \le ||\mathbf A||\cdot||\mathbf x|| \textrm{ and } ||\mathbf {AB}|| \le ||\mathbf A||\cdot ||\mathbf B||
定义:矩阵的算子范数:设
-
||\mathbf A||_p= \sup_{\mathbf x \ne 0} \frac{||\mathbf{Ax}||_p}{||\mathbf x||_p}=\max _{||\mathbf x||_p=1} ||\mathbf{Ax}||_p -
称为矩阵的算子范数
- 例如
||\mathbf I || = ||\mathbf Q|| =1 : errors don't grow - 根据定义有
|| \mathbf A \mathbf x|| \le ||\mathbf A||\cdot||\mathbf x|| - 对角矩阵的矩阵范数等于其最大元素(最大特征值)
- 例如
-
若矩阵为对称正定矩阵,则
||\mathbf A|| = \lambda_{\max}(\mathbf A) 对任意矩阵,推广为
||\mathbf A||^2 = \max_{\mathbf x \ne 0} \frac{|| \mathbf A \mathbf x || ^2}{||\mathbf x||^2} = \max_{\mathbf x \ne 0} \frac{\mathbf x^\top \mathbf A^\top \mathbf A \mathbf x}{\mathbf x^\top \mathbf x} = \lambda_{\max} (\mathbf A ^\top \mathbf A) 证明:
-
设
\mathbf A^\top \mathbf A 的特征向量为\mathbf q_1, \mathbf q_2,\cdots, \mathbf q_n . 则任意向量\mathbf x 均可由特征向量线性表出,且\mathbf q_i^\top \mathbf q_j=0 -
\begin{aligned} \max_{\mathbf x \ne 0} \frac{\mathbf x^\top \mathbf A^\top \mathbf A \mathbf x}{\mathbf x^\top \mathbf x} &= \frac{(c_1\mathbf q_1 + \cdots + c_n \mathbf q_n)^\top (c_1\lambda_1\mathbf q_1 + \cdots + c_n \lambda_n \mathbf q_n)}{(c_1\mathbf q_1 + \cdots + c_n \mathbf q_n)^\top (c_1\mathbf q_1 + \cdots + c_n \mathbf q_n)} \\ &= \frac{c_1^2 \lambda_1 + \cdots + c_n^2 \lambda_n}{c_1^2 + \cdots + c_n^2} \le \lambda_{\max} \end{aligned}
-
-
补充:
|| \mathbf A|| equals the largest singular value\sigma_{\max} of\mathbf A -
又若
\mathbf A 非奇异,则||\mathbf A^{-1}||_2 = \lambda_{\min} (\mathbf A)^{-1}
三种常见的算子范数:
- 谱范数:
||\mathbf A||_2 = \sqrt{\lambda_{\max} (\mathbf A^\top \mathbf A)} - 列范数:
||\mathbf A||_1 = \max_{1 \le j\le n} \sum_{i=1}^n|a_{i,j}| - 行范数:
||\mathbf A||_\infty = \max_{1 \le i\le n} \sum_{j=1}^n|a_{i,j}|
F-范数
谱半径
设
-
-
设
\varepsilon 为任意指定小正数,则必存在算子范数||\cdot||_* 满足||\mathbf A||_* \le \rho(\mathbf A) + \varepsilon -
\lim_{n\to \infty} \mathbf A^n = 0 \iff ||\mathbf A|| < 1 \iff \rho(\mathbf A) < 1
定理:
- 若
|| \mathbf A|| < 1 则\mathbf I + \mathbf A 非奇异,且||(\mathbf I \pm \mathbf A)^{-1} || \le \frac{1}{1- || \mathbf A||}
迭代法
改写方程
则迭代矩阵为:
The speed of each step depends on
收敛性
迭代法收敛基本定理:
-
线性方程组
\mathbf A \mathbf x = \mathbf b ,迭代形式\mathbf x^{(k+1)} = \mathbf B \mathbf x^{k} + \mathbf g -
对 任意
\mathbf x^{(0)} 序列\{\mathbf x^{(k)}\} 收敛的 充要条件 为\rho (\mathbf B) < 1 -
证明:
-
\mathbf x^{(k)} - \mathbf x^* = \mathbf B (\mathbf x^{(k-1)}-\mathbf x ^*)= \cdots = \mathbf B^k (\mathbf x^{(0)}-\mathbf x^*) -
\lim_{k\to\infty}\mathbf B^{k} \to 0 \iff \rho(\mathbf B) < 1
-
-
或者从误差向量的角度来理解,矩阵
\mathbf B 对误差向量\mathbf e 压缩 -
注意
\rho (\mathbf B) \ge 1 时不能说对任意\mathbf x^{(0)} 都不收敛
误差估计:
-
设
\mathbf B = \mathbf S^{-1}\mathbf T ,若\mathbf B 的某一算子范数||\mathbf B|| <1 ,则对任意初始向量\mathbf x^{(0)} 均收敛到方程的解\mathbf x^* ,且有误差估计:|| \mathbf x^{(k)} - \mathbf x^{*}|| \le \frac{||\mathbf B||^k}{1-||\mathbf B||} ||\mathbf x^{(1)} - \mathbf x^{(0)}||\\ || \mathbf x^{(k)} - \mathbf x^{*}|| \le \frac{||\mathbf B||}{1-||\mathbf B||} ||\mathbf x^{(k)} - \mathbf x^{(k-1)}|| -
或估计残差
\mathbf r = \mathbf b - \mathbf A \mathbf x^{(k)}
对角占优矩阵
定义:
-
若矩阵
\mathbf A_{n\times n} 满足对所有的行i ,有|a_{i,i}| \ge \sum_{j \ne i} |a_{i,j}| 且至少有一个严格不等式成立,则称\mathbf A 为弱对角占优矩阵。若所有不等式均为严格大于,则称为(行)严格对角占优矩阵. -
|a_{i,i}| > \sum_{j \ne i} |a_{i,j}|, \textrm{ where } i=1,2,\cdots,n
对
-
- Jacobi 和 Gauss-Seidel 迭代均收敛