From deb93a26eb2557d667973ea48a114270e3fffdb8 Mon Sep 17 00:00:00 2001 From: Matt McKay Date: Sat, 18 Jul 2026 17:39:47 +1000 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=94=84=20resync=20imp=5Fsample.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .translate/state/imp_sample.md.yml | 6 ++++++ lectures/imp_sample.md | 16 ++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 .translate/state/imp_sample.md.yml diff --git a/.translate/state/imp_sample.md.yml b/.translate/state/imp_sample.md.yml new file mode 100644 index 00000000..a02d4d88 --- /dev/null +++ b/.translate/state/imp_sample.md.yml @@ -0,0 +1,6 @@ +source-sha: b8ed85c7e8b8c17f5f59c74b3cb829470363ca8b +synced-at: "2026-07-18" +model: claude-sonnet-5 +mode: RESYNC +section-count: 7 +tool-version: 0.17.0 diff --git a/lectures/imp_sample.md b/lectures/imp_sample.md index 70b79a85..26735024 100644 --- a/lectures/imp_sample.md +++ b/lectures/imp_sample.md @@ -9,6 +9,16 @@ kernelspec: display_name: Python 3 language: python name: python3 +translation: + title: 似然比过程的均值 + headings: + Overview: 概述 + Mathematical expectation of likelihood ratio: 似然比的数学期望 + Importance sampling: 重要性采样 + Selecting a sampling distribution: 选择抽样分布 + Approximating a cumulative likelihood ratio: 近似累积似然比 + Distribution of sample mean: 样本均值的分布 + Choosing a sampling distribution: 选择抽样分布 --- # 似然比过程的均值 @@ -263,13 +273,12 @@ estimate(g_a, g_b, h_a, h_b, T=10, N=10000) 下面的代码使用蒙特卡洛和重要性采样方法生成估计值的分布。 ```{code-cell} ipython3 -@jit(parallel=True) def simulate(p_a, p_b, q_a, q_b, N_simu, T=1): μ_L_p = np.empty(N_simu) μ_L_q = np.empty(N_simu) - for i in prange(N_simu): + for i in range(N_simu): μ_L_p[i] = estimate(p_a, p_b, p_a, p_b, T=T) μ_L_q[i] = estimate(p_a, p_b, q_a, q_b, T=T) @@ -467,5 +476,4 @@ plt.show() 注意,即使在$T = 1$时,使用重要性抽样的均值估计比直接用$g$进行抽样的偏差更大。 -因此,我们的模拟表明,对于我们的问题,直接使用$g$进行蒙特卡洛近似会比使用$h_3$作为重要性抽样分布更好。 - +因此,我们的模拟表明,对于我们的问题,直接使用$g$进行蒙特卡洛近似会比使用$h_3$作为重要性抽样分布更好。 \ No newline at end of file From 1d3e640005db08962aaf13c4ac47132328cfd97a Mon Sep 17 00:00:00 2001 From: Matt McKay Date: Sat, 18 Jul 2026 20:30:56 +1000 Subject: [PATCH 2/3] 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 --- lectures/imp_sample.md | 1 + 1 file changed, 1 insertion(+) diff --git a/lectures/imp_sample.md b/lectures/imp_sample.md index 26735024..1e0fbef3 100644 --- a/lectures/imp_sample.md +++ b/lectures/imp_sample.md @@ -44,6 +44,7 @@ import numpy as np from numba import jit, vectorize, prange import matplotlib.pyplot as plt FONTPATH = "fonts/SourceHanSerifSC-SemiBold.otf" +import matplotlib as mpl mpl.font_manager.fontManager.addfont(FONTPATH) plt.rcParams['font.family'] = ['Source Han Serif SC'] From 0ebf1206bd90cdbb6e3b47dc62b387362c248bd1 Mon Sep 17 00:00:00 2001 From: Matt McKay Date: Sun, 19 Jul 2026 14:04:13 +1000 Subject: [PATCH 3/3] Restore trailing newline (engine issue tracked in QuantEcon/action-translation#116) Co-Authored-By: Claude Fable 5 --- lectures/imp_sample.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lectures/imp_sample.md b/lectures/imp_sample.md index 1e0fbef3..9d062359 100644 --- a/lectures/imp_sample.md +++ b/lectures/imp_sample.md @@ -477,4 +477,4 @@ plt.show() 注意,即使在$T = 1$时,使用重要性抽样的均值估计比直接用$g$进行抽样的偏差更大。 -因此,我们的模拟表明,对于我们的问题,直接使用$g$进行蒙特卡洛近似会比使用$h_3$作为重要性抽样分布更好。 \ No newline at end of file +因此,我们的模拟表明,对于我们的问题,直接使用$g$进行蒙特卡洛近似会比使用$h_3$作为重要性抽样分布更好。