0

I've been trying for hours to fit a sine wave to this data with no success. The bit I'm finding difficult is that there isn't a full wavelength and so only a portion of the sine wave is shown. Here is the data I have:

ydata = vel-mean_vel
xdata = np.linspace(min(phase), max(phase), 9)

def func(x, a, b):
    return  a*np.sin((x*2*np.pi)*b)

popt, pcov = curve_fit(func, xdata, ydata,p0=(-154.52782708, 126.52963958))  
print(popt)


#plotting
plt.figure(figsize=[7,7])
plt.plot(phase, ydata, '.')

plt.plot(xdata, func(xdata, popt[0], popt[1]), color = 'red') 

plot

I'd appreciate any help at all :)

Lewis Cooper
  • 63
  • 10
  • Unfortunately I cannot answer because the question is closed. There is an easy method explained in https://fr.scribd.com/doc/14674814/Regressions-et-equations-integrales . The result is y=a*cos(w*x)+b*sin(w*x)+c with a=-87.562 ; b=-198.9 ; c=20.463 ; w=5.370 .If the question was still open I would give the detail of the calculus. The graph of the sine curve obtained is nicely fitting the shape of the could of points even with a so large scatter of the data. – JJacquelin Feb 19 '21 at 11:00
  • Sorry, I tried to post the graph in addition to your question but this was rejected by reviewers. – JJacquelin Feb 20 '21 at 07:11

0 Answers0