Group Abstract Group Abstract

Message Boards Message Boards

0
|
8.6K Views
|
5 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Fit data with a proper Gaussian using NonlinearModelFit?

Posted 7 years ago

Hi everybody. I need help! I'm trying to fit my data set with a Gaussian, but I was able to get a curve that doesn't look like a Gaussian. I'm noob with this, so you guys please help me! At least I wanna have a hint about how can I handle the parameters to get the best as possible fit. This is what I already have done...

data = Import[
   "/home/leblanc/Documents/Astro/Paper/a.csv", "table", FieldSeparators -> " "];
nlm = NonlinearModelFit[data, a Exp[-(x - b)^2/2 c^2], {a, b, c}, x];
nlm["AdjustedRSquared"];
nlm[x];
nlm["ParameterTable"];
dataplot = ListPlot[data];
fitplot = Plot[nlm[x], {x, 1.8, 2.00}];
Show[dataplot, fitplot];
Attachment

Attachments:
5 Replies
POSTED BY: Hans Dolhaine

I'm use Trial and Error,and knowledge of function properties (like Gaussian,and line),and that's all.

Regards Mariusz.

POSTED BY: Mariusz Iwaniuk

Thank you crack!

Adjustment:

 data = Import["a.csv", "table", FieldSeparators -> " "];
 nlm = NonlinearModelFit[data, 
    d + a*Exp[-(x - b)^2/2 c^2], {{a, 100}, {b, 1.94}, {c, 90}, {d, 
      95}}, x];
 nlm["AdjustedRSquared"];
 nlm[x];
 nlm["ParameterTable"];
 dataplot = ListPlot[data];
 fitplot = 
   Plot[nlm[x], {x, 1.8, 2.10}, PlotStyle -> Red, PlotRange -> All];
 Show[dataplot, fitplot]

enter image description here

A better model:

 data = Import["a.csv", "table", FieldSeparators -> " "];
 nlm = NonlinearModelFit[data, 
    d + a*Exp[-(x - b)^2/2 c^2] + 
     e*x, {{a, 100}, {b, 1.94}, {c, 90}, {d, 95}, {e, 200}}, x];
 nlm["AdjustedRSquared"];
 nlm[x];
 nlm["ParameterTable"];
 dataplot = ListPlot[data];
 fitplot = 
   Plot[nlm[x], {x, 1.8, 2.10}, PlotStyle -> Red, PlotRange -> All];
 Show[dataplot, fitplot]

enter image description here

POSTED BY: Mariusz Iwaniuk
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard