Consider:
I'm trying to find an algorithm to fit a sine curve into a data set. This is quite simple using Python SciPy, but now I have to bring the whole algorithm to an microcontroller using embedded C or C++.
Is there a good way to do this in C++? Is there a library?
I'm trying to convert an algorithm written in Python to embedded C++. I hope to find a library or an algorithm in C++.
A very simple algorithm is shown below: No initial "guessed" values of the parameters, and no iterative loop. It is easy to code in C++ or any other language.
If you provide the data (numerical, not graphical), I could show each step of numerical calculus.
Without your data, I made toy data in scanning your graph. From the 11082 pixels of the circular "points" of the graph, only 100 pixels were randomly taken. The coordinates of those pixels where used to create the "toy" data. Of course, this is far to be accurate. Nevertheless, this approach leads to the results below.
The principle of this method is explained in: https://fr.scribd.com/doc/14674814/Regressions-et-equations-integrales
The linearisation of the regression is obtained with numerical integration: Instead of directly fitting the sinusoidal equation one fits a linear integral equation to which the sinusoidal function is a solution. The numerical calculus of the integrals (Sk and SSk) might cause more or less deviations depending on the distribution and scatter of the experimental points. In case of too large deviation the approximate values of the parameters found can be used as good initial values to start the iteration process of a classical non-linear regression.