Skip to content

FEAT: log densities for the parametric mass models - #146

Merged
ColmTalbot merged 1 commit into
ln-spin-modelsfrom
ln-mass-models
Oct 23, 2026
Merged

ColmTalbot merged 1 commit into
ln-spin-modelsfrom
ln-mass-models

Conversation

@ColmTalbot

Copy link
Copy Markdown
Owner

Add ln_ versions of power_law_mass, power_law_primary_mass_ratio, power_law_primary_secondary_independent/identical, three_component_single, two_component_primary_secondary_independent/ identical, double_power_law_primary_mass,
double_power_law_peak_primary_mass and
double_power_law_primary_power_law_mass_ratio.

The power laws use ln_powerlaw and ln_powerlaw_from_logs, whose normalization does not overflow for steep slopes in single precision. The broken power law adds the log of the continuity correction to the lower part and subtracts log(1 + correction) with logaddexp; the mixtures use logaddexp. Functions of the dataset use dataset["ln_mass_1"], ["ln_mass_2"] and ["ln_mass_ratio"] when present, as ln_two_component_primary_mass_ratio does, and the power law in mass ratio it uses moves to _ln_mass_ratio_power_law to be shared.

In a float32 survey (10k samples x 10 draws per model), the points lost to underflow drop to none from 1.3% for
two_component_primary_secondary_independent/identical, 1.8% for three_component_single and 0.6% for double_power_law_peak_primary_mass.

Add ln_ versions of power_law_mass, power_law_primary_mass_ratio,
power_law_primary_secondary_independent/identical,
three_component_single, two_component_primary_secondary_independent/
identical, double_power_law_primary_mass,
double_power_law_peak_primary_mass and
double_power_law_primary_power_law_mass_ratio.

The power laws use ln_powerlaw and ln_powerlaw_from_logs, whose
normalization does not overflow for steep slopes in single precision.
The broken power law adds the log of the continuity correction to the
lower part and subtracts log(1 + correction) with logaddexp; the
mixtures use logaddexp. Functions of the dataset use
dataset["ln_mass_1"], ["ln_mass_2"] and ["ln_mass_ratio"] when present,
as ln_two_component_primary_mass_ratio does, and the power law in mass
ratio it uses moves to _ln_mass_ratio_power_law to be shared.

In a float32 survey (10k samples x 10 draws per model), the points lost
to underflow drop to none from 1.3% for
two_component_primary_secondary_independent/identical, 1.8% for
three_component_single and 0.6% for double_power_law_peak_primary_mass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ColmTalbot
ColmTalbot added this pull request to stack #147 October 23, 2026 17:55
@codecov

codecov Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.50%. Comparing base (2a87a52) to head (5dfefe4).

Additional details and impacted files
@@                Coverage Diff                 @@
##           ln-spin-models     #146      +/-   ##
==================================================
+ Coverage           95.21%   95.50%   +0.29%     
==================================================
  Files                  14       14              
  Lines                1107     1156      +49     
==================================================
+ Hits                 1054     1104      +50     
+ Misses                 53       52       -1     
Flag Coverage Δ
python3.10 95.50% <100.00%> (+0.29%) ⬆️
python3.11 95.50% <100.00%> (+0.29%) ⬆️
python3.12 95.50% <100.00%> (+0.29%) ⬆️
python3.13 95.50% <100.00%> (+0.29%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ColmTalbot
ColmTalbot merged commit d33317c into main Oct 23, 2026
16 checks passed
@ColmTalbot
ColmTalbot deleted the ln-mass-models branch October 23, 2026 18:17
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