Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

'NonlinearFit` confusion

  • To: mathgroup at smc.vnet.net
  • Subject: [mg49844] 'NonlinearFit` confusion
  • From: klingot at yahoo.com (Klingot)
  • Date: Wed, 4 Aug 2004 10:46:20 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

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.


  • Prev by Date: RE: Special characters for German
  • Next by Date: Re: Failure to Evaluate?
  • Previous by thread: Re: Asymmetric quadratic coefficient problem
  • Next by thread: Re: 'NonlinearFit` confusion