I'm trying to use the mpmath
library, which provides arbitrary precision arithmetic, and the scipy.stats
library together:
from mpmath import mpf
from scipy.stats import norm
x = mpf(3) # arbitrary precision float
y = norm.cdf(x)
However, norm.cdf
internally checks if its input is a number by calling np.isnan(x)
. Therefore, I get the folloing error:
Traceback (most recent call last):
File "name of my file", line 5, in <module>
y = norm.cdf(x)
File "C:\Program Files\Anaconda3\lib\site-packages\scipy\stats\_distn_infrastructure.py", line 1734, in cdf
place(output, (1-cond0)+np.isnan(x), self.badvalue)
TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
Is there a way to force scipy.stats.cdf
to use mpmath.isnan
instead of np.isnan
? Or is there another way to solve this issue?