Curve fitting a percentage of data
I have two sets of real data, xdata and ydata, and I'm trying to do an exponencial fitting to them, as shown in my code below.
def func(x, a, b, c):
return a * np.exp(-b * x) + c
popt, pcov = curve_fit(func, xdata, ydata)
plt.scatter(xdata, ydata, color='r', label="Demanda máxima", alpha=0.5)
plt.plot(xdata, func(xdata, *popt), 'r--')
The fitting is working fine, however, I need 90% of my data points to be under/over my fitted curve. Is that a way to do this?
Thanks in advice.