1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Fitting points to skewed sinusoids

  1. Jun 19, 2012 #1
    Fitting points to "skewed" sinusoids


    I have a problem related to least square fit of data. Let me start from a step back. I have a set of points, given as x-y coordinates. x represents an angle and y the corresponding value of a function. I am fitting sinusoids to those data points, and I am basically doing it like here: http://www.cheric.org/ippage/e/ipdata/2001/13/node6.html [Broken] (see Curve Fitting with Sinusoidal Functions)

    This works very well. I can reconstruct A0, A1 and B1 without problems. What I get is a sinusoid that represents the least square fit to my data points. Now comes my problem. The sinusoids that I have to fit are "skewed". Given a certain set of data, I have to fit a function of the kind:
    y = A \cos (\omega + \arcsin (d \sin (\phi - \omega)) - \alpha)
    where A is the normal amplitude of the cosine, omega is the pulsation, alpha the phase, d and phi are what cause the "skewness". You can try to plot it to see that this function is like a cosine, but not symmetric.

    Now, how would I go about fitting that function to my set of data? The problem is very non-linear and I'm stuck. Any suggestion is very appreciated.

    Last edited by a moderator: May 6, 2017
  2. jcsd
  3. Jun 19, 2012 #2


    User Avatar
    Homework Helper

    Re: Fitting points to "skewed" sinusoids

    It would seem you need to use nonlinear regression. Your same link has a topic about it but doesn't say much. I'm sure you can find descriptions via a Google search. Basically, you linearize the function using the first few Taylor series terms using a 'guess' for the solution, form the least squares problem, solve the resulting matrix equation for the unknowns, then repeat until you converge on a solution.
  4. Jun 19, 2012 #3
    Re: Fitting points to "skewed" sinusoids


    Thanks for the answer. However, it doesn't seem to me that the problem can be easily linearized. My problem is to find the values of A, phi and alpha. If I used a Taylor series expansion I would end up dividing my problem in many linear interpolators, each one working over a subset of my data. Each solution would give me the coefficients of each linear function (m and q), but then I would be back at the beginning, trying to guess my A, phi and alpha from my collection of m and q.

    Does this make sense?
  5. Jun 19, 2012 #4
    Re: Fitting points to "skewed" sinusoids

    Matlab's curve fitting toolbox can also do this in a few clicks if you have it. It will even give you the confidence bands :wink:
  6. Jun 20, 2012 #5


    User Avatar
    Homework Helper

    Re: Fitting points to "skewed" sinusoids

    Sure it can. All that's needed from the Taylor Series is the constant and linear terms. If you have a function f = f(a,b,c) the linearization is:

    f ≈ f0 + ∂f/∂a*Δa + ∂f/∂b*Δb + ∂f/∂c*Δc

    (evaluated at current 'guesses' for a,b,c), which is linear in Δa, Δb, and Δc. It can be difficult sometimes getting good initial 'guesses' for the unknowns (to get convergence), but usually it can be done with a few attempts. Suggest you find some articles on nonlinear regression. It's actually quite straightforward once you get the hang of it.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook