I have a set of (slightly noisy) data taken from two (or more) curves, but taken either from one or the other curve. As an example, consider this code (in reality, data is noisier, especially in how intervals are sampled from one of the two curves)
x = np.linspace(0, 50, num=100) y1 = np.sin(x/5) * 0.1 y2 = y1 + 0.2 y = y1 * (np.cos(x) > 0) + y2 * (np.cos(x) < 0) y = np.random.normal(y, 0.001) plt.plot(x, y, '.')
That generates a plot like this:
I would like to fit (actually, smooth) two parallel curves to these data, in python. I am using
UnivariateSpline, but apparently I cannot do what I need with it.