在原始实验数据上找到最大值

问题描述

我正在研究调查对象,在这里我必须绘制一些实验数据,然后找到最大值(临界点),如下图所示:

Example_image

我正在尝试(使用立方方程式)调整拟合曲线以找到最大值,并且我现在正在寻求优化该曲线。我已经尝试过使用maxarray,但是有一个特定的值无法解决这种趋势。

这是我到目前为止所做的:

import matplotlib.pyplot as plt
from scipy.optimize import curve_fit
import numpy as np
import scipy

# Subo los datos experimentales #
datos=np.loadtxt("OFET2.txt",delimiter="\t")
x=datos[:,1]
y=datos[:,4]
n=len(x)
dr=np.diff(y)/np.diff(x)
dx=datos[:n-1,1]

def func(x,a,b,c):
    return -(a*x+b*x**2-c)       # Este x no tiene nada que ver con el dato de x

plt.plot(dx,dr,label='experimental-data')

popt,pcov = curve_fit(func,dx,dr)
print(popt)

#x values for the fitted function
xFit = np.arange(-100,400,0.01)       

#Plot the fitted function
plt.plot(xFit,func(xFit,*popt),'r--',label='fit params: a=%5.3f,b=%5.3f,c=%5.3f' % tuple(popt))

plt.xlabel('x')
plt.ylabel('y')
plt.grid()
plt.legend()
plt.show()

这是该图的图像:

Ploted graphic

一个想法是使曲线仅适合大于0.008(y

希腊人!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)