Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #15945

Re: FindFit bug

From Daniel Lichtblau <danl@wolfram.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: FindFit bug
Date 2011-02-01 11:55 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <ii8sc2$2r0$1@smc.vnet.net> (permalink)

Show all headers | View raw


Igor wrote:
> Hello,
> It seems that FindFit cannot fit a sine function.
> It produces no warnings and gives a totally
> wrong answer:
> 
> dat = Table[{t, 3 Sin[3 t + 1]}, {t, -3, 3, 0.1}];
> 
> fit = FindFit[dat, a Sin[w t + f], {a, w, f}, t]
> 
> Show[ListPlot[dat], Plot[a Sin[w t + f] /. fit, {t, -3, 3}]]
> 
> Output: {a -> 0.599211, w -> 1.51494, f -> 3.80421}
> 
> At the same time it fits Sin[3t+1] just fine.

Very likely has trouble when not given reasonable starting points. Can 
get around this by using a global method. That would be "NMinimize" 
since the other possibilities are local optimization methods.

In[47]:= fit =
  FindFit[dat, a Sin[w t + f], {a, w, f}, t, Method -> "NMinimize"]

Out[47]= {a -> -3., w -> -3., f -> -1.}

I notice that several methods give a result equivalent to yours, so I 
would guess it is a local minimizer, in the {a,w,f} parameter space, for 
a sums of squares approximation.

Daniel Lichtblau
Wolfram Research

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: FindFit bug Daniel Lichtblau <danl@wolfram.com> - 2011-02-01 11:55 +0000

csiph-web