[action-translation] resync: os_stochastic.md#169
Conversation
✅ Deploy Preview for astonishing-narwhal-a8fc64 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Translation Quality ReviewVerdict: PASS | Model: claude-sonnet-5 | Date: 2026-07-18 📝 Translation Quality
Summary: This is a high-quality, complete resync of the document. The translation accurately conveys complex dynamic programming and stochastic optimal savings concepts, maintains consistent terminology (e.g., 贝尔曼方程, 逐期最优策略, 价值函数), and preserves all MyST/Markdown formatting including math blocks, code cells, and directives. No syntax errors were found. The added translation metadata block is expected and correctly formatted. Overall this is a faithful and fluent translation suitable for academic technical content. Mathematical notation and LaTeX equations preserved accurately throughout Technical terms like '贝尔曼算子', '逐期最优的', '价值函数迭代' are translated consistently with proper domain conventions Code blocks, comments, and docstrings translated appropriately without breaking functionality Natural academic Chinese register maintained throughout complex theoretical passages Translation metadata correctly added per expected sync system format 🔍 Diff Quality
Summary: The target document was correctly resynced to match the new source content on 'Optimal Savings III: Stochastic Returns', replacing the old mismatched 'Optimal Growth I' content with proper structure and heading metadata. This review was generated automatically by action-translation review mode. |
There was a problem hiding this comment.
Pull request overview
This PR forward-resyncs lectures/os_stochastic.md to match the current upstream English source, shifting the lecture from an older “Optimal Growth I” version to “Optimal Savings III: Stochastic Returns” (state (x_t), savings (s_t), updated DP/VFI exposition and code). It also records sync metadata in the translation state file.
Changes:
- Replaces the full lecture content to align with the upstream “Optimal Savings III: Stochastic Returns” structure and notation.
- Updates embedded code to the upstream approach (NamedTuple
Model,Bfunction, VFI implementation, single exercise). - Adds
.translate/state/os_stochastic.md.ymlto track source SHA and resync metadata.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| lectures/os_stochastic.md | Whole-file resync of the lecture text + code cells to the latest upstream “Optimal Savings III: Stochastic Returns”. |
| .translate/state/os_stochastic.md.yml | Adds resync state metadata (source SHA, date, model, mode, etc.). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import matplotlib.pyplot as plt | ||
| import matplotlib as mpl | ||
| FONTPATH = "fonts/SourceHanSerifSC-SemiBold.otf" | ||
| mpl.font_manager.fontManager.addfont(FONTPATH) | ||
| plt.rcParams['font.family'] = ['Source Han Serif SC'] | ||
|
|
||
| plt.rcParams["figure.figsize"] = (11, 5) #设置默认图形大小 | ||
| import numpy as np | ||
| from scipy.interpolate import interp1d | ||
| from scipy.optimize import minimize_scalar | ||
| from typing import NamedTuple, Callable |
| def maximize(g, upper_bound): | ||
| """ | ||
| 在区间 [a, b] 上最大化函数 g。 | ||
| 在区间 [0, upper_bound] 上最大化函数 g。 | ||
|
|
||
| 我们利用了在任何区间上 g 的最大值点也是 -g 的最小值点这一事实。 | ||
| 元组 args 收集了传递给 g 的任何额外参数。 | ||
| 我们利用了在任何区间上 g 的最大值点也是 | ||
| -g 的最小值点这一事实。 | ||
|
|
||
| 返回最大值和最大值点。 | ||
| """ | ||
|
|
||
| objective = lambda x: -g(x, *args) | ||
| result = minimize_scalar(objective, bounds=(a, b), method='bounded') | ||
| objective = lambda x: -g(x) | ||
| bounds = (0, upper_bound) | ||
| result = minimize_scalar(objective, bounds=bounds, method='bounded') | ||
| maximizer, maximum = result.x, -result.fun |
| ```{code-cell} ipython3 | ||
| def T(v, og): | ||
| ```{code-cell} python3 | ||
| def T(v: np.ndarray, model: Model) -> tuple[np.ndarray, np.ndarray]: |
| v = model.u(model.x_grid) # 初始条件 | ||
| i = 0 | ||
| error = tol + 1 | ||
|
|
||
| while i < max_iter and error > tol: | ||
| v_new = T(v, model) | ||
| error = np.max(np.abs(v - v_new)) | ||
| i += 1 | ||
| if verbose and i % print_skip == 0: | ||
| print(f"第 {i} 次迭代的误差为 {error}。") | ||
| v = v_new | ||
|
|
||
| if error > tol: | ||
| print("未能收敛!") | ||
| elif verbose: | ||
| print(f"\n经过 {i} 次迭代后收敛。") | ||
|
|
||
| v_greedy = get_greedy(v_new, model) | ||
| return v_greedy, v_new |
| Exercises: 练习 | ||
| --- | ||
|
|
||
| (optgrowth)= |
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The resynced file keeps Chinese plot labels but reverted the import cell to the source's exact form, losing the Source Han Serif setup - Chinese in figures would render as missing glyphs. Residual #107 class found in the merge review; applied wave-wide. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Forward Resync: os_stochastic.md
Source: QuantEcon/lecture-python.myst — lectures/os_stochastic.md
Source commit:
5efda54This PR resyncs the translation to match the current source document.
Reason: The target is actually a translation of an entirely different (earlier) version of this lecture — 'Optimal Growth I: The Stochastic Optimal Growth Model' using state variable y_t, class-based OptimalGrowthModel, cd_analytical.py load directives, exercises og_ex1 and og_ex2 — whereas the source is 'Optimal Savings III: Stochastic Returns' using NamedTuple Model, state variable x_t, savings s_t, and only one exercise (og_ex1) with CRRA utility. The target contains substantial additional content not in source (algorithm steps list, extra citations, additional exercise og_ex2, different model class structure, extra explanatory paragraphs) while also missing content from the source (Bellman equation greedy policy theorem box, contraction mapping details specific to source's phrasing, updated 'Overview' text, updated code using Model NamedTuple and B function, os/os_numerical doc references). This is a completely different lecture version, so both major additions and content changes exist, with TARGET_HAS_ADDITIONS taking priority.
Changes
Whole-file resync applied. The entire document was resynced in a single pass.
Created by action-translation forward resync