0

I am trying to use non-linear curve fitting for my data that seems to be periodic. So far, I found the "sum of sine" function to be the best; yielding (R² ≈ 1).

I wonder if there is any implementation of such function in Scipy?

Thank you


NOTE:

This question was wrongly closed. Please note that I am asking about the "sum of sine" Algorithm. and the link you provided when marked as duplicate is misleading, because I am asking about something else. Using a naive approach to implement "sum of sine" will not work because this kind of fitting is EXTREMLY sensitive to initial values of the parameters. Matlab does a lot of work under the hood to make it converge (using FFT, etc). So my question is if such implementation (not how to implement it manually) is already available in Scipy.

  • Yes and no. Yes, you could use `scipy.optimize.curve_fit` like matlab does it with `fit(x, y, 'sin3')`, but you still need to take care of initials (probably try different ones) and write the callable for function evaluation yourself (shouldn't be too hard, though). – Jan Sep 28 '21 at 14:11
  • 1
    *"... my question is if such implementation [...] is already available in Scipy."* A specialized fitter like Matlab's sum of sines? No. – Warren Weckesser Sep 28 '21 at 20:41

0 Answers0