问题描述
我正在尝试使用 jupyter notebook 运行在单独的 python 文件上定义的以下函数
def f(x):
return 2 * norm.cdf(x)
AttributeError: 'function' object has no attribute 'cdf'
但是,我收到一个属性错误。当我在 .py 文件中正确导入模块时,我不确定到底发生了什么。
解决方法
海里有很多norm()
,所以你的问题很可能是你没有调用你认为的norm()
。冗长总是好的:)
import scipy as scp
from scipy import stats
def f(x):
return 2*scp.stats.norm.cdf(x)