Re: FindFit (beginner question)
- To: mathgroup at smc.vnet.net
- Subject: [mg63839] Re: FindFit (beginner question)
- From: Bill Rowe <readnewsciv at earthlink.net>
- Date: Wed, 18 Jan 2006 02:39:08 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
On 1/17/06 at 4:33 AM, pfraser at covad.net (Pete Fraser) wrote: >I'm trying to curve fit to a series of points with a Sin. I started >with a test set of points that actually lay on a Sin curve: >samples = Table[{i, Sin[i/4]}, {i, 0, 20}]; >then used FindFit (even giving a hint on the amplitude): >f1 = FindFit[samples, a Sin[b x + c], {{a, 1}, b, c}, x] >I would have expected: >{a -> 1, b -> 0.25, c -> 0} >but actually got: >{a -> -0.125598, b -> 0.978835, c -> 1.984} >What am I doing wrong? The short answer is nothing. Doing non-linear curve fitting is inherently problematic. The answer you get is often very sensitive to the initial starting point. The default starting point uses is 1 for parameters that do not have a specified initial start point. In this particular example changing the initial starting point for b gives the desired result, i.e., In[2]:=FindFit[samples,a Sin[b x +c],{a,{b,0},c},x] Out[2]:={a -> 1., b -> -0.25, c -> 3.14159} which is clearly a correct fit since sin(x) = sin(Pi-x) -- To reply via email subtract one hundred and four