QuantEcon / QuantEcon/lecture-python.myst
prob_meaning.md: assorted corrections
Open
Nobody has claimed this yet.
- Dominant language
- TeX
- Stars
- 123
- Forks
- 57
- Avg merge
- 3d 10h
- Merged PRs (30d)
- 11
Description
A collection of small issues found in lectures/prob_meaning.md.
- Exercise pm_ex2 part (a): The question asks for the likelihood function for a sample of length $n$, but the solution provides the likelihood for a single flip ($n=1$). Either the question or the solution should be revised so they match.
- Exercise pm_ex2 solution, before part (c): The sentence "Now pretend that the true value of $\theta = .4$..." appears twice — once as a standalone line before part (c) and again as the opening of part (c) itself. The first occurrence should be removed.
- Bayesian section, missing setup before exercise pm_ex2: Bayes' Law, likelihood functions, and posterior distributions are not mentioned in the lecture text before the exercise — they only appear inside the solution. These concepts are already introduced in Probability with Matrices (
prob_matrix), so a back-reference (e.g., "Recall the posterior distribution derived using Bayes' Law in {doc}Probability with Matrices <prob_matrix>") before the exercise would bridge the gap without duplicating material. - $n$-step posterior formula is used before it's derived: The solution code in part (c) uses $\text{Beta}(\alpha + k, \beta + n - k)$ via
form_single_posterior, and all subsequent plots and coverage interval calculations depend on it. But the formal derivation doesn't appear until much later, in the "It is natural to extend the one-step Bayesian update..." section after the exercise. Moving the derivation earlier means that later section also needs to be revised or removed to avoid duplication. - Line length throughout code cells: Comments, docstrings, and code lines frequently exceed 80 characters, making them hard to read on the website. Sentences in comments should also start with a capital letter. Affected areas include the
Bayesianclass docstrings and various plotting cells (e.g., lines 506, 509, 551, 555, 682). - Variable naming: Several names are unclear or misleading:
iiis used both as a loop index and as a posterior distribution in list comprehensions (e.g.,ii.cdf(...),ii.mean()). Useifor indices andpostorposteriorfor distributions.num/num_list→n_obs/n_obs_list(it's the number of observations, not a generic number)step_num→n_obs(it's not a "step")kk→k(no reason for the doubled name)npt,nn,nI→ more descriptive names liken_thetas,n_ns,n_IsK→head_counts(capitalKlooks like a constant)comp→table
- PEP 8 naming conventions:
Bay_statshould bebay_statorbayes— instance names should besnake_case, notPascalCase.frequentistclass should beFrequentist— class names should bePascalCase. (TheBayesianclass already follows this convention.)
- Plot label formatting: Line 590 uses
'n=%d thousand' % (num/1000), which produces awkward labels like "n=5 thousand". Use f-string formatting with comma separators instead, e.g.,f'Posterior with n={n_obs:,}'→ "n=5,000". - Typos and spelling:
- "probabilties" → "probabilities" (line 76)
- "to to help" → "to help" (line 36, doubled word)
- "probabililty" → "probability" (lines 381, 546, 555, 564, 568, 572 — same misspelling repeated 6 times)
- "statististian" → "statistician" (line 690)
- Notation inconsistency: Line 331 refers to "the average of $P_{k,i}$" but the variable was defined as $\rho_{k,i}$ on line 325.
- Subject-verb agreement (line 602): "posterior means converges" → "posterior mean converges"; "posterior standard deviations converges" → "posterior standard deviation converges".
- LaTeX equations use
*for multiplication (lines 638, 642, 646): Should use\cdotor juxtaposition instead. - Spiky posterior density plots:
θ_values = np.linspace(0.01, 1, 100)only provides 100 grid points. The part (h) plot is zoomed to [0.3, 0.5], leaving ~20 points to render highly concentrated posteriors. Increase the grid resolution (e.g., 1000 points). - Cross-references say "this quantecon lecture" (lines 719–722): These render poorly in PDF where there's no hyperlink context. Replace with actual lecture titles: Non-Conjugate Priors, Posterior Distributions for AR(1) Parameters, and Forecasting an AR(1) Process.
- Variance formula is wrong (lines 327–329): The variance of $\rho_{k,i}$ is given as $n \cdot \text{Prob}(X=k|\theta) \cdot (1 - \text{Prob}(X=k|\theta))$, but $\rho_{k,i}$ is a Bernoulli indicator, so its variance is $\text{Prob}(X=k|\theta) \cdot (1 - \text{Prob}(X=k|\theta))$ — no factor of $n$.
- Upper and lower bounds swapped in part (e) (lines 521–522):
ppf(0.05)(the 5th percentile) is assigned toupper_boundandppf(0.95)(the 95th percentile) tolower_bound. Lines 672–673 do it correctly. -
compare()skips $k=0$ (line 192):range(n)withi+1starts at $k=1$, but $k=0$ is a valid binomial outcome. - Exercise pm_ex1 part 3 is vague: "With the Law of Large numbers in mind, use your code to say something" — say something about what?
- Text says $\log(I)$ varies from 2 to 7 (line 286) but code has
I_log_high = 6(line 289). - Line 321 is imprecise: Says the observed fraction approximates $\theta$, but $f_k^I$ approximates $\text{Prob}(X=k|\theta)$, not $\theta$ itself.
- Inconsistent bool-to-int conversion: The
frequentistclass uses* 1(line 171) whileBayesianuses.astype(int)(line 455). Should be consistent —.astype(int)is clearer.
All items addressed in #878.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with lectures/prob_meaning.md and review the checklist against issue #878, which the issue says addresses all items. Inspect the affected exercises, code cells, formulas, naming, cross-references, and plots; done means the documented corrections are present and the lecture remains consistent and readable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 20/100