Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@riga
Copy link
Collaborator

@riga riga commented May 4, 2025

Evermore defines values of nuisance / constraint parameters in units of standard deviations of the effect to be applied.

Especially, this is required in the loss computation of the constraint term in

def _constraint(param: Parameter) -> Array:
prior = param.prior
if isinstance(prior, PDFLike):
prior = cast(PDFLike, prior)
if isinstance(prior, pdf.Poisson):
# expectation for Poisson pdf (x+1)*lambda
return prior.log_prob((param.value + 1) * prior.lamb)
return prior.log_prob(param.value)
return jnp.array([0.0])


This PR generalizes the scaling of the parameter value to the evaluation point x of the PDF which is beneficial in two cases:

  • Normal PDFs are usually always created with mean 0 and width 1, so line 27 should always be correct for them. However, it would be more general to make this conversion explicit.
  • For Poisson PDFs this scaling is highly non-trivial and the current version in line 26 leads to undefined behavior for shifts lower than -1 standard deviation.

I added a new abstract PDF method scale_std (side note, I'm not sure if that name is optimal yet), which is implemented by both Normal and Poisson. The former does the usual scaling using mean and width, whereas the second one raises an exception, at least until we have a quantile based, differentiable computation (if that exists at all).

@pfackeldey
Copy link
Owner

Sounds good! 👍

@pfackeldey pfackeldey merged commit 53defb6 into pfackeldey:main May 4, 2025
6 checks passed
@riga riga deleted the feat/pdf_scaling branch May 4, 2025 12:11
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