Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better document the 'mr' parameter to 'metrop_select'. #7160

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bangerth
Copy link

@bangerth bangerth commented Feb 17, 2024

I found myself confused why metrop_select() has this comparison:

    if np.isfinite(mr) and np.log(uniform()) < mr:

If mr was just a ratio of probabilities, as one would typically see in theoretical descriptions, then it should be compared to uniform(), not the log. But mr is the logarithm of the ratio -- something not clear from the documentation, but that can be added :-)


馃摎 Documentation preview 馃摎: https://pymc--7160.org.readthedocs.build/en/7160/

Copy link

welcome bot commented Feb 17, 2024

Thank You Banner]
馃挅 Thanks for opening this pull request! 馃挅 The PyMC community really appreciates your time and effort to contribute to the project. Please make sure you have read our Contributing Guidelines and filled in our pull request template to the best of your ability.

@@ -181,7 +181,13 @@ def metrop_select(mr: np.ndarray, q: np.ndarray, q0: np.ndarray) -> tuple[np.nda

Parameters
----------
mr: float, Metropolis acceptance rate
mr: float, Metropolis acceptance rate. In theory, this acceptance rate is the
Copy link
Member

Choose a reason for hiding this comment

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

Can this be summarized a bit more. Isn't it enough to say it's the logarithm of the ratio of probabilities?

Copy link
Author

Choose a reason for hiding this comment

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

In places where it is called, the variable passed in here is typically called delta_logp. I wanted to explain the parameter in a way that explains the origin of the name.

Copy link
Member

Choose a reason for hiding this comment

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

I understand but it's too verbose in my opinion. Logarithm of probability ratio is pretty explicit. If you look in the database you'll quickly get used to seeing everything working on log scales

Copy link
Member

Choose a reason for hiding this comment

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

The parameter description should be (and should have been) on a different line, with only the parameter name and its type in the first line:

mr : float
    description
    which
    can be
    multiline

it looks like this class isn't on the website listed api docs so not fixing won't result in rendering errors unless/until it is added to the website.

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.

None yet

3 participants