问题描述
我正在尝试在numpy数组的第一列上使用scipy.stats.johnsonsu.expect()函数,但是期望值函数包括numpy数组中的值:
A = [MxN] array of positive floats
b = 2
ev_Array = ss.johnsonsu.expect(func=lambda x: (x * b) - A[:,0],args=(dstr_params[0],dstr_params[1]),loc=dstr_params[-2],scale=dstr_params[-1],lb=A[:,0] / b,ub=upper_bound / b)
我收到此错误:
Traceback (most recent call last):
File "myfile.py",line 241,in <module>
main()
File "myfile.py",line 214,in main
ev_Array = ss.johnsonsu.expect(func=lambda x: (x * b) - A[:,File "~/.local/lib/python3.8/site-packages/scipy/stats/_distn_infrastructure.py",line 2561,in expect
vals = integrate.quad(fun,lb,ub,**kwds)[0] / invfac
File "~/.local/lib/python3.8/site-packages/scipy/integrate/quadpack.py",line 348,in quad
flip,a,b = b < a,min(a,b),max(a,b)
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
我可以通过列表的常规迭代来完成此操作,但是我想知道如何在A中传递A,以便输出是[.mx1]数组,其值来自.expect(),而在lambda函数中在计算期望值时,A保持不变。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)