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
Computing histogram of float32 data drops small values only at particular positions within the dataset.
In the following code, the output of the histogram function will change, if either the DTYPE or ORDER is changed, resulting in (at least for ORDER) rather inconsistent behavior.
This is a result of floating point precision within the cumulative histogram implementation. When you add 1E-10 to 1.0 at float32 precision, the first value is smaller than the resolution of float32 (approximately 1E-7) and gets rounded to zero:
So depending on the order in which your weights appear, you'll get different behavior.
This type of behavior is entirely expected when working with floating point arithmetic. The solution in this case would be to use a higher-precision floating point representation, such as float64, which has a resolution of approximately 1E-16.
Describe the issue:
Computing histogram of float32 data drops small values only at particular positions within the dataset.
In the following code, the output of the histogram function will change, if either the DTYPE or ORDER is changed, resulting in (at least for ORDER) rather inconsistent behavior.
Reproduce the code example:
Error message:
Python and NumPy Versions:
2.2.5
3.13.3 (main, Apr 9 2025, 07:44:25) [GCC 14.2.1 20250207]
Runtime Environment:
[{'numpy_version': '2.2.5',
'python': '3.13.3 (main, Apr 9 2025, 07:44:25) [GCC 14.2.1 20250207]',
'uname': uname_result(system='Linux', node='book', release='6.13.8-arch1-1', version='#1 SMP PREEMPT_DYNAMIC Sun, 23 Mar 2025 17:17:30 +0000', machine='x86_64')},
{'simd_extensions': {'baseline': ['SSE', 'SSE2', 'SSE3'],
'found': ['SSSE3',
'SSE41',
'POPCNT',
'SSE42',
'AVX',
'F16C',
'FMA3',
'AVX2'],
'not_found': ['AVX512F',
'AVX512CD',
'AVX512_KNL',
'AVX512_KNM',
'AVX512_SKX',
'AVX512_CLX',
'AVX512_CNL',
'AVX512_ICL',
'AVX512_SPR']}},
{'filepath': '/usr/lib/libgomp.so.1.0.0',
'internal_api': 'openmp',
'num_threads': 4,
'prefix': 'libgomp',
'user_api': 'openmp',
'version': None}]
Context for the issue:
No response
The text was updated successfully, but these errors were encountered: