You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Product uncertainty underflows to zero with many factors #105
Since #85 (#86), the first-order uncertainty of a product of signals is computed from the mantissas and exponents of the factors (np.frexp), so that no intermediate product overflows or underflows whatever the order and magnitudes of a few factors. However, the products of the mantissas before and after each factor are computed with np.cumprod: each mantissa lies in [0.5, 1), so that their product decreases geometrically with the number of factors and finally underflows, even when the product of the signals itself is perfectly representable.
Reproduced with factors all equal to 1 and an uncertainty of 0.01 on each (expected: 0.01 × √n):
dtype
factors
result
expected
float64
1 050
0.324037
0.324037
float64
1 074
0.257812
0.327719
float64
1 100
0
0.331662
float32
130
0.114018
0.114018
float32
150
0.1875
0.122474
float32
200
0
0.141421
The products of the mantissas first lose precision (subnormal numbers), then vanish: the uncertainty of a product of many signals is wrong, then artificially zero, a scientifically misleading result. sigima.proc.signal.product of 200 float32 signals returns dy = 0.
Proposal
Renormalize the running products of the mantissas at each step (np.frexp of the current product, exponents accumulated as integers), for the products before and after each factor: they stay in [0.5, 1) whatever the number of factors. Scaling by powers of two is exact, so that the results are bit-identical wherever no intermediate product underflowed (existing tests unchanged).
The result changes for many factors: the contract of sigima.signal.product goes to version 2 (version 1 was published with Sigima 1.3.0; the one-off exception of 1.4 does not apply to later changes), with its qualification.
Tests with several hundred to several thousand factors, in float32 and float64, including factors different from 1.
Reported by an independent review of Sigima 1.4 (unreleased).
Activity
fix(signal): keep the product uncertainty defined for many factors
PierreRaybaut commentedon Oct 26, 2026
Fixed by #106 (merged into develop).