LogLikelihood transformations and decompositions (FP32 prep)#431
Draft
vhaasteren wants to merge 3 commits intonanograv:devfrom
Draft
LogLikelihood transformations and decompositions (FP32 prep)#431vhaasteren wants to merge 3 commits intonanograv:devfrom
vhaasteren wants to merge 3 commits intonanograv:devfrom
Conversation
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.
Add likelihood transform support and split varying/constant log-likelihood terms
Summary
Extends
LogLikelihoodto support transformed bases ("native","Lw","GtLw") and to optionally return the log-likelihood split into parameter-varying vs. constant terms (e.g., when white noise and delay params are fixed). This enables single-precision workflows and numerical verification.Changes
transformparameter onLogLikelihood:LogLikelihoodnow accepts atransformargument ("native","Lw","GtLw"). The transform selects how the rNr/logdet data term is computed viaget_transformed_rNr_logdet.get_transformed_rNr_logdet: All transforms (native, Lw, GtLw) go through a singleget_transformed_rNr_logdetAPI. Each pulsar returns a tuple whose first element is the parameter-varying part and the rest are constant terms (e.g., dimension counts, log determinants).transform="native"(default), returns a single scalar log-likelihood (backward compatible). Fortransform="Lw"or"GtLw", returns(loglike_varying, loglike_remainder)— the part that depends on the prior matrix B vs. the rest.TransformedLogLikelihoodremoved: Logic folded intoLogLikelihood; the transform is controlled by the constructor argument.Backward compatibility
Existing callers that do not pass
transformgettransform="native"and receive a scalar. PTAs built withlnlikelihood=LogLikelihood(orLogLikelihoodDenseCholesky) behave as before.Usage
Default: scalar log-likelihood (unchanged behavior)
loglike = pta.get_lnlikelihood(params)
Transformed mode: returns (varying, remainder) for single-precision use
pta = PTA(models, lnlikelihood=lambda pta: LogLikelihood(pta, transform="GtLw"))
loglike_varying, loglike_remainder = pta.get_lnlikelihood(params)
total = loglike_varying + loglike_remainder