简体   繁体   English

调用 scipy function 时出现属性错误

[英]Attribute error when calling calling a scipy function

I am trying to run the following function defined on a separate python file using jupyter notebook我正在尝试使用 jupyter notebook 运行在单独的 python 文件上定义的以下 function

def f(x):
    return 2 * norm.cdf(x)

AttributeError: 'function' object has no attribute 'cdf'

However, I am getting an Attribute error.但是,我收到一个属性错误。 I am not sure what is exactly going on as I imported the module correctly in the.py file.当我在 .py 文件中正确导入模块时,我不确定到底发生了什么。

There are plenty of norm() s in the sea, so your problem is very likely that you are not calling the norm() that you think you are.大海中有很多norm() ,所以你的问题很可能是你没有调用你认为的norm() It is always good to be verbose:)冗长总是好的:)

import scipy as scp
from scipy import stats

def f(x):
    return 2*scp.stats.norm.cdf(x)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM