Repository navigation
Use distmarg for distance marginalization - #1163
Open
ColmTalbot wants to merge 4 commits into
Open
ColmTalbot wants to merge 4 commits into
ColmTalbot wants to merge 4 commits into
Conversation
Replace the 400x800 interpolated lookup table with distmarg, which evaluates the distance-marginalized likelihood directly from the matched-filter and optimal SNRs at the reference distance. It is accurate to ~1e-4 in ln L everywhere, needs no precomputation, and follows the array backend of its inputs. Distance reconstruction samples the exact conditional posterior. The lookup-table argument is still accepted for backwards compatibility, and a small record of the tabulated prior is still written to cached_lookup_table_filename, which bilby_pipe reads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Deprecate distance_marginalization_lookup_table (and the cache file it controls) for removal in bilby v3.1.0, with a DeprecationWarning. - Remove BoundedRectBivariateSpline and its test; the distance lookup table was its only user. - Reconstruct distance for a zero template by sampling the distance prior. - Drop accuracy details from the docstring and the clip of <h|h>. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CI builds its environments from pixi.toml, which lists the gw dependencies itself, so distmarg[rust] has to be added there as well as to gw_requirements.txt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
prior.rescale returns a numpy scalar; mixed with torch or JAX inputs it made distmarg see two array namespaces in distance_marginalized_likelihood. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
|
I'm a fan of this approach. Is it possible to add a second maintainer (no need for code credit) to the repo in case you choose to leave us and do something else, and we need to bug-fix distmarg? |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This replaces the interpolated lookup table used for distance marginalization in
GravitationalWaveTransientwithdistmarg.distmargevaluates the distance-marginalized likelihood directly from the matched-filter and optimal SNRs at the reference distance. The ROQ, relative-binning and multiband likelihoods use the samedistance_marginalized_likelihood, so they pick up the change without modification.What changes
distance_marginalized_likelihoodcallsdistmarginstead of the 400×800 lookup table and its spline.SCIPY_ARRAY_API=1.UniformSourceFrameandUniformComovingVolume, rather than from the interpolatedprob. Nothing else is precomputed; previously, building the table took ~40 s per phase setting.distance_marginalization_lookup_tableis deprecated, with aDeprecationWarning, for removal in v3.1.0. A small record of the tabulated prior is still written tocached_lookup_table_filename, becausebilby_pipereads that file during data generation.BoundedRectBivariateSplineand its test are removed. The lookup table was its only user.distmarg[rust]is added togw_requirements.txt. Therustextra installs the compiled backend: a single-point evaluation then takes ~2 µs, against ~7 µs for the table.Accuracy
distmargis accurate to ≲1e-4 in ln L across the full stress grid:d*fromd_min/5to5 d_max;rho_mffrom 1e-3 to 1e4, including negative values;This is checked against a dense reference quadrature and an independent mpmath oracle.
In a version of the fast-tutorial example:
Testing
🤖 Generated with assistance from Claude Code