我想使用lmfit 将椭圆测量数据拟合到复杂模型中.两个测量参数,psi和delta是复杂函数中的变量rho.
我可以尝试用共享参数或picewise方法将问题分离到实部和虚部,但是有没有办法直接用复杂函数来做?仅适合函数的实部工作,但是当我定义复杂的残差函数时,我得到:
TypeError:没有为复数定义排序关系.
下面是我的实际功能拟合代码和我尝试解决复杂的拟合问题:
from __future__ import division
from __future__ import print_function
import numpy as np
from pylab import *
from lmfit import minimize, Parameters, Parameter, report_errors
#=================================================================
# MODEL
def r01_p(eps2, th):
c=cos(th)
s=(sin(th))**2
stev= sqrt(eps2) * c - sqrt(1-(s / eps2))
imen= sqrt(eps2) * c + sqrt(1-(s / eps2))
return stev/imen
def r01_s(eps2, th):
c=cos(th)
s=(sin(th))**2
stev= c - sqrt(eps2) * sqrt(1-(s/eps2))
imen= c + …Run Code Online (Sandbox Code Playgroud)