MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: FindFit bug

  • To: mathgroup at smc.vnet.net
  • Subject: [mg116069] Re: FindFit bug
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Tue, 1 Feb 2011 06:51:23 -0500 (EST)

A starting point fixes it:

dat = Table[{t, 3 Sin[3 t + 1]}, {t, -3, 3, 0.01}];

fit = FindFit[dat, a Sin[w t + f], {{a, 2}, w, f}, t]

Show[ListPlot[dat], Plot[a Sin[w t + f] /. fit, {t, -3, 3}]]

{a -> 3., w -> 3., f -> 1.}

Bobby

On Mon, 31 Jan 2011 02:23:20 -0600, Igor <igor.volkov at gmail.com> 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.
>


-- 
DrMajorBob at yahoo.com


  • Prev by Date: Import Converter for Tecplot XY (ascii, point) data
  • Next by Date: Re: Problems integrating InterpolatingFunction
  • Previous by thread: Import Converter for Tecplot XY (ascii, point) data
  • Next by thread: Re: FindFit bug