From: osman@stargate.cinternet.net (Me) Subject: Re: Curve fitting. Date: 7 Mar 1999 10:12:45 -0500 Newsgroups: sci.math.num-analysis Keywords: standard regression On Sun, 7 Mar 1999 Olivier Maës wrote: >Hi all, > >I have few experimental points : > > X Y > 9270 111 > 9411 107 > 9552 98 > 9693 88 > 9833 83 > 9974 82 >10115 87 >11242 96 >11383 111 >11524 121 >11665 117 >11805 104 >11946 96 >12087 103 >12228 121 > >I know that they can be fitted with a curve like : > > Y = aX + b + (cX + d)*sin(eX + f) > >How can I find a, b, c, d, e and f from my measurement points ? > >Thank you for help. > > > Just use gnuplot3.7 with its "fit" command. The only problem is that you have quite a few unknowns and really not enough data. The results of this fit will depend greatly on the initial values. Just keep the coeff of x in the sin term small so it won't oscillate wildly. In a first try I came up with: fit f(x) 'foo.data' via a,b,c,d,e,f After 8 iterations the fit converged. final sum of squares residuals : 398.414 rel. change during last iteration : -8.57448e-06 Final set of parameters 68.3% confidence interval (one at a time) ======================= ========================================= a = 0.00849747 +/- 0.00135903 (15.9934%) b = 9.59555 +/- 14.6627 (152.807%) c = 0.0142024 +/- 0.00196512 (13.8365%) d = -151.585 +/- 21.1732 (13.9678%) e = 0.00732784 +/- 0.0001037 (1.41515%) f = 130.637 +/- 1.14767 (0.878521%) correlation matrix of the fit parameters: a b c d e f a 1.000 -0.996 0.320 -0.323 -0.194 0.173 b -0.996 1.000 -0.321 0.325 0.182 -0.162 c 0.320 -0.321 1.000 -0.996 -0.178 0.169 d -0.323 0.325 -0.996 1.000 0.174 -0.164 e -0.194 0.182 -0.178 0.174 1.000 -0.994 f 0.173 -0.162 0.169 -0.164 -0.994 1.000 you can also plot the results with the initial data: plot 'foo.data', f(x) -- Osman Buyukisik ============================================================================== From: spellucci@mathematik.tu-darmstadt.de (Peter Spellucci) Subject: Re: Curve fitting. Date: 8 Mar 1999 15:35:45 GMT Newsgroups: sci.math.num-analysis In article <7btifk$f0a$1@mars.worldonline.fr>, "Olivier Maës" writes: |> Hi all, |> |> I have few experimental points : |> |> X Y |> 9270 111 snip |> I know that they can be fitted with a curve like : |> |> Y = aX + b + (cX + d)*sin(eX + f) |> |> How can I find a, b, c, d, e and f from my measurement points this is a classical nonlinear least squares problem . you may use any of the nonlinear least squares codes listed at http://plato.la.asu.edu/guide.html using lmdif from minpack, renaming a,b,c,d by x[1],x[2],x[3],x[4],x{5],x[6] and X by (t-10700) i got sum of erros squared = .1713951591894696E+04 loesungsvektor = x[ 1]= .5774884523611436D-02 x[ 2]= .1010204505122279D+03 x[ 3]= .4142059231591140D-02 x[ 4]= -.6742606934928337D+00 x[ 5]= .9998152217705151D+00 x[ 6]= .1445380819587726D+01 hope this helps peter