我正在尝试使用mpmath
提供任意精度算术的scipy.stats
库和一起使用的库:
from mpmath import mpf
from scipy.stats import norm
x = mpf(3) # arbitrary precision float
y = norm.cdf(x)
但是,norm.cdf
内部会通过调用来检查其输入是否为数字np.isnan(x)
。因此,我得到以下错误:
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''
有没有办法强制scipy.stats.cdf
使用mpmath.isnan
而不是np.isnan
?或者有其他方法可以解决这个问题吗?