且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

用python编写数学公式

更新时间:2023-02-13 20:58:01

Python的sqrt操作不支持负整数.但是,numpy适用于复数.虚数$ i $由Python中的1j给出.因此,您必须将方程式转换为:

Python's sqrt operation doesn't support negative integers. However, numpy works with complex numbers. The imaginary number $i$ is given by 1j in Python. So you will have to convert your equation to:

a=abs((np.exp( (g.node[i]['theta']*(1j)) for i in g.nodes_iter()))/g.number_of_nodes())