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 a sine curve that isn't a perfect sine curve?

  1. Mar 31, 2013 #1
    For my 3rd year project, I have a set of data which is the variation within an interference pattern.
    The outcome has clear sine curve properties (Alternating peaks and troughs of intensity) but the positions aren't regular (i.e. the peak-to-peak distance between peak1 and peak2 is larger than the distance between peak2 and peak3).

    I have tried using SciDAVis to plot this curve but it finds a best-fit/average kind of sine curve, not a fit that passes through all the available points. Is there a method or program that will help me?

    I would preferably be able to make a note of the equation of the curve in order to plot it with other sine curves of the interference pattern from other varying distances from the sources.
  2. jcsd
  3. Mar 31, 2013 #2
    I'm not sure what the program you're using is, but if your specified model function is a sine wave then it won't be able to account for the frequency variation you describe. Can you find any simple relationships between the peak-to-peak distances? The model function might take the form f(x) = a*sin(x*g(x)), where g(x) can be some linear function in x, say, g(x) = bx + c.
  4. Apr 1, 2013 #3
    If your data extends over a number of periods, try Fast Fourier Transform (FFT).
    If the data extends over only a narow range (a few periods or only a part of a period) and if the expected function patern is y=a*sin(w*x+b)+c, you may try a non-linear regression in order to compute w, a, b, c. This is a difficult problem. The methods are rarely reliable, depending a lot of the data (number, distribution, scatter). Generally, they use some iterative algorithm :
    A especially non-iterative algorithm for the sinusoidal case is presented in pages 35, 36 of the paper " Régressions et équations intégrales" :
    Last edited: Apr 1, 2013
  5. Apr 1, 2013 #4
    What you are trying to fit is probably not enough of a sine wave to fit it like that. What you could do, if the fft doesn't work, is trying to extract the phase [itex]\phi(t)[/itex] and then fit a linear (polynomial) function through it for example. The most simple way to do it, is taking the average value of the function, define it as zero and find the zero crossings. These points represent a phase of [itex]\pi,2\pi,3\pi,\dots[/itex]. You could also do this with the maxima and minima. It is a bit of a hack, but you might get some useful information.
  6. Apr 5, 2013 #5
    You can try the "function finder" on my curve and surface fitting web site, http://zunzun.com - it is free and won't cost anything to give it a try. You can limit the function finder to trigonometric equations only. The direct link is:

    http://zunzun.com/FunctionFinder/2/ [Broken]

    If you need any help with the site, contact me directly:

    James Phillips
    Personal Info deleted

    web: http://zunzun.com

    Last edited by a moderator: May 6, 2017
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook