Monotonically decreasing curve using Python

I have a set of data points as shown. enter image description here

I need to fit the curve to these points so that the curve decreases monotonously. There is no specified functional form for the curve. I am experimenting with curve fitting for the first time and in general, I would like to know how to act when you can select certain functions, select them and compare them to choose the best.

I believe that for a monotonically decreasing curve, the restriction will be that the first derivative is negative. I looked at the scipy.curve_fit and scipy.interpolate.UnivariateSpline functions, but they don't seem to have the ability for limited matching. What would be the best function to use in such a case? Thank.

+3
source
1

, . . , , , , , , .

, / . SSE ? , , ?

- :

import numpy as np
impoty scipy.optimize as opt

def objective(pars):
    a, b, c = pars
    return np.sum((y-(a*np.exp(-b*x)+c))**2)

opt.minimize(objective, x0=np.array([12000, 0.3, 2000])) 
+1

All Articles