Skip to content

Laplace: Add mean argument to helper distributions #3210

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from

Conversation

WardBrian
Copy link
Member

Summary

Closes #3202. Note that this is branched off of #3209, since doing the two changes independently would lead to a great many merge conflicts.

Tests

Existing tests updated to pass 0 as the mean. It would be nice to add some tests
with a non-zero mean, if there are suggestions (@avehtari @charlesm93)

Side Effects

Release notes

Checklist

  • Copyright holder: (fill in copyright holder information)

    The copyright holder is typically you or your assignee, such as a university or company. By submitting this pull request, the copyright holder is agreeing to the license the submitted work under the following licenses:
    - Code: BSD 3-clause (https://opensource.org/licenses/BSD-3-Clause)
    - Documentation: CC-BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

  • the basic tests are passing

    • unit tests pass (to run, use: ./runTests.py test/unit)
    • header checks pass, (make test-headers)
    • dependencies checks pass, (make test-math-dependencies)
    • docs build, (make doxygen)
    • code passes the built in C++ standards checks (make cpplint)
  • the code is written in idiomatic C++ and changes are documented in the doxygen

  • the new changes are tested

@WardBrian WardBrian requested a review from SteveBronder June 17, 2025 15:16
@avehtari
Copy link
Member

This example https://discourse.mc-stan.org/t/embedded-laplace-numerical-problem/39700 uses non-zero mean (mu) and Poisson. So with the helper it should look something like (not certain what is the argument order now)

laplace_marginal_poisson_log_lpmf(y | mu, [1], cov_fun, (sigmaz, N), theta_0)

@WardBrian
Copy link
Member Author

Thanks @avehtari.

Writing that test made me realize something else: The y_index argument to laplace_marginal_poisson_log_lpmf is currently 0-indexed rather than 1-indexed. Is that intentional @charlesm93 @SteveBronder?


const int N = 1;
const std::vector<int> y{153};
const std::vector<int> y_index{0};
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My instinct (and @avehtari's above) was to make this {1}, but that led to an index-out-of-bounds, because this variable is used as a 0-based index. This comment is to remind me that I want to verify this is intentional

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.

Include prior mean argument to built-in Laplace marginal likelihood functions
3 participants