nanograv / enterprise

ENTERPRISE (Enhanced Numerical Toolbox Enabling a Robust PulsaR Inference SuitE) is a pulsar timing analysis code, aimed at noise analysis, gravitational-wave searches, and timing model analysis.
https://enterprise.readthedocs.io
MIT License
67 stars 67 forks source link

Percentage Point Functions for parameters #353

Closed vhaasteren closed 7 months ago

vhaasteren commented 1 year ago

This PR adds the Percentage Point Function (PPF) to Enterprise parameters. The PPF is the inverse of the CDF, so it can be used to sample from the distribution. Some Nested Sampling implementations require the PPF as input: for instance MultiNest requires the "hypercube transformation". That is done with the PPF.

Now we can do something like:

from enterprise.signals.parameter import LinearExp

le = LinearExp(1, 3)("LEXP")
le.get_ppf(0.5)

The Truncated Normal PPF is not yet implemented, but LinearExp, Normal, and Uniform are there.

codecov[bot] commented 1 year ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 87.48%. Comparing base (5c1e455) to head (fbff5be). Report is 16 commits behind head on dev.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/nanograv/enterprise/pull/353/graphs/tree.svg?width=650&height=150&src=pr&token=7Sjk8cLA85&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nanograv)](https://app.codecov.io/gh/nanograv/enterprise/pull/353?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nanograv) ```diff @@ Coverage Diff @@ ## dev #353 +/- ## ========================================== - Coverage 88.44% 87.48% -0.96% ========================================== Files 13 13 Lines 3037 3133 +96 ========================================== + Hits 2686 2741 +55 - Misses 351 392 +41 ``` | [Files](https://app.codecov.io/gh/nanograv/enterprise/pull/353?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nanograv) | Coverage Δ | | |---|---|---| | [enterprise/signals/parameter.py](https://app.codecov.io/gh/nanograv/enterprise/pull/353?src=pr&el=tree&filepath=enterprise%2Fsignals%2Fparameter.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nanograv#diff-ZW50ZXJwcmlzZS9zaWduYWxzL3BhcmFtZXRlci5weQ==) | `91.66% <100.00%> (+7.60%)` | :arrow_up: | ... and [2 files with indirect coverage changes](https://app.codecov.io/gh/nanograv/enterprise/pull/353/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nanograv) ------ [Continue to review full report in Codecov by Sentry](https://app.codecov.io/gh/nanograv/enterprise/pull/353?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nanograv). > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nanograv) > `Δ = absolute (impact)`, `ø = not affected`, `? = missing data` > Powered by [Codecov](https://app.codecov.io/gh/nanograv/enterprise/pull/353?dropdown=coverage&src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nanograv). Last update [8b1f24c...fbff5be](https://app.codecov.io/gh/nanograv/enterprise/pull/353?dropdown=coverage&src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nanograv). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nanograv).
vhaasteren commented 1 year ago

It seems that this requires some extra unit tests. Actually, the unit tests for the entire parameter class do not check for exceptions. I'll just update it to check for everything...

AaronDJohnson commented 7 months ago

@vhaasteren Is there anything that needs to be done on this one?

vhaasteren commented 7 months ago

No, is ready to go