I am trying to interpolate a concave curve a bit like a gaussian shape , and the number of points is changing and can be very few. I tried a b-spline interplation
spl = UnivariateSpline(x, y,k=2)
y_fit = [max(spl(c),0) for c in x_new]
I tried also a cubic spline. But i have two problems:
- it wants to fit all the points and some time some are noise and i want to ignore them like here
- when i have a few points it has a weird behavior and doesnt follow the needed shape it starts oscillating again like here
is there a way to configurate it in a better way or should i change the method and try a curve fitting function?
“it wants to fit all the points and some time some are noise and i want to ignore them like here“: then you definitely don’t want interpolation, you want curve fitting.
Also “when i have a few points it has a weird behavior and doesnt follow the needed shape it starts oscillating again like here“: it’s hard to say anything without knowing what “the needed shape” is. Figure out the shape then use curve fitting to match the shape’s parameters to your data.