Skip to content

Commit 10ffa8c

Browse files
mmckyclaude
andauthored
[action-translation] resync: imp_sample.md (#116)
* 🔄 resync imp_sample.md * Add missing 'import matplotlib as mpl' for the i18n font config The resync kept the CJK font-configuration block but dropped the mpl import it depends on - a NameError at execution that non-strict builds swallow. Found sweeping the wave for the pattern behind zh-cn#97's December fixes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * 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 d58fc29 commit 10ffa8c

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

.translate/state/imp_sample.md.yml

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

lectures/imp_sample.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ kernelspec:
99
display_name: Python 3
1010
language: python
1111
name: python3
12+
translation:
13+
title: 似然比过程的均值
14+
headings:
15+
Overview: 概述
16+
Mathematical expectation of likelihood ratio: 似然比的数学期望
17+
Importance sampling: 重要性采样
18+
Selecting a sampling distribution: 选择抽样分布
19+
Approximating a cumulative likelihood ratio: 近似累积似然比
20+
Distribution of sample mean: 样本均值的分布
21+
Choosing a sampling distribution: 选择抽样分布
1222
---
1323

1424
# 似然比过程的均值
@@ -34,6 +44,7 @@ import numpy as np
3444
from numba import jit, vectorize, prange
3545
import matplotlib.pyplot as plt
3646
FONTPATH = "fonts/SourceHanSerifSC-SemiBold.otf"
47+
import matplotlib as mpl
3748
mpl.font_manager.fontManager.addfont(FONTPATH)
3849
plt.rcParams['font.family'] = ['Source Han Serif SC']
3950
@@ -263,13 +274,12 @@ estimate(g_a, g_b, h_a, h_b, T=10, N=10000)
263274
下面的代码使用蒙特卡洛和重要性采样方法生成估计值的分布。
264275

265276
```{code-cell} ipython3
266-
@jit(parallel=True)
267277
def simulate(p_a, p_b, q_a, q_b, N_simu, T=1):
268278
269279
μ_L_p = np.empty(N_simu)
270280
μ_L_q = np.empty(N_simu)
271281
272-
for i in prange(N_simu):
282+
for i in range(N_simu):
273283
μ_L_p[i] = estimate(p_a, p_b, p_a, p_b, T=T)
274284
μ_L_q[i] = estimate(p_a, p_b, q_a, q_b, T=T)
275285
@@ -468,4 +478,3 @@ plt.show()
468478
注意,即使在$T = 1$时,使用重要性抽样的均值估计比直接用$g$进行抽样的偏差更大。
469479

470480
因此,我们的模拟表明,对于我们的问题,直接使用$g$进行蒙特卡洛近似会比使用$h_3$作为重要性抽样分布更好。
471-

0 commit comments

Comments
 (0)