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

Handle numerically unstable calculations #145

Closed
jacanchaplais opened this issue Aug 31, 2023 · 1 comment · Fixed by #147
Closed

Handle numerically unstable calculations #145

jacanchaplais opened this issue Aug 31, 2023 · 1 comment · Fixed by #147
Assignees
Labels
design enhancement New feature or request

Comments

@jacanchaplais
Copy link
Owner

Approaches:

  1. Raise warnings
  2. Use sentinels, eg. NaN
  3. Clamp values to sensible defaults, eg. 1.0e-14 -> 0

Introducing NaNs seems to be a good idea for MomentumArray.phi when transverse momentum is very small. Then again, emitting particles with negative masses if the magnitude of spatial momentum > energy seems to be common. I suspect these particles generally just have quite a close cancellation between momentum and energy, so it's a numerical precision issue.

Raising warnings would avoid potential breaking changes, but would clutter the standard output, and give users little ability to automatically handle the invalid data.

Clamping values seems risky, because this would assume that the user is happy to have the data get cleaned up for them.

Or nothing could be done, and the impetus could be put on the user to do their own data checking and validation. This seems a bit disingenuous, though.

Will place issue on the backlog until an approach is decided upon.

@jacanchaplais
Copy link
Owner Author

Will implement both warnings and NaNs.

@jacanchaplais jacanchaplais linked a pull request Sep 1, 2023 that will close this issue
jacanchaplais added a commit that referenced this issue Sep 1, 2023
jacanchaplais added a commit that referenced this issue Sep 1, 2023
jacanchaplais added a commit that referenced this issue Sep 3, 2023
Explicit numerical instability handling #145
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design enhancement New feature or request
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant