0

这就是我想要做的:

将数值积分数组(在整个数据范围内)除以特定积分范围内的“四元”积分函数:

maxw = lambda t,en: exp(-en/(kB*t)) # where the following is inside a loop through t values, and B is a data array with the same dimension as en
aa=[]
cc=[]
A=B*maxw(t,en) 
aa.append(trapz(A,en)) # integrate numerically
cc.append(quad(lambda energ: exp(-energ/kB*t),e0,inf)) # integrate fn over range e0, inf
#end of loop in t    
dd=array(aa)/array(cc)

这给出了错误:“操作数不能与形状(n)(n,2)一起广播”,n是t循环的长度

或者换一种说法,对于循环中“t”的每一个值: (1)用trapz对一组数值数据进行积分,变成一个数组;(2) 在一定的范围内使用 quad 积分一个函数,也变成一个数组;然后 (3) 将一个数组除以另一个得到最终数组。

显然我缺少一些东西。我该怎么做?

4

0 回答 0