Re: 'NonlinearFit` confusion
- To: mathgroup at smc.vnet.net
- Subject: [mg49889] Re: [mg49844] 'NonlinearFit` confusion
- From: DrBob <drbob at bigfoot.com>
- Date: Thu, 5 Aug 2004 09:21:14 -0400 (EDT)
- References: <200408041446.KAA20105@smc.vnet.net>
- Reply-to: drbob at bigfoot.com
- Sender: owner-wri-mathgroup at wolfram.com
Fitting equations to data is always an inexact science. That's the only fundamental you're missing, I think. Bobby On Wed, 4 Aug 2004 10:46:20 -0400 (EDT), Klingot <klingot at yahoo.com> wrote: > I'm trying to fit a sinusoidal function to my data using > 'NonlinearFit' but it's exhibiting rather odd behaviour. Please see my > examples below: > > EXAMPLE (1). >**** As a test, I created a list of data from a function of the form y > = 6 + 2Sin[3 + x] with: > > datay = Table [6 + 2Sin[3 + x], {x, -10Pi, 10Pi, 0.05}]; > datax = Table [x, {x, -10Pi, 10Pi, 0.05}]; > data = Table[{datax[[i]], datay[[i]]}, {i, 1, Length[datay]}]; > > **** Then tested to see whether NonlinearFit would correctly deduce > the equations parameters with: > > NonlinearFit[data, c + a Sin[d + e x], x, {a, c, d,e}] > > **** As expected, it gave me '6.+ 2. Sin[3. + 1. x]' ... exactly as > one would expect :) > > > EXAMPLE (2). > > **** Second test, I modified the equation by multiplying x by 5, ie. > y = 6 + 2Sin[3 + 5x]: > > datay = Table [6 + 2Sin[3 + 5 x], {x, -10Pi, 10Pi, 0.05}]; > datax = Table [x, {x, -10Pi, 10Pi, 0.05}]; > data = Table[{datax[[i]], datay[[i]]}, {i, 1, Length[datay]}]; > > ***** and applied the NonlinearFit as before: > > NonlinearFit[data, c + a Sin[d + e x], x, {a, c, d,e}] > > ***** but this time I get a wildly innacurate result: 6.000165 + > 0.025086 Sin[0.0080308 - 0.247967 x] > > Specifically, the parameters 'a', 'd' and 'e' are all completely in > error by orders of magnitude. > > I tried extending the range of the data to include more cycles of the > sinusoid, thereby making it more continuous/monotonic but that made no > difference. > > Am I missing something fundamental here? > > Any assistance would be greatly appreciated. > > PS: I'm using Mathematica 5.0 on a MAC. > > > -- DrBob at bigfoot.com www.eclecticdreams.net
- References:
- 'NonlinearFit` confusion
- From: klingot@yahoo.com (Klingot)
- 'NonlinearFit` confusion