1
$\begingroup$

I have a series of data and I want to find the best gaussian fit. As you can see in the notebook I imported, there is something wrong.

Lin0005 is the series of data that I want to put on the y axis. DataX is the table with the x coordinates to associate with Lin0005. Data0005 is the matrix that puts Lin0005 together with DataX.

DataFit0005 should have the coordinates of the points of the gaussian function that best fits Data0005, but as you can see it is not. The values are all too close to zero and I don't understand why.

Can anyone help me?

Import["http://halirutan.github.io/Mathematica-SE-Tools/decode.m"]["http://i.stack.imgur.com/aesRB.png"]
$\endgroup$
2
$\begingroup$

I cannot tell that I understood all you did in your notebook, such as the aim of the operation DataFit0005=Table[{x, a*Exp[-(x - b)^2/2*c^2] /. fit0005}, {x, 0.825 - 64*1.65, 0.825 + 63*1.65}], for example.

However, you are very close to the solution. Your data does not go to zero at large values of x, but rather to a constant, which one can see just plotting the Data0005. For this reason one should add an off-set to parameters:

ff = FindFit[Data0005, a*Exp[-(x - b)^2/(2*c^2)] + d, {a, b, c, d}, x]

(*  {a -> 115., b -> 0.911, c -> 6.37, d -> 5.07}  *)

as can be inspected by direct plotting the data together with the function:

Show[{
  ListPlot[Data0005, PlotRange -> {0, 120}, PlotStyle -> Blue],
  Plot[(a*Exp[-(x - b)^2/(2*c^2)] + d) /. ff, {x, -100, 100}, 
   PlotRange -> All, PlotStyle -> Red]
  }]

yielding the following:

enter image description here

Have fun!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.