I have a one-dimensional data set in PHP, to be precise, an array with linearly increasing indices (to represent the values on the x-axis, the delta being 1) and corresponding values (representing the values on the y-axis). My question is: how can I make a sinusoidal regression for such a data set? I have found linear, exponential and even logarithmic regression algorithms, but none for a sine curve.
The data set is formatted as such:
f(x) would be equal to $array[$x], where x ∈ ℕ
Here’s a Python implementation of a similar algorithm I came across the other day that might be helpful; it shouldn’t be too difficult to translate it into PHP:
http://exnumerus.blogspot.co.uk/2010/04/how-to-fit-sine-wave-example-in-python.html