Handle underflow and overflow errors in Numpy and Scipy

I have the following calculation in my code:

norm.cdf(term_1) + np.exp(term_2) * norm.cdf(term_3)

I use NumPy and scipy.stats libraries. The values of term_1 and term_3 can be too small or too large which results in overflow or underflow errors. The values of norm.cdf(term_1) and norm_cdf(term_3) can cause the issues too. For term_2, it can be as large as 750 sometimes which again leads to infinity. What is the best way to keep accuracy and approximate the equation?

Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.