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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template morphing #318

Merged
merged 3 commits into from
Mar 22, 2024
Merged

Template morphing #318

merged 3 commits into from
Mar 22, 2024

Conversation

JelleAalbers
Copy link
Member

@JelleAalbers JelleAalbers commented Aug 1, 2023

This extends flamedisx's support for "old-fashioned" template sources, by adding support for linear / vertical template morphing. The new MultiTemplateSource takes multiple (param dict, histogram) combinations. For example:

source = fd.MultiTemplateSource(
    (dict(elife=800, drift_field=120), histogram_1),
    (dict(elife=920, drift_field=150), histogram_2),
    ...)

would produce a source that has elife and drift_field as free parameters, which control a linear interpolation between the differential rate histograms corresponding to those parameters.

Using a rectilinear grid of parameter points is recommended. Something like a cross of points should also work, but internally we interpolate onto a grid anyway on initialization (because tensorflow(_probability) only has rectilinear interpolation)

MultiTemplateSource can interpolate mu (expected events) in the same way as the differential rates. Unfortunately, since flamedisx sources usually can't estimate their own mu's, likelihoods still use the mu estimation API (#222). This means you would have to manually specify to use SimulateEachCallMu (or GridInterpolatedMu (#242) with the same grid as the template morphing source) to get consistent results.

There is a unit test that shows the interpolation appears to be working, but I'd like to test the behavior on likelihoods before we merge.

This PR adds on top of #317, which is much smaller and probably easier to review first. Then I can rebase this.

@JelleAalbers JelleAalbers marked this pull request as ready for review March 22, 2024 08:19
@JelleAalbers
Copy link
Member Author

Robert's commit fixes the (optional, off by default) interpolation inside templates for the bins at the edge of the histogram. We interpolated linearly between bin centers, but I forgot to turn on extrapolation. So you would expect bad stuff to happen if you fed in an event that was closer to the edge of a histogram than the bin center.

Other than that, I saw no objections since last August, so I'm going to merge.

@JelleAalbers JelleAalbers merged commit 8497c6d into main Mar 22, 2024
2 checks passed
@JelleAalbers JelleAalbers deleted the template_morphing branch March 22, 2024 08:38
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.

2 participants