Not a good least squares fit, what is the problem, I can not fitting the Curve peak

47 Views Asked by At

can not fit the curve peak:click see the fig

    data= {{-40,5},{-30,5},{-20,10},{-15,20},{-13,25},
        {-10,27},{-7,45},{-2,70},{-1,120},{0,220},
        {1,300},{2,330},{4,300},{6,270},{7,250},
         {10,150},{11,100},{12,60},{16,50},{17,45},
         {20,30},{21,25},{22,23},{25,15},{40,10},{50,5}}        (*data*)

  model=165 Exp[a^2/b^2/4.-x/b/c]Erfc[a/b/2-x/a/c]+d          (*Fitting model)      


  fit= FindFit[data,model,{{a,1.5},{b,4.},{c,5.},{d,20.}},x]   (* Fitting process*)
  d+165 Exp[0.25a^2/b^2-x/b/c] Erfc[a/(2 b)-x/(a c)]
  {a->0.529679,b->3.40937,c->2.64714,d->28.4233}                (* get the results*)


  modelf =Function[{x},Evaluate[model/.fit]]
  Function[{x},28.4233+165Exp[0.00603416-0.110802 x] Erfc[0.0776799-0.713199 x]]  (found the eqution)

  Plot[Function[{x},28.423306055448116`+165Exp[0.0060341638213215`-0.11080238519843215`x ]Erfc[0.07767988041521112`-0.7131987369585024`x  ]][x],{x,-40.774,50},Epilog?Map[Point,data],Frame->True,PlotRange->{-50,400},AxesStyleWhite]  (*Plot  result*)
1

There are 1 best solutions below

2
On BEST ANSWER

It looks like it should be a parabola. Why are you using EXP{} ? (Or is that the program's SSE function?) I'd put the data into Excel , insert a scatterplot, and choose the 'trendline' function as a 2nd order polynomial, and click to show the equation and R² on the chart, so you have a correct reference. But also review the SSE method; you can enter X's and Y's, then the X²s and Y²s, and run the sums (Hence "SUM of squares of errors") The advantage is that you can choose the function you want from X to Y (f(x)), and the SSE will minimize the coefficients.