Skip to content

Fix code and math defects in SUG cross-validation and mixture sections - #983

Open
avehtari wants to merge 1 commit into
masterfrom
fix-sug-cv-defects
Open

avehtari wants to merge 1 commit into
masterfrom
fix-sug-cv-defects

Conversation

@avehtari

Copy link
Copy Markdown
Member

Submission Checklist

  • Builds locally (quarto render of cross-validation.qmd and finite-mixtures.qmd to HTML, Quarto 1.8.26)
  • New functions marked with <<{ since VERSION }>> (no new functions)
  • Declare copyright holder and open-source license: see below

Summary

I found these defects (with help from Claude) while I worked on #962 and #963 (I still need to think more about those). This PR fixes only clear errors; it does not rename variables or add content.

src/stan-users-guide/cross-validation.qmd:

  • The generated quantities block of the random-folds example did not compile. I fixed the code and the related equations.
  • permutation_rng exchanged each element with an element drawn uniformly from all $N$ positions. This does not give a uniform permutation for $N \ge 3$: there are $N^N$ equally likely paths, and $N!$ does not divide $N^N$. A simulation with $N = 3$ gives probabilities of 4/27 and 5/27 instead of 1/6. The function now does a Fisher-Yates shuffle with discrete_range_rng(n, N). I removed the footnote that said Stan has no uniform discrete RNG.
  • In the Rao-Blackwellization derivation, I fixed an equation. The text now gives the correct reason that the expectation equals the linear predictor and the expectation of a normal distribution is its location.
  • The loo package citation rendered as "Visualization in Bayesian workflow". See the all.bib item.

src/stan-users-guide/finite-mixtures.qmd:

  • A comma was missing between the two arguments of log_mix, so the code did not compile.
  • The text said to subtract log(N_new) after log_sum_exp. The correct value is log(M), the number of draws, for each test point.

src/bibtex/all.bib:

  • The key GabryEtAl:2019 was defined two times: for the loo package and for "Visualization in Bayesian workflow". The loo package entry now has the key VehtariEtAl:2026. The two GabryEtAl:2019 citations in posterior-predictive-checks.qmd refer to the visualization paper.

Copyright and Licensing

Please list the copyright holder for the work you are submitting (this will be you or your assignee, such as a university or company):

Aalto University

By submitting this pull request, the copyright holder is agreeing to license the submitted work under the following licenses:

This branch has not been deployed

No deployments
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