Skip to content

[action-translation] resync: bayes_nonconj.md#163

Merged
mmcky merged 3 commits into
mainfrom
resync/bayes_nonconj
Jul 19, 2026
Merged

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

Conversation

@mmcky

@mmcky mmcky commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Forward Resync: bayes_nonconj.md

Source: QuantEcon/lecture-python.mystlectures/bayes_nonconj.md
Source commit: b78fbcd
This PR resyncs the translation to match the current source document.

Reason: The two documents are almost entirely different. SOURCE describes a modern NumPyro-only lecture using NUTS and AutoNormal SVI with specific priors (uniform, truncated log-normal, truncated Laplace) and a streamlined workflow. TARGET is an older/different version using both Pyro and NumPyro, with additional priors (von Mises), rejection-sampling based truncated distributions, a full BayesianInference Python class implementation, beta-guide and truncated-normal guide SVI implementations, and different code/explanations not present in SOURCE at all. Conversely, SOURCE's specific content (data generation function, run_nuts helper, r_hat/ESS diagnostics discussion, trace plots, ELBO derivation details, comparison plots, 'Where to next' section) is missing from TARGET. Since TARGET contains substantial unique content (class implementation, pymc4/pyro dual support, von Mises prior, rejection sampling) not found in SOURCE, this is TARGET_HAS_ADDITIONS.

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:01
@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 db492a6
🔍 Latest deploy log https://app.netlify.com/projects/astonishing-narwhal-a8fc64/deploys/6a5c1b322447c2000833f320
😎 Deploy Preview https://deploy-preview-163--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

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 the Chinese translation of lectures/bayes_nonconj.md to match the current upstream lecture version, updating the narrative and examples to a modern NumPyro-only workflow (NUTS + AutoNormal SVI) and adding translation heading metadata.

Changes:

  • Replaced the previous mixed Pyro/NumPyro + custom-class content with an updated NumPyro-only lecture structure (MCMC diagnostics, non-conjugate priors, SVI comparison).
  • Added translation frontmatter (translation: ... headings:) to map upstream headings to Chinese.
  • Added new translation sync state file at .translate/state/bayes_nonconj.md.yml.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
lectures/bayes_nonconj.md Full resync of the lecture content, examples, and translation frontmatter headings.
.translate/state/bayes_nonconj.md.yml Records source SHA and resync metadata for the translation pipeline.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lectures/bayes_nonconj.md
Comment on lines +34 to +35
```{include} _admonition/gpu.md
```
Comment thread lectures/bayes_nonconj.md
Comment on lines 85 to 88
import numpy as np
import seaborn as sns
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']

from scipy.stats import binom
import scipy.stats as st
import torch

Comment thread lectures/bayes_nonconj.md
chain_method="vectorized",
progress_bar=False,
)
mcmc.run(random.key(seed), *args)
Comment thread lectures/bayes_nonconj.md
return mcmc
```

NumPyro建立在[JAX](https://docs.jax.dev)之上,而JAX显式地处理随机性:它不依赖全局随机状态,而是要求每次运行都拥有自己的**PRNG密钥**,这里通过`random.key(seed)`创建。
Comment thread lectures/bayes_nonconj.md
- ('vonMises', kappa),其中kappa表示集中参数,中心位置设为$0.5$。
- 注意:在使用`Pyro`时,这是原始vonMises分布的截断版本;
- 注意:在使用`Numpyro`时,这是**平移后**的分布。
svi_result = svi.run(random.key(0), 5000, prior_ln, k, n, progress_bar=False)
Comment thread lectures/bayes_nonconj.md

return params, losses
vi_samples = guide.sample_posterior(
random.key(1), svi_result.params, sample_shape=(4000,)
@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:11 Inactive
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 commented Jul 18, 2026

Copy link
Copy Markdown

✅ Translation Quality Review

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


📝 Translation Quality

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

Summary: This is a high-quality, accurate, and fluent translation that faithfully captures the technical content, mathematical derivations, and nuanced explanations of the English source. Terminology is consistent with standard Bayesian/statistical Chinese usage. Minor concerns include an added font-configuration code block not present in the source and a jupytext_version discrepancy, both of which are likely pipeline-related rather than translation quality issues. Consistent and accurate rendering of technical statistical/Bayesian terminology (e.g., 后验, 先验, 共轭对, 证据下界/ELBO, 有效样本量) matching standard usage Mathematical notation and LaTeX equations are fully preserved without corruption Code blocks are intact with accurately translated comments and docstrings Complex explanatory passages (e.g., on KL divergence derivation, NUTS mechanics) are translated with clarity and correct logical flow Heading structure and MyST directives (admonitions, code-cells, doc refs) are correctly preserved

Suggestions:

  • Imports section: The translation adds font-loading code (mpl.font_manager, FONTPATH, plt.rcParams) that is not present in the English source's code cell — this is an addition beyond the source content and should be verified against project convention, though it may be a standard practice for rendering Chinese characters in plots.
  • jupytext_version metadata: The translation shows '1.16.4' while the English source shows '1.17.2' — this version mismatch should be reconciled to match the source or confirmed as an intentional pipeline artifact.
  • '均匀先验' subsection 'A uniform prior': the phrase '正如似然函数所显示的那样' for 'just as the likelihood is' is slightly loose but conveys the meaning adequately; a more literal rendering like '正如似然函数本身一样' could be marginally clearer, though not critical.

🔍 Diff Quality

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

Summary: The target document has been fully resynced to match the current English source's structure, section order, and content, with a correctly populated translation heading map.

Issues:

  • Minor stylistic additions retained in target (custom font import/config in the imports code cell) that are not present in the English source; these are pre-existing localization additions rather than resync errors, but worth flagging as a deviation from strict source parity.
  • Code-cell comment translations (e.g., 'mask the density...') are translated, which is appropriate, but should be double-checked that code logic itself remains unchanged (it does).

This review was generated automatically by action-translation review mode.

@github-actions
github-actions Bot temporarily deployed to pull request July 18, 2026 11:33 Inactive
@github-actions
github-actions Bot temporarily deployed to pull request July 19, 2026 00:55 Inactive
@mmcky
mmcky merged commit 370a894 into main Jul 19, 2026
7 checks passed
@mmcky
mmcky deleted the resync/bayes_nonconj branch July 19, 2026 00:56
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