Path: utzoo!attcan!uunet!cs.utexas.edu!rutgers!sun-barr!decwrl!ucbvax!hplabs!hpl-opus!walker From: walker@hpl-opus.HP.COM (Rick Walker) Newsgroups: comp.sources.wanted Subject: Re: Curve fitting program wanted Message-ID: <63140006@hpl-opus.HP.COM> Date: 1 Jul 89 02:58:52 GMT References: <452@carroll1.UUCP> Organization: HP Labs, High Speed Electronics Dept., Palo Alto, CA Lines: 50 / hpl-opus:comp.sources.wanted / jeff@carroll1.UUCP (Jeff Bartig) / 2:25 pm Jun 29, 1989 / > I am looking for a curve fitting program which enables the analysis of > experimental data using a user defined function. I would like to be able > to use it on an IBM PC or a Unix system. I'm looking for either PD or > a good commercial package. > > If anyone knows of such a program, please contact me via email. I will > mail a summary of what I get to whoever wants one. > > Jeff > Try the Downhill Simplex Method as described on p305-309 in Numerical Recipes in C, by Press, Flannery, Teukolsky and Vetterling., Cambridge University Press, 1988. This is a really neat multi-dimensional minimizer that is easy to program. All you need is to do is define a function y = f(x1,x2,x3...xN, p1, p2, p3, p4...) , where x1,x2... are your independant variable, and p1,p2... are your adjustable parameters. Then you need k experimental data points (in N dimensions): x11, x12, x13..., x1N, y1 x21, x22, x23..., x2N, y2 x31, x32, x33..., x3N, y3 ... ... xk3, xk2, xk3..., xkN, yk Next you define your figure of merit X for your fit to be equal to X = The SUM from j=1 to j=k of [f(xj1, xj2, ... xjN, p1, p2, p3 ...) - yj]^2 This gives a "chi-squared error surface" (equivalent to an RMS figure of merit). Run the Simplex algorithm on this surface to find a relative minima and you will have potentially found a good fit for your parameters and your data set. The routines to do this are alot easier to write than they are to describe. See the Byte article: M.S. Caceci and W.P. Cacheris, "Fitting Curves to Data", 1984 BYTE, vol. 9, no. 5, pp. 340-362. for a Pascal implementation of the algorithm and a good discussion of the theory. It works great! -------------- Rick Walker, ...!hplabs!walker