Repository navigation
Keep the product uncertainty defined for many factors - #106
Merged
Merged
Conversation
Since #86, the first-order uncertainty of a product of signals is computed from the mantissas and exponents of the factors, but the products of the mantissas before and after each factor were computed with np.cumprod. Each mantissa lying in [0.5, 1), these products decreased geometrically with the number of factors and underflowed, even when the product itself was representable: the uncertainty was wrong, then zero, from about 150 float32 or 1074 float64 factors (e.g. 0 instead of 0.33 for 1100 factors equal to 1 with an uncertainty of 0.01 each). The running products of the mantissas are now renormalized at each step (np.frexp of the current product, exponents accumulated as integers), so that they stay in [0.5, 1) whatever the number of factors. Scaling by powers of two is exact: the results are bit-identical wherever no intermediate product underflowed. The result changes for many factors: the contract of sigima.signal.product, published at version 1 with Sigima 1.3.0, goes to version 2, qualified. Closes #105 Assisted-by: Claude Opus 5.5
PierreRaybaut
force-pushed
the
fix/product-uncertainty-many-factors
branch
from
October 26, 2026 08:35
2184af6 to
7e1c4c2
Compare
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.
Closes #105
Summary
Since #86, the first-order uncertainty of a product of signals is computed from the mantissas and exponents of the factors (
np.frexp), but the products of the mantissas before and after each factor usednp.cumprod. Each mantissa lying in [0.5, 1), these products decreased geometrically with the number of factors and underflowed, even when the product itself was representable: the uncertainty was wrong (subnormal numbers), then zero, from about 150float32or 1 074float64factors — e.g.0instead of0.3317for 1 100 factors equal to 1 with an uncertainty of 0.01 each, anddy = 0forproduct()of 200float32signals.np.frexpof the current product, exponents accumulated asint64): they stay in [0.5, 1) whatever the number of factors.float32andfloat64factors spanning 10⁻³⁰ to 10³⁰, zeros included; existing tests unchanged).sigima.signal.product, published at version 1 with Sigima 1.3.0, goes to version 2 (the one-off exception of 1.4 does not apply to later changes), qualified at version 2.productat version 2), French translation updated (checked with a gettext build +sphinx_intl update).Validation
float64factors, 200 and 1 000float32factors (σ = 0.01 √n); 1 000 factors of 0.6 (representable product 0.6¹⁰⁰⁰); 4 000 alternating factors 10³ and −10⁻³ (product close to 1, mantissa product about 0.5²⁰⁰⁰). 5 of these 6 cases fail with the former implementation.--qualification-report: no problem (productv2 qualified, validation and replay passed).developagainst this branch: provenance, replay, capsule and signal feature tests pass (163); DataLab reads the local contract versions dynamically, no fixture recordssigima.signal.product.