MathGroup Archive 2000

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

Search the Archive

Re: Fitting a function to a list (newbie)

mathprof at wrote:
> I'm new to Mathematica 4.0.. 
> I have a list that I'd like to fit to the function:
> A + B*Sin[C*x+D]
> In other words, I'd like to find the (approximate numeric) values of
> A,B,C,D that yield the best fit to my data.
> I tried using Fit[], but it only applies to linear combinations of
> functions, and couldn't optomize the values of C and D.

Fit performs a least-squares approximation; this method only works for
linear combinations of funcions, so the problem is not really
Mathematica, it's more that you're task is not so trivial. You want a
"Non-linear fitting". You could a) have a look at some numerics book
(say, "Numerical Recipes") and program it yourself b) get a special
program for data analysis and visualization which has nl fitting
(xmgrace for unix -which is free- has it, I guess Origin for Windows
should have it also) c) do it on Mathematica using some package or try
to do it yourself. For example, you could construct a function which is
the square of the difference between your data and your sin, with some
initial guesses for A,B,C and D, then try to FindMinimum of the thing on
A,B,C,D. That should work.



  • Prev by Date: Re: NDSolve and numeric-only computation
  • Next by Date: Creating Raster Image Animation
  • Previous by thread: Re: Fitting a function to a list (newbie)
  • Next by thread: Re: Fitting a function to a list (newbie)