Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #15843
| From | "Kevin J. McCann" <Kevin.McCann@umbc.edu> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: FindFit bug |
| Date | 2011-02-01 11:52 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <ii8s5o$2l3$1@smc.vnet.net> (permalink) |
| References | <ii5rhr$fh4$1@smc.vnet.net> |
The problem is that for a nonlinear fit there may be local minima. You
need to give FindFit a reasonably good initial guess. For example
fit = FindFit[dat, a Sin[w t + f], {{a, 2}, w, f}, t]
starts with a at 2, and the result gives the correct answer. I usually
use Manipulate to get a good first guess on the parameters for a 1d
function like this.
Kevin
On 1/31/2011 3:23 AM, 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.
>
Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
FindFit bug Igor <igor.volkov@gmail.com> - 2011-01-31 08:23 +0000 Re: FindFit bug "Sjoerd C. de Vries" <sjoerd.c.devries@gmail.com> - 2011-02-01 11:52 +0000 Re: FindFit bug Gary Wardall <gwardall@gmail.com> - 2011-02-01 11:54 +0000 Re: FindFit bug "Kevin J. McCann" <Kevin.McCann@umbc.edu> - 2011-02-01 11:52 +0000 Re: FindFit bug Albert Retey <awnl@gmx-topmail.de> - 2011-02-01 11:54 +0000
csiph-web