Skip to content

Reduce repetition of the beta posterior derivation#912

Merged
jstac merged 13 commits into
mainfrom
dedup-beta-posterior
Jun 18, 2026
Merged

Reduce repetition of the beta posterior derivation#912
jstac merged 13 commits into
mainfrom
dedup-beta-posterior

Conversation

@jstac

@jstac jstac commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

What

  • prob_meaning.md: state the closed-form beta posterior $\theta \mid k \sim \mathrm{Beta}(\alpha+k,\ \beta+n-k)$ in the main text (before the exercise), labeled eq:beta_posterior. The exercise pm_ex2 now 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 in prob_meaning (noting the $N$-vs-$n$ sample-size notation).

Why

The closed-form beta posterior was previously only stated inside prob_meaning's exercise solution and then re-derived from scratch in bayes_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

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>
@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown

📖 Netlify Preview Ready!

Preview URL: https://pr-912--sunny-cactus-210e3e.netlify.app

Commit: d07d7f2

📚 Changed Lectures


Build Info

jstac and others added 11 commits June 18, 2026 12:20
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>
@jstac jstac merged commit 5c41d25 into main Jun 18, 2026
1 check passed
@jstac jstac deleted the dedup-beta-posterior branch June 18, 2026 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant