调用 scipy 函数时出现属性错误

问题描述

我正在尝试使用 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)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...