Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

Numpy array multiplication leads to some values being inf even though the original arrays are all valid floats

$
0
0

I am trying to perform an element wise multiplication of numerous numpy arrays.

The implementation:-

mult = np.ones(len(single_arrays[0]))for i in range(len(single_arrays)):    mult *= single_arrays[i]

Most values in the each of the single arrays is between 0 and 1(some values are above 1), and the 2D "single_arrays" has about 700 individual arrays.

The resultant array "mult" has a lot of "inf" values and one "nan" value even though no array in the "single_arrays" has "inf" or "nan" values, all the values are valid floating points.

Why is this issue arising in mult ? Some values are very small in the array, going to tens and thousandths decimal places, could underflow or overflow be an issue here ?


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>