Skip to content

Fix OffsetReal.calculateLogP() double-subtracting offset#73

Merged
rbouckaert merged 1 commit into
masterfrom
fix/offset-real-calculate-logp
May 6, 2026
Merged

Fix OffsetReal.calculateLogP() double-subtracting offset#73
rbouckaert merged 1 commit into
masterfrom
fix/offset-real-calculate-logp

Conversation

@alexeid
Copy link
Copy Markdown
Member

@alexeid alexeid commented May 5, 2026

Fixes #72.

Summary

  • OffsetReal.calculateLogP() evaluated the underlying distribution at param - 2 * offset instead of param - offset, because both the override and the logDensity(x) it called subtracted the offset.
  • One-line fix: pass param.get() directly to logDensity(), matching the convention used by density(x) and calcLogP(value) in the same class.
  • Added testCalculateLogPOfOffsetReal covering Exp and Normal cases (the existing MeanOfParametricDistributionTest only exercised getMean()).

No production callers of OffsetReal.calculateLogP() exist in beast3 today, so no MCMC results were affected. Downstream consumers (LPhyBeast) need this fixed before they can use OffsetReal as a prior.

Test plan

  • mvn test -Dtest=MeanOfParametricDistributionTest — all 7 tests pass on the new branch
  • mvn test -Dtest='*Distribution*Test,*Prior*Test' — all 36 tests in beast-base pass

calculateLogP() passed param.get() - offset.get() to logDensity(),
but logDensity(x) itself subtracts offset, so the underlying
distribution was evaluated at param - 2*offset.

Also adds testCalculateLogPOfOffsetReal covering Exp and Normal.
@alexeid alexeid requested a review from rbouckaert May 5, 2026 23:54
@rbouckaert rbouckaert merged commit 12e8226 into master May 6, 2026
1 check passed
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.

OffsetReal.calculateLogP() double-subtracts offset

2 participants