QuantEcon · GitHub

Commit 5c41d25

jstacclaude

and

authored

Reduce repetition of the beta posterior derivation (#912)

* State beta posterior in prob_meaning and reference it from bayes_nonconj Move the closed-form beta posterior into the main text of prob_meaning (before the exercise, which now asks the reader to recover it), and replace the duplicated derivation in bayes_nonconj's "Analytical posterior" section with a back-reference. Reduces repetition across the two lectures. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Replace Bayesian class with functions in prob_meaning The class only bundled a few parameters with three short methods; its state (draws, posterior_list, prior) reads more clearly as plain values produced by small functions. Refactor into simulate_flips and form_posterior, update the call sites and the exercise prompt. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Replace Frequentist class with functions in prob_meaning Like the Bayesian class, this only bundled parameters with methods that stashed results on self. Refactor into simulate_head_counts and compare_frequencies, and update the comparison loops and exercise prompt to call them directly. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Use binomial coefficient notation in the binomial pmf Replace the n!/(k!(n-k)!) form with the standard \binom{n}{k} in the binomial pmf definition (and its restatements) across prob_meaning and bayes_nonconj. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Link to the two videos instead of embedding them Replace the {youtube} embeds with a bullet list of links in prob_meaning. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Link to Wikipedia where the binomial distribution is first defined Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Use leading zero in decimals (0.x not .x) in prob_meaning Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Tidy exercises: drop 'please', fix stale class refs, indicator notation - Drop "please" from each exercise prompt in pm_ex1 and pm_ex2. - Update the remaining "Python class" references (part h prompt and solution) to match the function-based refactor. - Define f_k^I with an indicator-function sum instead of words. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Use proper subsections instead of bold pseudo-headings Convert the "Comparison with different theta/n/I" headings and "Code for answering questions" from bold paragraphs to ### subsections. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Replace rng-or-default boilerplate with a seed parameter Give simulate_flips, simulate_head_counts, and compare_frequencies a seed=1234 default and build the generator with default_rng(seed), dropping the `rng = rng or np.random.default_rng()` guard. Call sites pass seed (seed=i in the comparison loops) instead of constructing and threading an rng object. Also fixes a stray undefined-rng line left in simulate_head_counts. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Split pm_ex2 into a derivation exercise and a coding exercise The lead-in promised a derivation that the exercise never asked for. Now pm_ex2 keeps parts (a) and (b) and adds a new (c) asking the reader to derive the closed-form Beta(alpha+k, beta+n-k) posterior; the solution's existing n-flip generalization becomes solution part (c). The coding problems move to a new exercise pm_ex3 (parts a-f) with its own solution. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Align Overview with delivered content; add synthesis and subsections (a) Reword the Overview to frame the lecture around the two meanings of probability (dropping the unfulfilled frequentist-confidence-interval promise), and add a "Comparing the two interpretations" synthesis section that contrasts the two answers before the conjugate-prior discussion. (c) Add ### subsections to the Bayesian half for parity with the Frequentist half, and add a caveat explaining the shape of the "different n" comparison (zero for n<10, peak near n=14). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

1 file changed

Lines changed: 149 additions & 156 deletions

Read the original on github.com ↗