Skip to content

Add LogUniform distribution to beast.base.spec#69

Open
alexeid wants to merge 1 commit intomasterfrom
add-loguniform
Open

Add LogUniform distribution to beast.base.spec#69
alexeid wants to merge 1 commit intomasterfrom
add-loguniform

Conversation

@alexeid
Copy link
Copy Markdown
Member

@alexeid alexeid commented Apr 24, 2026

Summary

Adds LogUniform as a proper, scale-invariant ScalarDistribution for strictly positive quantities — the defensible replacement for the improper OneOnX prior, which was deliberately not migrated to the spec types (see existing note in version.xml:226).

  • Density p(x) = 1 / (x * log(upper/lower)) on [lower, upper], equivalent to Uniform on log(x).
  • Apache Commons Statistics has no reciprocal distribution, so ContinuousDistribution is implemented inline with closed-form density, CDF, inverse CDF, mean, variance, and inverse-CDF sampler.
  • Parameters lower, upper are RealScalar<PositiveReal>; the distribution validates 0 < lower < upper < infinity in refresh().
  • Registered as a BEASTInterface service provider in both module-info.java and version.xml.

Motivation

FLC's beast3 migration (4ment/flc#10) uses OneOnX on the coalescent popSize; that block is currently commented out because OneOnX has no spec-type counterpart. LogUniform on e.g. [1e-6, 1e6] gives twelve orders of magnitude of scale-invariant prior support — behaviourally equivalent for typical molecular-clock analyses, philosophically cleaner (proper, integrable, has a CDF and quantile), and usable anywhere ScalarDistribution is expected.

Test plan

  • LogUniformTest (8 tests): closed-form density, zero outside support, CDF/quantile round-trip (1000 random pairs), log-space median equals sqrt(ab), mean formula, calculateLogP via param, XML parse, rejection of degenerate bounds
  • Full beast-base suite: 399 tests, 0 failures, 0 errors
  • Verify downstream: use LogUniform for popSize prior in FLC example XML

Proper, scale-invariant ScalarDistribution on [lower, upper] with
lower > 0. Density 1/(x log(upper/lower)); equivalent to Uniform on
log(x). Intended as the defensible replacement for the improper
OneOnX prior on strictly positive quantities (popSize, rates,
variances), which was deliberately not migrated to the spec types
(see existing comment in version.xml).

Apache Commons Statistics has no reciprocal distribution, so
ContinuousDistribution is implemented inline with closed-form
density, CDF, inverse CDF, mean, variance, and inverse-CDF sampler.
Registered in module-info.java and version.xml as a BEASTInterface
service provider. 8 tests covering closed-form density, support,
CDF/quantile round-trip, log-space median, mean, XML parse, and
rejection of degenerate bounds.
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