1
votes

I have a problem with fitting this curve with both gnuplot and python.

The file I want to fit is here. I want to fit it with a simple sinusoidal function as the followed:

a+b*sin(c*x+d)

I have as a result in both fitting method of gnuplot and python:

gnuplot version python version

A part from the small difference in the x-scale, the one in python is rescaled, both figure give to me an incorrect fitting.

1
You need an appropriate initial guess. - Christoph

1 Answers

2
votes

If you assume that your data covers several cycles, and that your points are reasonably randomly distributed:

  • the average (mean) y-value is a good guess for a
  • the standard deviation of a sine wave is 1/sqrt(2) of the peak, so a good guess is b = sqrt(2) * stddev(data)
  • c is most easily found from the first strong peak in an FFT of your data