Python: OverflowError: math range error

后端 未结 6 700
轻奢々
轻奢々 2020-12-09 14:56

I get a Overflow error when i try this calculation, but i cant figure out why.

1-math.exp(-4*1000000*-0.0641515994108)
6条回答
  •  [愿得一人]
    2020-12-09 15:49

    Try np.exp() instead of math.exp()

    Numpy handles overflows more gracefully, np.exp(999) results in inf and 1. / (1. + np.exp(999)) therefore simply results in zero

    import math 
    import numpy as np
    
    print(1-np.exp(-4*1000000*-0.0641515994108))
    

提交回复
热议问题