Skip to content

Commit 0ef129f

Browse files
mmckyclaude
andauthored
[action-translation] resync: exchangeable.md (#110)
* 🔄 resync exchangeable.md * Restore trailing newline (engine issue tracked in QuantEcon/action-translation#116) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent 97cf445 commit 0ef129f

2 files changed

Lines changed: 53 additions & 36 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
source-sha: a137f5d12f0be3bdb39cec11bec221bf5b1861f7
2+
synced-at: "2026-07-18"
3+
model: claude-sonnet-5
4+
mode: RESYNC
5+
section-count: 9
6+
tool-version: 0.17.0

lectures/exchangeable.md

Lines changed: 47 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,22 @@ kernelspec:
77
display_name: Python 3
88
language: python
99
name: python3
10+
translation:
11+
title: 可交换性和贝叶斯更新
12+
headings:
13+
Overview: 概述
14+
Independently and Identically Distributed: 独立同分布
15+
Independently and Identically Distributed::IID Means Past Observations Don't Tell Us Anything About Future Observations: IID意味着过去的观测不能告诉我们任何关于未来观测的信息
16+
A Setting in Which Past Observations Are Informative: 过去观测具有信息性的情况
17+
Relationship Between IID and Exchangeable: IID和可交换之间的关系
18+
Exchangeability: 可交换性
19+
Bayes' Law: 贝叶斯定律
20+
More Details about Bayesian Updating: 关于贝叶斯更新的更多细节
21+
Appendix: 附录
22+
Appendix::Sample Paths of $\pi_t$: $\pi_t$ 的样本路径
23+
Appendix::Rates of convergence: 收敛速率
24+
Appendix::Graph of Ensemble Dynamics of $\pi_t$: $\pi_t$ 的集合动态图
25+
Sequels: 后续内容
1026
---
1127

1228
(odu_v3)=
@@ -136,7 +152,7 @@ $$
136152
但在特殊的独立同分布(IID)情况下,
137153

138154
$$
139-
p(W_t | W_{t-1}, \ldots, W_0) = p(W_t)
155+
p(W_t | W_{t-1}, \ldots, W_0) = p(W_t) ,
140156
$$
141157

142158
且部分历史$W_{t-1}, \ldots, W_0$不包含关于$W_t$概率的任何信息。
@@ -163,15 +179,15 @@ $$
163179

164180
我们可以说*客观上*,即在自然选择了$F$或$G$*之后*,数据是从$F$中生成的概率要么是$0$要么是$1$。
165181

166-
现在我们在这个设定中引入一个部分知情的决策者,他知道:
182+
现在我们在这个设定中引入一个部分知情的决策者,
167183

168-
- $F$和$G$两者,但是
184+
- 知道$F$和$G$两者,但是
169185

170186
- 不知道自然在$t=-1$时一次性选择的是$F$还是$G$
171187

172-
所以我们的决策者不知道自然选择了这两个分布中的哪一个
188+
因此,尽管我们的决策者知道$F$也知道$G$,他却不知道自然选择从这两个已知分布中的哪一个进行抽样
173189

174-
决策者用**主观概率**$\tilde \pi$来描述他的不确定性,并假设自然以概率$\tilde \pi \in (0,1)$选择了$F$,以概率$1 - \tilde \pi$选择了$G$。
190+
决策者用**主观概率**$\tilde \pi$来描述他的不确定性,并推理时就好像自然以概率$\tilde \pi \in (0,1)$选择了$F$,以概率$1 - \tilde \pi$选择了$G$。
175191

176192
因此,我们假设决策者:
177193

@@ -190,7 +206,6 @@ $$
190206

191207
$$
192208
f(W_0) f(W_1) \cdots
193-
194209
$$
195210

196211
在自然选择$G$的条件下,序列$W_0, W_1, \ldots$的联合密度为
@@ -219,8 +234,7 @@ h(W_0, W_1, \ldots ) \equiv \tilde \pi [f(W_0) f(W_1) \cdots \ ] + ( 1- \tilde \
219234

220235
$$
221236
h(W_0, W_1) = \tilde \pi f(W_0)f (W_1) + (1 - \tilde \pi) g(W_0)g(W_1) \neq
222-
223-
(\tilde \pi f(W_0) + (1-\tilde \pi) g(W_0))(
237+
(\tilde \pi f(W_0) + (1-\tilde \pi) g(W_0))(
224238
\tilde \pi f(W_1) + (1-\tilde \pi) g(W_1))
225239
$$
226240

@@ -235,7 +249,6 @@ $$
235249

236250
所以过去确实包含了可以用来了解未来的信息。
237251

238-
但是什么信息?如何了解?
239252

240253
## 可交换性
241254

@@ -249,11 +262,13 @@ $$
249262

250263
更一般地说,如果一个随机变量序列的联合概率分布在有限个随机变量的位置发生改变时保持不变,则称该序列是**可交换的**
251264

252-
方程 {eq}`eq_definetti` 表示了一个可交换的联合密度函数,它是由两个独立同分布(IID)的随机变量序列的联合密度函数构成的**混合**
265+
方程 {eq}`eq_definetti` 表示了我们这个例子中的可交换联合密度,它是由两个针对随机变量序列的独立同分布(IID)联合密度构成的**混合**
253266

254-
对贝叶斯统计学家来说,混合参数 $\tilde \pi \in (0,1)$ 具有特殊的解释,即自然选择概率分布 $F$ 的主观**先验概率**
267+
贝叶斯统计学家将混合参数 $\tilde \pi \in (0,1)$ 解释为决策者的主观信念——决策者的**先验概率**——即自然选择了概率分布 $F$ 的概率
255268

256-
DeFinetti {cite}`definetti` 建立了一个相关的可交换过程表示,该过程是通过混合参数为 $\theta \in (0,1)$ 的独立同分布伯努利随机变量序列,以及混合概率密度 $\pi(\theta)$ 得到的。贝叶斯统计学家会将这个混合概率密度解释为未知伯努利参数 $\theta$ 的先验分布。
269+
```{note}
270+
DeFinetti {cite}`definetti` 建立了一个相关的可交换过程表示,该过程是通过混合参数为 $\theta \in (0,1)$ 的独立同分布伯努利随机变量序列,以及混合概率密度 $\pi(\theta)$ 得到的,贝叶斯统计学家会将这个混合概率密度解释为未知伯努利参数 $\theta$ 的先验分布。
271+
```
257272

258273
## 贝叶斯定律
259274

@@ -306,6 +321,7 @@ $$
306321
\pi_{t+1} = \frac{\pi_t f(w_{t+1})}{\pi_t f(w_{t+1}) + (1 - \pi_t) g(w_{t+1})}
307322
$$ (eq_Bayes102)
308323
324+
309325
等式{eq}`eq_Bayes102`源自贝叶斯法则,该法则告诉我们
310326
311327
$$
@@ -333,8 +349,7 @@ $$
333349
$$
334350
\pi_{t+1} =\frac{\pi_{t}f\left(w_{t+1}\right)}{\pi_{t}f\left(w_{t+1}\right)+\left(1-\pi_{t}\right)g\left(w_{t+1}\right)}
335351
=\frac{\pi_{t}\frac{f\left(w_{t+1}\right)}{g\left(w_{t+1}\right)}}{\pi_{t}\frac{f\left(w_{t+1}\right)}{g\left(w_{t+1}\right)}+\left(1-\pi_{t}\right)}
336-
337-
=\frac{\pi_{t}l\left(w_{t+1}\right)}{\pi_{t}l\left(w_{t+1}\right)+\left(1-\pi_{t}\right)}
352+
=\frac{\pi_{t}l\left(w_{t+1}\right)}{\pi_{t}l\left(w_{t+1}\right)+\left(1-\pi_{t}\right)}
338353
$$
339354
340355
这意味着
@@ -352,15 +367,13 @@ $$
352367
353368
当似然比$l(w_{t+1})$大于1时,观测值$w_{t+1}$会将分布$F$的概率$\pi$向上推动,当似然比$l(w_{t+1})$小于1时,观测值$w_{t+1}$会将$\pi$向下推动。
354369
355-
表达式{eq}`eq_Bayes103`是我们将用来显示由以下因素引起的$\{\pi_t\}_{t=0}^\infty$动态的一些图表的基础
356-
357-
贝叶斯定律。
370+
表达式{eq}`eq_Bayes103`是我们将用来显示由贝叶斯定律引起的$\{\pi_t\}_{t=0}^\infty$动态的一些图表的基础。
358371
359372
我们将绘制 $l\left(w\right)$ 来帮助我们理解学习过程是如何进行的——即,如何通过贝叶斯更新来更新自然选择分布 $f$ 的概率 $\pi$。
360373
361374
为了创建完成工作所需的 Python 基础设施,我们构建一个包装函数,该函数可以根据 $f$ 和 $g$ 的参数显示信息丰富的图表。
362375
363-
```{code-cell} ipython3
376+
```{code-cell} python3
364377
@vectorize
365378
def p(x, a, b):
366379
"通用贝塔分布函数。"
@@ -438,7 +451,7 @@ def learning_example(F_a=1, F_b=1, G_a=3, G_b=1.2):
438451
ax3.fill_between(π_grid, roots[0], roots[1], color='green', alpha=0.15)
439452
ax3.fill_between(π_grid, roots[1], w_max, color='blue', alpha=0.15)
440453
ax3.hlines(roots, 0., 1., linestyle="--")
441-
ax3.set(xlabel='$\pi$', ylabel='$w$')
454+
ax3.set(xlabel=r'$\pi$', ylabel='$w$')
442455
ax3.grid()
443456
444457
plt.show()
@@ -448,7 +461,7 @@ def learning_example(F_a=1, F_b=1, G_a=3, G_b=1.2):
448461
449462
我们将从Python函数的各种对象的默认值开始,然后在后续示例中对其进行修改。
450463
451-
```{code-cell} ipython3
464+
```{code-cell} python3
452465
learning_example()
453466
```
454467
@@ -476,7 +489,7 @@ learning_example()
476489
477490
我们保持$F$与前一个实例相同,即均匀分布,但现在假设$G$是一个参数为$G_a=2, G_b=1.6$的Beta分布。
478491
479-
```{code-cell} ipython3
492+
```{code-cell} python3
480493
learning_example(G_a=2, G_b=1.6)
481494
```
482495
@@ -495,7 +508,7 @@ learning_example(G_a=2, G_b=1.6)
495508
496509
让我们编写一些Python代码。
497510
498-
```{code-cell} ipython3
511+
```{code-cell} python3
499512
def function_factory(F_a=1, F_b=1, G_a=3, G_b=1.2):
500513
501514
# 定义 f 和 g
@@ -548,17 +561,17 @@ def function_factory(F_a=1, F_b=1, G_a=3, G_b=1.2):
548561
return simulate
549562
```
550563
551-
```{code-cell} ipython3
564+
```{code-cell} python3
552565
simulate = function_factory()
553566
```
554567
555568
我们首先生成 $N$ 条模拟的 $\{\pi_t\}$ 路径,每条路径包含 $T$ 个时期,其中序列是真实的从分布 $F$ 中独立同分布抽取的。我们设定初始先验 $\pi_{-1} = .5$。
556569
557-
```{code-cell} ipython3
570+
```{code-cell} python3
558571
T = 50
559572
```
560573
561-
```{code-cell} ipython3
574+
```{code-cell} python3
562575
# 当自然选择F时
563576
π_paths_F = simulate(a=1, b=1, T=T, N=1000)
564577
```
@@ -569,8 +582,8 @@ T = 50
569582
570583
接下来,当序列确实是来自 $G$ 的独立同分布抽样时,我们生成 $T$ 期的路径。同样,我们设定初始先验 $\pi_{-1} = .5$。
571584
572-
```{code-cell} ipython3
573-
# when nature selects G
585+
```{code-cell} python3
586+
# 当自然选择G时
574587
π_paths_G = simulate(a=3, b=1.2, T=T, N=1000)
575588
```
576589
@@ -584,7 +597,7 @@ T = 50
584597
585598
使用 $N$ 条模拟的 $\pi_t$ 路径,当数据是从 $F$ 中抽样生成时,我们在每个 $t$ 时刻计算 $1 - \sum_{i=1}^{N}\pi_{i,t}$,当数据是从 $G$ 中抽样生成时,我们计算 $\sum_{i=1}^{N}\pi_{i,t}$。
586599
587-
```{code-cell} ipython3
600+
```{code-cell} python3
588601
plt.plot(range(T+1), 1 - np.mean(π_paths_F, 0), label='F生成')
589602
plt.plot(range(T+1), np.mean(π_paths_G, 0), label='G生成')
590603
plt.legend()
@@ -608,7 +621,7 @@ $$
608621
609622
以下代码近似计算上述积分:
610623
611-
```{code-cell} ipython3
624+
```{code-cell} python3
612625
def expected_ratio(F_a=1, F_b=1, G_a=3, G_b=1.2):
613626
614627
# define f and g
@@ -628,16 +641,16 @@ def expected_ratio(F_a=1, F_b=1, G_a=3, G_b=1.2):
628641
plt.plot(π_grid, expected_rario, label=f"{q} generates")
629642
630643
plt.hlines(1, 0, 1, linestyle="--")
631-
plt.xlabel("$π_t$")
632-
plt.ylabel("$E[\pi_{t+1}/\pi_t]$")
644+
plt.xlabel(r"$\pi_t$")
645+
plt.ylabel(r"$E[\pi_{t+1}/\pi_t]$")
633646
plt.legend()
634647
635648
plt.show()
636649
```
637650
638651
首先,考虑 $F_a=F_b=1$ 且 $G_a=3, G_b=1.2$ 的情况。
639652
640-
```{code-cell} ipython3
653+
```{code-cell} python3
641654
expected_ratio()
642655
```
643656
@@ -647,16 +660,15 @@ expected_ratio()
647660
648661
从某种意义上说,这里没有什么可学习的。
649662
650-
```{code-cell} ipython3
663+
```{code-cell} python3
651664
expected_ratio(F_a=3, F_b=1.2)
652665
```
653666
654-
655667
上图表明 $\pi_t$ 是惰性的,保持在其初始值。
656668
657669
最后,让我们看一个 $f$ 和 $g$ 既不是非常不同也不完全相同的情况,特别是当 $F_a=2, F_b=1$ 且 $G_a=3, G_b=1.2$ 时。
658670
659-
```{code-cell} ipython3
671+
```{code-cell} python3
660672
expected_ratio(F_a=2, F_b=1, G_a=3, G_b=1.2)
661673
```
662674
@@ -666,4 +678,3 @@ expected_ratio(F_a=2, F_b=1, G_a=3, G_b=1.2)
666678
667679
* {doc}`本讲座 <likelihood_ratio_process>` 描述了**似然比过程**及其在频率派和贝叶斯统计理论中的作用
668680
* {doc}`本讲座 <navy_captain>` 研究了二战时期一位美国海军上尉的直觉,即海军要求他使用的(频率派)决策规则不如亚伯拉罕·瓦尔德尚未设计的序贯规则。
669-

0 commit comments

Comments
 (0)