Reduce repetition of the beta posterior derivation#912
Merged
Conversation
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>
📖 Netlify Preview Ready!Preview URL: https://pr-912--sunny-cactus-210e3e.netlify.app Commit: 📚 Changed LecturesBuild Info
|
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>
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>
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>
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>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- 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>
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>
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>
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>
(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>
# Conflicts: # lectures/bayes_nonconj.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
prob_meaning.md: state the closed-form beta posterioreq:beta_posterior. The exercisepm_ex2now asks the reader to recover this result rather than being the only place it appears.bayes_nonconj.md: replace the duplicated three-step integral derivation in the "Analytical posterior" section with a back-reference to the result derived inprob_meaning(noting theWhy
The closed-form beta posterior was previously only stated inside
prob_meaning's exercise solution and then re-derived from scratch inbayes_nonconj. Stating it once as a first-class result and referencing it removes the repetition.Prose/math only — no code cells were modified.
🤖 Generated with Claude Code