MathGroup Archive 2008

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

Search the Archive

Re: Fitting experimental data

  • To: mathgroup at
  • Subject: [mg85544] Re: Fitting experimental data
  • From: "Kevin J. McCann" <Kevin.McCann at>
  • Date: Wed, 13 Feb 2008 04:28:42 -0500 (EST)
  • Organization: University System of Maryland
  • References: <fopb53$bhu$>

Here is the way I usually do this for a particular example. I generally 
roll my own least-squares fit:

(*Plot the data points,but don't show the plot*)

(*The function that I wish to fit*)

(*The LSQ fit function.*)
(*Note that you can plot this for a range of B and Ro values*)

(*Finally,fit the data by finding the minimum*)
(* The output comes in two parts. The first is *)
(* the sum of the squares; the second, the best fit parameters *)

(* g[R] is the fitting function with the best fit parameters *)

(*Plot the fit along with the original data points*)
FrameLabel->{"R","g(R)"},PlotLabel->"LSQ Demo"

Hope this helps,


Ausman, Kevin wrote:
> I am trying to fit experimental data (a list of {x,y} points) with a 
> model that produces a similar list of points. It seems that FindMinimum 
> with a Levenberg Marquardt method makes the most sense; unfortunately, I 
> can't seem to get it to work.
> soln=FindMinimum[Sum[(xptData[[i,2]]-(simulatedData[xaxis,testInstFunc,
> k1auto,a1initauto])[[i]])^2,{i,1,Length[xaxis]}],{{k1auto,0.04},{a1initauto,0.9}}]
> In this example, xptData is the list of experimental data. simulatedData 
> returns just the y axis as a list (assuming the same x axis), and the 
> resulting list, as you might imagine, depends on k1auto and a1initauto. 
> However, this results in a number of errors, I think because it tries to 
> evaluate simulatedData for the general case rather than for specific 
> instances of k1auto and a1initauto. simulatedData requires the use of 
> ListConvolve, NDSolve, and a number of other functions that seem to 
> preclude a general solution rather than a specific solution.
> Does anyone have any thoughts on how to overcome this problem? Thanks!
> Kevin Ausman
> ausman at


Kevin J. McCann
Research Associate Professor
Physics Building
University of Maryland, Baltimore County
1000 Hilltop Circle
Baltimore, MD 21250

  • Prev by Date: Re: Reduce in Ver 6
  • Next by Date: Re: Sphere through 4 points
  • Previous by thread: Re: Fitting experimental data
  • Next by thread: RE: Fitting experimental data