Joined: 25 Nov 2006
Location: Chapel Hill, NC
|Posted: Sat Nov 26, 2011 11:36 am Post subject:
|The initial guess for b needs to be a lot smaller. What happens is that DG finds a local minima, but there certainly is a better minima. So do the following:
- In the Draw guess menu select "Always". This draws the initial guess as well as the fit.
- Change the initial b value. It should be a lot smaller, so try 0.1, 0.01 etc until the initial guess has approximately the same frequency. You could also change the initial guess of a to be 30.
You can also leave the Draw guess at "If it fails" to only draw the initial guess if the minima can't be found.
The mathematica issue is the following. DG is minimizing the function f(a,b,c,d) = sum (y_i - (a*sin(b*x_i + c) + d) )^2
Since the gradient of f is a non-linear function of a,b,c,d there might be many local minima's. Which you find will depend on the initial guess. One way to visualize it is to think of f(a,b,c,d) to be an undulating surface over a four dimensional domain. Easy to visualize for one or two arguments, and four arguments look very similar. Since there is a sin in there, this surface looks very wavy in both b and c. Waves in two dimensions form a sort of ocean surface and there are a lot of local minima's there. You found one that is close to the initial guess (1,1,1,1).