xpsi-group / xpsi

X-PSI: X-ray Pulse Simulation and Inference
Other
34 stars 21 forks source link

Numerical issue in background marginalization #349

Closed thjsal closed 7 months ago

thjsal commented 9 months ago

It seems that B_for_integrand variable can fail to be between the background integration bounds (even though it should be within those), when the bounds are determined by both the user given support and the default limits. This can lead to numerical problems for the integration, and thus GSL can fail to produce a correct integration result and lead to X-PSI setting an arbitrarily low likelihood value for a parameter vector when that is not necessary.

Here the lines related to the issue: https://github.com/xpsi-group/xpsi/blob/1dfb38f7a598f4dc9b2cd5d507c52018cdcbd492/xpsi/likelihoods/default_background_marginalisation.pyx#L532

Solution would be adding these lines after the linked line:

if B_for_integrand < lower:
    B_for_integrand = lower
elif B_for_integrand > upper:
    B_for_integrand = upper