I am trying to get a physical significant fit to some experimental data. I know that not only will the y values increase monotonically with x but also that dy/dx will also increase monotonically. I have tried a number of fitting functions including a polynomial fit and a univariate spline but neither of these has allowed me to produce the fit I am looking for.
So, I'm looking for a curve fitting function (in scipy?) that will allow me to define the known constraints of the final curve. Below is an example of my data, with a fitted line that does not display a monotonically increasing derivative.
import numpy as np
import matplotlib.pyplot as plt
data = np.array([[ 6.30991828, -10.22329935],
[ 6.30991828, -10.2127338 ],
[ 6.47697236, -10.01359361],
[ 6.47697236, -9.89353722],
[ 6.47697236, -9.81708052],
[ 6.55108034, -9.42113403],
[ 6.55108034, -9.21932801],
[ 6.58617165, -8.40428977],
[ 6.62007321, -7.6500927 ]])
interp = np.linspace(min(data[:,0]), max(data[:,0]), 20)
f = np.polyfit(data[:,0], data[:,-1], 3)
data_interp = np.polyval(f, interp)
plt.plot(data[:,0], data[:,1], 'x', interp, data_interp, '-')
EDIT: I believe that you can do this in MATLAB with the slmengine.