问题描述
我正在尝试使用需要拟合的三个参数来优化方程。我有一组频率与比率数据,其中比率为 (v2/v1)^2,其中 V2 仅是电阻器两端的电压,V1 是所有三个分压器上的电压。我之前执行过曲线拟合和卡方计算,没有任何问题。当我的代码运行时,它会为数据点的陡峭钟形曲线形状生成线性拟合。
这是我关于适合的代码:
f_scale = 1 / (2 * np.pi)
f_51,RatioSq_51 = np.genfromtxt("2275_LCR_Lab_Data_5mH_1nF.txt",delimiter = ",",unpack = True,skip_header = 1)
omega_51 = 2 * np.pi * f_51
def res_curve_51(omega_51,*theta_51):
R_51 = 100
omega_0,Q,R_prime = theta_51
return ((R_51 / (R_51 + R_prime)) ** 2) / (1 + ((Q ** 2) * ((omega_51 / omega_0) - (omega_0 / omega_51)) ** 2))
a_0 = [omega_0_51_i,Q_51_i,R_prime_51_i] = np.array([10 ** 6,1.0,1.0])
theta_51,theta_51_cov = curve_fit(res_curve_51,omega_51,RatioSq_51,p0 = a_0)
omega_0_51,Q_51,R_prime_51 = theta_51
xPlot_51 = np.linspace(min(omega_51 * f_scale),max(omega_51 * f_scale),1000)
curve_fit_51 = res_curve_51(xPlot_51,*theta_51)
plot_51.plot(xPlot_51,curve_fit_51,color = 'green',linewidth = 1,label = 'Curve Fit')
Data plotted is a steep curve yet I'm being returned a linear fit.
任何帮助将不胜感激,提前致谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)