Skip to content

[action-translation] resync: os_stochastic.md#169

Merged
mmcky merged 3 commits into
mainfrom
resync/os_stochastic
Jul 18, 2026
Merged

[action-translation] resync: os_stochastic.md#169
mmcky merged 3 commits into
mainfrom
resync/os_stochastic

Conversation

@mmcky

@mmcky mmcky commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Forward Resync: os_stochastic.md

Source: QuantEcon/lecture-python.mystlectures/os_stochastic.md
Source commit: 5efda54
This 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

Copilot AI review requested due to automatic review settings July 18, 2026 10:44
@mmcky mmcky added action-translation-sync CLI resync PR (translate forward --github) resync Forward resync labels Jul 18, 2026
@netlify

netlify Bot commented Jul 18, 2026

Copy link
Copy Markdown

Deploy Preview for astonishing-narwhal-a8fc64 ready!

Name Link
🔨 Latest commit f0f02fc
🔍 Latest deploy log https://app.netlify.com/projects/astonishing-narwhal-a8fc64/deploys/6a5b61a0af97e30008736751
😎 Deploy Preview https://deploy-preview-169--astonishing-narwhal-a8fc64.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@mmcky mmcky added the action-translation PRs created by QuantEcon/action-translation label Jul 18, 2026
@github-actions

github-actions Bot commented Jul 18, 2026

Copy link
Copy Markdown

✅ Translation Quality Review

Verdict: PASS | Model: claude-sonnet-5 | Date: 2026-07-18


📝 Translation Quality

Criterion Score
Accuracy 9/10
Fluency 9/10
Terminology 9/10
Formatting 9/10
Overall 9/10

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

Check Status
Scope Correct
Position Correct
Structure Preserved
Heading-map Correct
Overall 10/10

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, B function, VFI implementation, single exercise).
  • Adds .translate/state/os_stochastic.md.yml to 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.

Comment thread lectures/os_stochastic.md
Comment on lines 86 to +90
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
Comment thread lectures/os_stochastic.md
Comment on lines +463 to 475
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
Comment thread lectures/os_stochastic.md
```{code-cell} ipython3
def T(v, og):
```{code-cell} python3
def T(v: np.ndarray, model: Model) -> tuple[np.ndarray, np.ndarray]:
Comment thread lectures/os_stochastic.md
Comment on lines +744 to +762
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
Comment thread lectures/os_stochastic.md
Exercises: 练习
---

(optgrowth)=
@github-actions

github-actions Bot commented Jul 18, 2026

Copy link
Copy Markdown

@github-actions
github-actions Bot temporarily deployed to pull request July 18, 2026 10:56 Inactive
mmcky and others added 2 commits July 18, 2026 21:16
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>
@github-actions
github-actions Bot temporarily deployed to pull request July 18, 2026 11:33 Inactive
@mmcky
mmcky merged commit 7d35abb into main Jul 18, 2026
7 checks passed
@mmcky
mmcky deleted the resync/os_stochastic branch July 18, 2026 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action-translation PRs created by QuantEcon/action-translation action-translation-sync CLI resync PR (translate forward --github) resync Forward resync

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants